summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/SystemServiceRegistry.java12
-rw-r--r--core/java/android/app/WallpaperManager.java13
-rw-r--r--core/java/android/content/Context.java16
-rw-r--r--core/java/android/provider/Settings.java1
4 files changed, 33 insertions, 9 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 495fd3c4682e..66cf99158e00 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -552,8 +552,16 @@ final class SystemServiceRegistry {
registerService(Context.WALLPAPER_SERVICE, WallpaperManager.class,
new CachedServiceFetcher<WallpaperManager>() {
@Override
- public WallpaperManager createService(ContextImpl ctx) {
- return new WallpaperManager(ctx.getOuterContext(),
+ 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);
+ }
+ IWallpaperManager service = IWallpaperManager.Stub.asInterface(b);
+ return new WallpaperManager(service, ctx.getOuterContext(),
ctx.mMainThread.getHandler());
}});
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index 3829afb04eaa..f21746cdd275 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -286,9 +286,8 @@ public class WallpaperManager {
private Bitmap mDefaultWallpaper;
private Handler mMainLooperHandler;
- Globals(Looper looper) {
- IBinder b = ServiceManager.getService(Context.WALLPAPER_SERVICE);
- mService = IWallpaperManager.Stub.asInterface(b);
+ Globals(IWallpaperManager service, Looper looper) {
+ mService = service;
mMainLooperHandler = new Handler(looper);
forgetLoadedWallpaper();
}
@@ -497,17 +496,17 @@ public class WallpaperManager {
private static final Object sSync = new Object[0];
private static Globals sGlobals;
- static void initGlobals(Looper looper) {
+ static void initGlobals(IWallpaperManager service, Looper looper) {
synchronized (sSync) {
if (sGlobals == null) {
- sGlobals = new Globals(looper);
+ sGlobals = new Globals(service, looper);
}
}
}
- /*package*/ WallpaperManager(Context context, Handler handler) {
+ /*package*/ WallpaperManager(IWallpaperManager service, Context context, Handler handler) {
mContext = context;
- initGlobals(context.getMainLooper());
+ initGlobals(service, context.getMainLooper());
}
/**
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index bd8103aebf69..74ba60d32fb6 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3100,6 +3100,14 @@ public abstract class Context {
* service objects between various different contexts (Activities, Applications,
* Services, Providers, etc.)
*
+ * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true,
+ * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE},
+ * {@link #FINGERPRINT_SERVICE}, {@link #SHORTCUT_SERVICE}, {@link #USB_SERVICE},
+ * {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, {@link #WIFI_SERVICE},
+ * {@link #WIFI_AWARE_SERVICE}. For these services this method will return <code>null</code>.
+ * Generally, if you are running as an instant app you should always check whether the result
+ * of this method is null.
+ *
* @param name The name of the desired service.
*
* @return The service or null if the name does not exist.
@@ -3183,6 +3191,14 @@ public abstract class Context {
* Services, Providers, etc.)
* </p>
*
+ * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true,
+ * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE},
+ * {@link #FINGERPRINT_SERVICE}, {@link #SHORTCUT_SERVICE}, {@link #USB_SERVICE},
+ * {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, {@link #WIFI_SERVICE},
+ * {@link #WIFI_AWARE_SERVICE}. For these services this method will return <code>null</code>.
+ * Generally, if you are running as an instant app you should always check whether the result
+ * of this method is null.
+ *
* @param serviceClass The class of the desired service.
* @return The service or null if the class is not a supported system service.
*/
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index c6deecced05d..c57eba26f30c 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -11133,6 +11133,7 @@ public final class Settings {
INSTANT_APP_SETTINGS.add(DEBUG_VIEW_ATTRIBUTES);
INSTANT_APP_SETTINGS.add(WTF_IS_FATAL);
INSTANT_APP_SETTINGS.add(SEND_ACTION_APP_ERROR);
+ INSTANT_APP_SETTINGS.add(ZEN_MODE);
}
/**