diff options
Diffstat (limited to 'services/java/com/android/server/WallpaperManagerService.java')
| -rw-r--r-- | services/java/com/android/server/WallpaperManagerService.java | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index 8a08277..7ed698b 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -19,6 +19,7 @@ package com.android.server; import static android.os.FileObserver.*; import static android.os.ParcelFileDescriptor.*; +import android.app.AppGlobals; import android.app.IWallpaperManager; import android.app.IWallpaperManagerCallback; import android.app.PendingIntent; @@ -31,6 +32,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; +import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; @@ -48,7 +50,7 @@ import android.os.RemoteCallbackList; import android.os.SELinux; import android.os.ServiceManager; import android.os.SystemClock; -import android.os.UserId; +import android.os.UserHandle; import android.service.wallpaper.IWallpaperConnection; import android.service.wallpaper.IWallpaperEngine; import android.service.wallpaper.IWallpaperService; @@ -146,6 +148,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { final Context mContext; final IWindowManager mIWindowManager; + final IPackageManager mIPackageManager; final MyPackageMonitor mMonitor; WallpaperData mLastWallpaper; @@ -389,6 +392,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { mContext = context; mIWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); + mIPackageManager = AppGlobals.getPackageManager(); mMonitor = new MyPackageMonitor(); mMonitor.register(context, null, true); WALLPAPER_BASE_DIR.mkdirs(); @@ -423,9 +427,9 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_USER_SWITCHED.equals(action)) { - switchUser(intent.getIntExtra(Intent.EXTRA_USERID, 0)); + switchUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0)); } else if (Intent.ACTION_USER_REMOVED.equals(action)) { - removeUser(intent.getIntExtra(Intent.EXTRA_USERID, 0)); + removeUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0)); } } }, userFilter); @@ -484,7 +488,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public void clearWallpaper() { if (DEBUG) Slog.v(TAG, "clearWallpaper"); synchronized (mLock) { - clearWallpaperLocked(false, UserId.getCallingUserId()); + clearWallpaperLocked(false, UserHandle.getCallingUserId()); } } @@ -521,7 +525,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public void setDimensionHints(int width, int height) throws RemoteException { checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); WallpaperData wallpaper = mWallpaperMap.get(userId); if (wallpaper == null) { throw new IllegalStateException("Wallpaper not yet initialized for user " + userId); @@ -552,14 +556,14 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public int getWidthHint() throws RemoteException { synchronized (mLock) { - WallpaperData wallpaper = mWallpaperMap.get(UserId.getCallingUserId()); + WallpaperData wallpaper = mWallpaperMap.get(UserHandle.getCallingUserId()); return wallpaper.width; } } public int getHeightHint() throws RemoteException { synchronized (mLock) { - WallpaperData wallpaper = mWallpaperMap.get(UserId.getCallingUserId()); + WallpaperData wallpaper = mWallpaperMap.get(UserHandle.getCallingUserId()); return wallpaper.height; } } @@ -574,7 +578,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { if (callingUid == android.os.Process.SYSTEM_UID) { wallpaperUserId = mCurrentUserId; } else { - wallpaperUserId = UserId.getUserId(callingUid); + wallpaperUserId = UserHandle.getUserId(callingUid); } WallpaperData wallpaper = mWallpaperMap.get(wallpaperUserId); try { @@ -597,7 +601,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { } public WallpaperInfo getWallpaperInfo() { - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); synchronized (mLock) { WallpaperData wallpaper = mWallpaperMap.get(userId); if (wallpaper.connection != null) { @@ -609,7 +613,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public ParcelFileDescriptor setWallpaper(String name) { if (DEBUG) Slog.v(TAG, "setWallpaper"); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); WallpaperData wallpaper = mWallpaperMap.get(userId); if (wallpaper == null) { throw new IllegalStateException("Wallpaper not yet initialized for user " + userId); @@ -656,7 +660,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public void setWallpaperComponent(ComponentName name) { if (DEBUG) Slog.v(TAG, "setWallpaperComponent name=" + name); - int userId = UserId.getCallingUserId(); + int userId = UserHandle.getCallingUserId(); WallpaperData wallpaper = mWallpaperMap.get(userId); if (wallpaper == null) { throw new IllegalStateException("Wallpaper not yet initialized for user " + userId); @@ -710,8 +714,9 @@ class WallpaperManagerService extends IWallpaperManager.Stub { if (DEBUG) Slog.v(TAG, "Using image wallpaper"); } } - ServiceInfo si = mContext.getPackageManager().getServiceInfo(componentName, - PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS); + int serviceUserId = wallpaper.userId; + ServiceInfo si = mIPackageManager.getServiceInfo(componentName, + PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS, serviceUserId); if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) { String msg = "Selected service does not require " + android.Manifest.permission.BIND_WALLPAPER @@ -728,8 +733,10 @@ class WallpaperManagerService extends IWallpaperManager.Stub { Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE); if (componentName != null && !componentName.equals(wallpaper.imageWallpaperComponent)) { // Make sure the selected service is actually a wallpaper service. - List<ResolveInfo> ris = mContext.getPackageManager() - .queryIntentServices(intent, PackageManager.GET_META_DATA); + List<ResolveInfo> ris = + mIPackageManager.queryIntentServices(intent, + intent.resolveTypeIfNeeded(mContext.getContentResolver()), + PackageManager.GET_META_DATA, serviceUserId); for (int i=0; i<ris.size(); i++) { ServiceInfo rsi = ris.get(i).serviceInfo; if (rsi.name.equals(si.name) && @@ -767,11 +774,6 @@ class WallpaperManagerService extends IWallpaperManager.Stub { if (DEBUG) Slog.v(TAG, "Binding to:" + componentName); WallpaperConnection newConn = new WallpaperConnection(wi, wallpaper); intent.setComponent(componentName); - int serviceUserId = wallpaper.userId; - // Because the image wallpaper is running in the system ui - if (componentName.equals(wallpaper.imageWallpaperComponent)) { - serviceUserId = 0; - } intent.putExtra(Intent.EXTRA_CLIENT_LABEL, com.android.internal.R.string.wallpaper_binding_label); intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity( @@ -804,8 +806,8 @@ class WallpaperManagerService extends IWallpaperManager.Stub { } } catch (RemoteException e) { } - } catch (PackageManager.NameNotFoundException e) { - String msg = "Unknown component " + componentName; + } catch (RemoteException e) { + String msg = "Remote exception for " + componentName + "\n" + e; if (fromUser) { throw new IllegalArgumentException(msg); } |
