Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f5ceae6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Document which sys services can be accessed by instant apps"

parents b743b067 8f90bcc5
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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());
            }});

+6 −7
Original line number Diff line number Diff line
@@ -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());
    }

    /**
+16 −0
Original line number Diff line number Diff line
@@ -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.
     */
+1 −0
Original line number Diff line number Diff line
@@ -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);
        }

        /**