Loading services/core/java/com/android/server/location/ContextHubClientBroker.java +40 −16 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub Supplier<Intent> supplier = () -> createIntent(ContextHubManager.EVENT_NANOAPP_MESSAGE, message.getNanoAppId()) .putExtra(ContextHubManager.EXTRA_MESSAGE, message); sendPendingIntent(supplier); sendPendingIntent(supplier, message.getNanoAppId()); } /** Loading @@ -247,7 +247,8 @@ public class ContextHubClientBroker extends IContextHubClient.Stub */ /* package */ void onNanoAppLoaded(long nanoAppId) { invokeCallback(callback -> callback.onNanoAppLoaded(nanoAppId)); sendPendingIntent(() -> createIntent(ContextHubManager.EVENT_NANOAPP_LOADED, nanoAppId)); sendPendingIntent( () -> createIntent(ContextHubManager.EVENT_NANOAPP_LOADED, nanoAppId), nanoAppId); } /** Loading @@ -257,7 +258,8 @@ public class ContextHubClientBroker extends IContextHubClient.Stub */ /* package */ void onNanoAppUnloaded(long nanoAppId) { invokeCallback(callback -> callback.onNanoAppUnloaded(nanoAppId)); sendPendingIntent(() -> createIntent(ContextHubManager.EVENT_NANOAPP_UNLOADED, nanoAppId)); sendPendingIntent( () -> createIntent(ContextHubManager.EVENT_NANOAPP_UNLOADED, nanoAppId), nanoAppId); } /** Loading @@ -280,7 +282,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub Supplier<Intent> supplier = () -> createIntent(ContextHubManager.EVENT_NANOAPP_ABORTED, nanoAppId) .putExtra(ContextHubManager.EXTRA_NANOAPP_ABORT_CODE, abortCode); sendPendingIntent(supplier); sendPendingIntent(supplier, nanoAppId); } /** Loading Loading @@ -360,9 +362,32 @@ public class ContextHubClientBroker extends IContextHubClient.Stub */ private synchronized void sendPendingIntent(Supplier<Intent> supplier) { if (mPendingIntentRequest.hasPendingIntent()) { Intent intent = supplier.get(); doSendPendingIntent(mPendingIntentRequest.getPendingIntent(), supplier.get()); } } /** * Sends an intent to any existing PendingIntent * * @param supplier method to create the extra Intent * @param nanoAppId the ID of the nanoapp which this event is for */ private synchronized void sendPendingIntent(Supplier<Intent> supplier, long nanoAppId) { if (mPendingIntentRequest.hasPendingIntent() && mPendingIntentRequest.getNanoAppId() == nanoAppId) { doSendPendingIntent(mPendingIntentRequest.getPendingIntent(), supplier.get()); } } /** * Sends a PendingIntent with extra Intent data * * @param pendingIntent the PendingIntent * @param intent the extra Intent data */ private void doSendPendingIntent(PendingIntent pendingIntent, Intent intent) { try { mPendingIntentRequest.getPendingIntent().send( pendingIntent.send( mContext, 0 /* code */, intent, null /* onFinished */, null /* Handler */, Manifest.permission.LOCATION_HARDWARE /* requiredPermission */, null /* options */); Loading @@ -373,7 +398,6 @@ public class ContextHubClientBroker extends IContextHubClient.Stub close(); } } } /** * @return true if the client is still registered with the service, false otherwise Loading Loading
services/core/java/com/android/server/location/ContextHubClientBroker.java +40 −16 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub Supplier<Intent> supplier = () -> createIntent(ContextHubManager.EVENT_NANOAPP_MESSAGE, message.getNanoAppId()) .putExtra(ContextHubManager.EXTRA_MESSAGE, message); sendPendingIntent(supplier); sendPendingIntent(supplier, message.getNanoAppId()); } /** Loading @@ -247,7 +247,8 @@ public class ContextHubClientBroker extends IContextHubClient.Stub */ /* package */ void onNanoAppLoaded(long nanoAppId) { invokeCallback(callback -> callback.onNanoAppLoaded(nanoAppId)); sendPendingIntent(() -> createIntent(ContextHubManager.EVENT_NANOAPP_LOADED, nanoAppId)); sendPendingIntent( () -> createIntent(ContextHubManager.EVENT_NANOAPP_LOADED, nanoAppId), nanoAppId); } /** Loading @@ -257,7 +258,8 @@ public class ContextHubClientBroker extends IContextHubClient.Stub */ /* package */ void onNanoAppUnloaded(long nanoAppId) { invokeCallback(callback -> callback.onNanoAppUnloaded(nanoAppId)); sendPendingIntent(() -> createIntent(ContextHubManager.EVENT_NANOAPP_UNLOADED, nanoAppId)); sendPendingIntent( () -> createIntent(ContextHubManager.EVENT_NANOAPP_UNLOADED, nanoAppId), nanoAppId); } /** Loading @@ -280,7 +282,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub Supplier<Intent> supplier = () -> createIntent(ContextHubManager.EVENT_NANOAPP_ABORTED, nanoAppId) .putExtra(ContextHubManager.EXTRA_NANOAPP_ABORT_CODE, abortCode); sendPendingIntent(supplier); sendPendingIntent(supplier, nanoAppId); } /** Loading Loading @@ -360,9 +362,32 @@ public class ContextHubClientBroker extends IContextHubClient.Stub */ private synchronized void sendPendingIntent(Supplier<Intent> supplier) { if (mPendingIntentRequest.hasPendingIntent()) { Intent intent = supplier.get(); doSendPendingIntent(mPendingIntentRequest.getPendingIntent(), supplier.get()); } } /** * Sends an intent to any existing PendingIntent * * @param supplier method to create the extra Intent * @param nanoAppId the ID of the nanoapp which this event is for */ private synchronized void sendPendingIntent(Supplier<Intent> supplier, long nanoAppId) { if (mPendingIntentRequest.hasPendingIntent() && mPendingIntentRequest.getNanoAppId() == nanoAppId) { doSendPendingIntent(mPendingIntentRequest.getPendingIntent(), supplier.get()); } } /** * Sends a PendingIntent with extra Intent data * * @param pendingIntent the PendingIntent * @param intent the extra Intent data */ private void doSendPendingIntent(PendingIntent pendingIntent, Intent intent) { try { mPendingIntentRequest.getPendingIntent().send( pendingIntent.send( mContext, 0 /* code */, intent, null /* onFinished */, null /* Handler */, Manifest.permission.LOCATION_HARDWARE /* requiredPermission */, null /* options */); Loading @@ -373,7 +398,6 @@ public class ContextHubClientBroker extends IContextHubClient.Stub close(); } } } /** * @return true if the client is still registered with the service, false otherwise Loading