Fix issue 7198767, 7198366, 7189824.

Bug #7198767: Crash on choosing App info from the Recent apps tab
Bug #7198366: Settings UI should not show other Users' apps
Bug #7189824: Settings crashes on trying to access Battery usage summary

Also fix running services to be able to show user bitmap when in
secondary users, crash in running services if a service is running
whose app is not installed for the current user.

Change-Id: Ief24810c9ddce1ec3f8641ce08af79e1bc18f221
This commit is contained in:
Dianne Hackborn
2012-09-21 16:40:21 -07:00
parent 9e143f5e9d
commit c715fb1207
6 changed files with 50 additions and 25 deletions

View File

@@ -18,6 +18,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.os.SystemClock;
import android.os.UserHandle;
import android.text.format.Formatter;
import android.util.Log;
@@ -238,6 +239,7 @@ public class ApplicationsState {
final Context mContext;
final PackageManager mPm;
final int mRetrieveFlags;
PackageIntentReceiver mPackageIntentReceiver;
boolean mResumed;
@@ -401,7 +403,15 @@ public class ApplicationsState {
Process.THREAD_PRIORITY_BACKGROUND);
mThread.start();
mBackgroundHandler = new BackgroundHandler(mThread.getLooper());
// Only the owner can see all apps.
if (UserHandle.myUserId() == 0) {
mRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
PackageManager.GET_DISABLED_COMPONENTS;
} else {
mRetrieveFlags = PackageManager.GET_DISABLED_COMPONENTS;
}
/**
* This is a trick to prevent the foreground thread from being delayed.
* The problem is that Dalvik monitors are initially spin locks, to keep
@@ -591,9 +601,7 @@ public class ApplicationsState {
mPackageIntentReceiver = new PackageIntentReceiver();
mPackageIntentReceiver.registerReceiver();
}
mApplications = mPm.getInstalledApplications(
PackageManager.GET_UNINSTALLED_PACKAGES |
PackageManager.GET_DISABLED_COMPONENTS);
mApplications = mPm.getInstalledApplications(mRetrieveFlags);
if (mApplications == null) {
mApplications = new ArrayList<ApplicationInfo>();
}
@@ -723,9 +731,7 @@ public class ApplicationsState {
if (DEBUG_LOCKING) Log.v(TAG, "addPackage release lock: already exists");
return;
}
ApplicationInfo info = mPm.getApplicationInfo(pkgName,
PackageManager.GET_UNINSTALLED_PACKAGES |
PackageManager.GET_DISABLED_COMPONENTS);
ApplicationInfo info = mPm.getApplicationInfo(pkgName, mRetrieveFlags);
mApplications.add(info);
if (!mBackgroundHandler.hasMessages(BackgroundHandler.MSG_LOAD_ENTRIES)) {
mBackgroundHandler.sendEmptyMessage(BackgroundHandler.MSG_LOAD_ENTRIES);