summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/SystemServiceRegistry.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 337939fd2388..03bec71548a8 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -1667,11 +1667,20 @@ public final class SystemServiceRegistry {
@Override
public WearableSensingManager createService(ContextImpl ctx)
throws ServiceNotFoundException {
- IBinder iBinder = ServiceManager.getServiceOrThrow(
+ IBinder iBinder = ServiceManager.getService(
Context.WEARABLE_SENSING_SERVICE);
- IWearableSensingManager manager =
- IWearableSensingManager.Stub.asInterface(iBinder);
- return new WearableSensingManager(ctx.getOuterContext(), manager);
+ if (iBinder != null) {
+ IWearableSensingManager manager =
+ IWearableSensingManager.Stub.asInterface(iBinder);
+ return new WearableSensingManager(ctx.getOuterContext(), manager);
+ }
+ // Wear intentionally removes the service, so do not throw a
+ // ServiceNotFoundException when the service is not absent.
+ if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)
+ && android.server.Flags.removeWearableSensingServiceFromWear()) {
+ return null;
+ }
+ throw new ServiceNotFoundException(Context.WEARABLE_SENSING_SERVICE);
}});
registerService(Context.ON_DEVICE_INTELLIGENCE_SERVICE, OnDeviceIntelligenceManager.class,