MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / loop

Method loop

core/java/android/os/Looper.java:110–155  ·  view source on GitHub ↗

Run the message queue in this thread. Be sure to call #quit() to end the loop.

()

Source from the content-addressed store, hash-verified

108 * {@link #quit()} to end the loop.
109 */
110 public static void loop() {
111 final Looper me = myLooper();
112 if (me == null) {
113 throw new RuntimeException("No Looper; Looper.prepare() wasn't called on this thread.");
114 }
115 final MessageQueue queue = me.mQueue;
116
117 // Make sure the identity of this thread is that of the local process,
118 // and keep track of what that identity token actually is.
119 Binder.clearCallingIdentity();
120 final long ident = Binder.clearCallingIdentity();
121
122 for (;;) {
123 Message msg = queue.next(); // might block
124 if (msg == null) {
125 // No message indicates that the message queue is quitting.
126 return;
127 }
128
129 // This must be in a local variable, in case a UI event sets the logger
130 Printer logging = me.mLogging;
131 if (logging != null) {
132 logging.println(">>>>> Dispatching to " + msg.target + " " +
133 msg.callback + ": " + msg.what);
134 }
135
136 msg.target.dispatchMessage(msg);
137
138 if (logging != null) {
139 logging.println("<<<<< Finished to " + msg.target + " " + msg.callback);
140 }
141
142 // Make sure that during the course of dispatching the
143 // identity of the thread wasn't corrupted.
144 final long newIdent = Binder.clearCallingIdentity();
145 if (ident != newIdent) {
146 Log.wtf(TAG, "Thread identity changed from 0x"
147 + Long.toHexString(ident) + " to 0x"
148 + Long.toHexString(newIdent) + " while dispatching to "
149 + msg.target.getClass().getName() + " "
150 + msg.callback + " what=" + msg.what);
151 }
152
153 msg.recycle();
154 }
155 }
156
157 /**
158 * Return the Looper object associated with the current thread. Returns

Callers 15

runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95

Calls 9

myLooperMethod · 0.95
clearCallingIdentityMethod · 0.95
nextMethod · 0.95
printlnMethod · 0.95
wtfMethod · 0.95
recycleMethod · 0.95
getNameMethod · 0.65
dispatchMessageMethod · 0.45
toHexStringMethod · 0.45

Tested by 15

runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76
runMethod · 0.76