Created
November 21, 2020 17:22
-
-
Save user-mw/96a1a591226f9c41e2f3e7d1baf8677e to your computer and use it in GitHub Desktop.
First constructor of Messenger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Handler { | |
| // A lot of code | |
| @UnsupportedAppUsage | |
| final IMessenger getIMessenger() { | |
| synchronized (mQueue) { | |
| if (mMessenger != null) { | |
| return mMessenger; | |
| } | |
| mMessenger = new MessengerImpl(); | |
| return mMessenger; | |
| } | |
| } | |
| private final class MessengerImpl extends IMessenger.Stub { | |
| public void send(Message msg) { | |
| msg.sendingUid = Binder.getCallingUid(); | |
| Handler.this.sendMessage(msg); | |
| } | |
| } | |
| // A lot of code | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class Messenger implements Parcelable { | |
| private final IMessenger mTarget; | |
| /** | |
| * Create a new Messenger pointing to the given Handler. Any Message | |
| * objects sent through this Messenger will appear in the Handler as if | |
| * {@link Handler#sendMessage(Message) Handler.sendMessage(Message)} had | |
| * been called directly. | |
| * | |
| * @param target The Handler that will receive sent messages. | |
| */ | |
| public Messenger(Handler target) { | |
| mTarget = target.getIMessenger(); | |
| } | |
| // Code | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment