summaryrefslogtreecommitdiff
path: root/core/java/android/app/SystemServiceRegistry.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-01-16 18:29:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-01-16 18:29:18 +0000
commit8da97bddbd1a7b07e4bf2e5cf58ac1373a271fb8 (patch)
tree486e34306bfb1f13bee29eb52249c66fc81f52d2 /core/java/android/app/SystemServiceRegistry.java
parent3876ecd56cd9499dfe7cf8d20862df90c8dbd1e7 (diff)
parente13851556bcfecff6de4b3a1a99be4dcaa5853a1 (diff)
Merge "DO NOT MERGE - Merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master" into stage-aosp-master
Diffstat (limited to 'core/java/android/app/SystemServiceRegistry.java')
-rw-r--r--core/java/android/app/SystemServiceRegistry.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 88976e182e6d..e41510da479a 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -714,11 +714,22 @@ final class SystemServiceRegistry {
@Override
public WallpaperManager createService(ContextImpl ctx)
throws ServiceNotFoundException {
- final IBinder b;
- if (ctx.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.P) {
- b = ServiceManager.getServiceOrThrow(Context.WALLPAPER_SERVICE);
- } else {
- b = ServiceManager.getService(Context.WALLPAPER_SERVICE);
+ final IBinder b = ServiceManager.getService(Context.WALLPAPER_SERVICE);
+ if (b == null) {
+ // There are 2 reason service can be null:
+ // 1.Device doesn't support it - that's fine
+ // 2.App is running on instant mode - should fail
+ final boolean enabled = Resources.getSystem()
+ .getBoolean(com.android.internal.R.bool.config_enableWallpaperService);
+ if (!enabled) {
+ // Life moves on...
+ return DisabledWallpaperManager.getInstance();
+ }
+ if (ctx.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.P) {
+ // Instant app
+ throw new ServiceNotFoundException(Context.WALLPAPER_SERVICE);
+ }
+ // Bad state - WallpaperManager methods will throw exception
}
IWallpaperManager service = IWallpaperManager.Stub.asInterface(b);
return new WallpaperManager(service, ctx.getOuterContext(),