diff options
| author | 2016-07-14 14:19:55 -0700 | |
|---|---|---|
| committer | 2016-07-15 11:20:36 -0700 | |
| commit | 40ea083b59c05beec2eb2c064927086aa55173f3 (patch) | |
| tree | 1a10a2fd7784353b5d777956719b4ba4cb11e902 | |
| parent | a8b4e7320a2b6f6f6e234b5b195441e0fb5e3a47 (diff) | |
Add way to set live wallpaper across users
Also adds an entry point for vendor specific services
to SystemUI.
Bug: 30038484
Change-Id: I8f335c1f7de15d619f2c688a8ac95372f166595f
5 files changed, 58 insertions, 6 deletions
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl index 9cd70e6d8366..db7d54bd40cf 100644 --- a/core/java/android/app/IWallpaperManager.aidl +++ b/core/java/android/app/IWallpaperManager.aidl @@ -49,7 +49,7 @@ interface IWallpaperManager { /** * 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. diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index 79f2a1e90c0a..9f1c5a6135f3 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -1400,12 +1400,26 @@ public class WallpaperManager { */ @SystemApi 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) { Log.w(TAG, "WallpaperService not running"); throw new RuntimeException(new DeadSystemException()); } try { - sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName()); + sGlobals.mService.setWallpaperComponentChecked(name, mContext.getOpPackageName(), + userId); return true; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index 39a341216f2c..52b5a54a7621 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -55,7 +55,8 @@ public class SystemUIApplication extends Application { com.android.systemui.media.RingtonePlayer.class, com.android.systemui.keyboard.KeyboardUI.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 }; /** diff --git a/packages/SystemUI/src/com/android/systemui/VendorServices.java b/packages/SystemUI/src/com/android/systemui/VendorServices.java new file mode 100644 index 000000000000..0be6b12fa365 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/VendorServices.java @@ -0,0 +1,29 @@ +/* + * 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 + } + +} diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 06e5e7318d51..193dc0374f47 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -1453,19 +1453,27 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { } @Override - public void setWallpaperComponentChecked(ComponentName name, String callingPackage) { + public void setWallpaperComponentChecked(ComponentName name, String callingPackage, + int userId) { + if (isWallpaperSupported(callingPackage) && isSetWallpaperAllowed(callingPackage)) { - setWallpaperComponent(name); + setWallpaperComponent(name, userId); } } // ToDo: Remove this version of the function @Override 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); + synchronized (mLock) { if (DEBUG) Slog.v(TAG, "setWallpaperComponent name=" + name); - int userId = UserHandle.getCallingUserId(); WallpaperData wallpaper = mWallpaperMap.get(userId); if (wallpaper == null) { throw new IllegalStateException("Wallpaper not yet initialized for user " + userId); |