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

Commit 119840eb authored by Adrian Roos's avatar Adrian Roos Committed by android-build-merger
Browse files

Merge \"Add way to set live wallpaper across users\" into nyc-mr1-dev

am: 9a7c3bd5

Change-Id: Ia5630143df774d76d5867e8e9541775e07e1c5df
parents dbf15041 9a7c3bd5
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ interface IWallpaperManager {
    /**
    /**
     * Set the live wallpaper. This only affects the system wallpaper.
     * Set the live wallpaper. This only affects the system wallpaper.
     */
     */
    void setWallpaperComponentChecked(in ComponentName name, in String callingPackage);
    void setWallpaperComponentChecked(in ComponentName name, in String callingPackage, int userId);


    /**
    /**
     * Set the live wallpaper. This only affects the system wallpaper.
     * Set the live wallpaper. This only affects the system wallpaper.
+15 −1
Original line number Original line Diff line number Diff line
@@ -1404,12 +1404,26 @@ public class WallpaperManager {
     */
     */
    @SystemApi
    @SystemApi
    public boolean setWallpaperComponent(ComponentName name) {
    public boolean setWallpaperComponent(ComponentName name) {
        return setWallpaperComponent(name, UserHandle.myUserId());
    }

    /**
     * Set the live wallpaper.
     *
     * This can only be called by packages with android.permission.SET_WALLPAPER_COMPONENT
     * permission. The caller must hold the INTERACT_ACROSS_USERS_FULL permission to change
     * another user's wallpaper.
     *
     * @hide
     */
    public boolean setWallpaperComponent(ComponentName name, int userId) {
        if (sGlobals.mService == null) {
        if (sGlobals.mService == null) {
            Log.w(TAG, "WallpaperService not running");
            Log.w(TAG, "WallpaperService not running");
            throw new RuntimeException(new DeadSystemException());
            throw new RuntimeException(new DeadSystemException());
        }
        }
        try {
        try {
            sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName());
            sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName(),
                    userId);
            return true;
            return true;
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
+2 −1
Original line number Original line Diff line number Diff line
@@ -55,7 +55,8 @@ public class SystemUIApplication extends Application {
            com.android.systemui.media.RingtonePlayer.class,
            com.android.systemui.media.RingtonePlayer.class,
            com.android.systemui.keyboard.KeyboardUI.class,
            com.android.systemui.keyboard.KeyboardUI.class,
            com.android.systemui.tv.pip.PipUI.class,
            com.android.systemui.tv.pip.PipUI.class,
            com.android.systemui.shortcut.ShortcutKeyDispatcher.class
            com.android.systemui.shortcut.ShortcutKeyDispatcher.class,
            com.android.systemui.VendorServices.class
    };
    };


    /**
    /**
+29 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui;

/**
 * Placeholder for any vendor-specific services.
 */
public class VendorServices extends SystemUI {

    @Override
    public void start() {
        // no-op
    }

}
+11 −3
Original line number Original line Diff line number Diff line
@@ -1470,19 +1470,27 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
    }
    }


    @Override
    @Override
    public void setWallpaperComponentChecked(ComponentName name, String callingPackage) {
    public void setWallpaperComponentChecked(ComponentName name, String callingPackage,
            int userId) {

        if (isWallpaperSupported(callingPackage) && isSetWallpaperAllowed(callingPackage)) {
        if (isWallpaperSupported(callingPackage) && isSetWallpaperAllowed(callingPackage)) {
            setWallpaperComponent(name);
            setWallpaperComponent(name, userId);
        }
        }
    }
    }


    // ToDo: Remove this version of the function
    // ToDo: Remove this version of the function
    @Override
    @Override
    public void setWallpaperComponent(ComponentName name) {
    public void setWallpaperComponent(ComponentName name) {
        setWallpaperComponent(name, UserHandle.getCallingUserId());
    }

    private void setWallpaperComponent(ComponentName name, int userId) {
        userId = ActivityManager.handleIncomingUser(getCallingPid(), getCallingUid(), userId,
                false /* all */, true /* full */, "changing live wallpaper", null /* pkg */);
        checkPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT);
        checkPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT);

        synchronized (mLock) {
        synchronized (mLock) {
            if (DEBUG) Slog.v(TAG, "setWallpaperComponent name=" + name);
            if (DEBUG) Slog.v(TAG, "setWallpaperComponent name=" + name);
            int userId = UserHandle.getCallingUserId();
            WallpaperData wallpaper = mWallpaperMap.get(userId);
            WallpaperData wallpaper = mWallpaperMap.get(userId);
            if (wallpaper == null) {
            if (wallpaper == null) {
                throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
                throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);