Skip to content

Commit 2c577f1

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Fix adding live wallpaper in a second user" into jb-mr1-dev
2 parents 04951a5 + 4e2820c commit 2c577f1

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

services/java/com/android/server/WallpaperManagerService.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static android.os.FileObserver.*;
2020
import static android.os.ParcelFileDescriptor.*;
2121

22+
import android.app.AppGlobals;
2223
import android.app.IWallpaperManager;
2324
import android.app.IWallpaperManagerCallback;
2425
import android.app.PendingIntent;
@@ -31,6 +32,7 @@
3132
import android.content.Intent;
3233
import android.content.IntentFilter;
3334
import android.content.ServiceConnection;
35+
import android.content.pm.IPackageManager;
3436
import android.content.pm.PackageManager;
3537
import android.content.pm.ResolveInfo;
3638
import android.content.pm.ServiceInfo;
@@ -146,6 +148,7 @@ public void onEvent(int event, String path) {
146148

147149
final Context mContext;
148150
final IWindowManager mIWindowManager;
151+
final IPackageManager mIPackageManager;
149152
final MyPackageMonitor mMonitor;
150153
WallpaperData mLastWallpaper;
151154

@@ -389,6 +392,7 @@ public WallpaperManagerService(Context context) {
389392
mContext = context;
390393
mIWindowManager = IWindowManager.Stub.asInterface(
391394
ServiceManager.getService(Context.WINDOW_SERVICE));
395+
mIPackageManager = AppGlobals.getPackageManager();
392396
mMonitor = new MyPackageMonitor();
393397
mMonitor.register(context, null, true);
394398
WALLPAPER_BASE_DIR.mkdirs();
@@ -710,8 +714,9 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
710714
if (DEBUG) Slog.v(TAG, "Using image wallpaper");
711715
}
712716
}
713-
ServiceInfo si = mContext.getPackageManager().getServiceInfo(componentName,
714-
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS);
717+
int serviceUserId = wallpaper.userId;
718+
ServiceInfo si = mIPackageManager.getServiceInfo(componentName,
719+
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS, serviceUserId);
715720
if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
716721
String msg = "Selected service does not require "
717722
+ android.Manifest.permission.BIND_WALLPAPER
@@ -728,8 +733,10 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
728733
Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
729734
if (componentName != null && !componentName.equals(wallpaper.imageWallpaperComponent)) {
730735
// Make sure the selected service is actually a wallpaper service.
731-
List<ResolveInfo> ris = mContext.getPackageManager()
732-
.queryIntentServices(intent, PackageManager.GET_META_DATA);
736+
List<ResolveInfo> ris =
737+
mIPackageManager.queryIntentServices(intent,
738+
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
739+
PackageManager.GET_META_DATA, serviceUserId);
733740
for (int i=0; i<ris.size(); i++) {
734741
ServiceInfo rsi = ris.get(i).serviceInfo;
735742
if (rsi.name.equals(si.name) &&
@@ -767,7 +774,6 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
767774
if (DEBUG) Slog.v(TAG, "Binding to:" + componentName);
768775
WallpaperConnection newConn = new WallpaperConnection(wi, wallpaper);
769776
intent.setComponent(componentName);
770-
int serviceUserId = wallpaper.userId;
771777
intent.putExtra(Intent.EXTRA_CLIENT_LABEL,
772778
com.android.internal.R.string.wallpaper_binding_label);
773779
intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
@@ -800,8 +806,8 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
800806
}
801807
} catch (RemoteException e) {
802808
}
803-
} catch (PackageManager.NameNotFoundException e) {
804-
String msg = "Unknown component " + componentName;
809+
} catch (RemoteException e) {
810+
String msg = "Remote exception for " + componentName + "\n" + e;
805811
if (fromUser) {
806812
throw new IllegalArgumentException(msg);
807813
}

0 commit comments

Comments
 (0)