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:
@@ -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);
|
||||
|
@@ -340,7 +340,8 @@ public class InstalledAppDetails extends Fragment
|
||||
}
|
||||
} else if ((mPackageInfo.applicationInfo.flags
|
||||
& ApplicationInfo.FLAG_INSTALLED) == 0) {
|
||||
mUninstallButton.setText(R.string.install_text);
|
||||
mUninstallButton.setText(R.string.uninstall_text);
|
||||
enabled = false;
|
||||
} else {
|
||||
mUninstallButton.setText(R.string.uninstall_text);
|
||||
}
|
||||
@@ -392,6 +393,9 @@ public class InstalledAppDetails extends Fragment
|
||||
|
||||
mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
|
||||
|
||||
// Need to make sure we have loaded applications at this point.
|
||||
mSession.resume();
|
||||
|
||||
retrieveAppEntry();
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
@@ -1134,6 +1138,7 @@ public class InstalledAppDetails extends Fragment
|
||||
Uri.fromParts("package", mAppEntry.info.packageName, null));
|
||||
intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { mAppEntry.info.packageName });
|
||||
intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid);
|
||||
intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(mAppEntry.info.uid));
|
||||
getActivity().sendOrderedBroadcast(intent, null, mCheckKillProcessesReceiver, null,
|
||||
Activity.RESULT_CANCELED, null, null);
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.applications;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.users.UserUtils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerNative;
|
||||
@@ -377,7 +378,8 @@ public class RunningState {
|
||||
}
|
||||
|
||||
try {
|
||||
ApplicationInfo ai = pm.getApplicationInfo(mProcessName, 0);
|
||||
ApplicationInfo ai = pm.getApplicationInfo(mProcessName,
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
if (ai.uid == mUid) {
|
||||
mDisplayLabel = ai.loadLabel(pm);
|
||||
mLabel = mDisplayLabel.toString();
|
||||
@@ -394,7 +396,8 @@ public class RunningState {
|
||||
// If there is one package with this uid, that is what we want.
|
||||
if (pkgs.length == 1) {
|
||||
try {
|
||||
ApplicationInfo ai = pm.getApplicationInfo(pkgs[0], 0);
|
||||
ApplicationInfo ai = pm.getApplicationInfo(pkgs[0],
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
mDisplayLabel = ai.loadLabel(pm);
|
||||
mLabel = mDisplayLabel.toString();
|
||||
mPackageInfo = ai;
|
||||
@@ -435,7 +438,8 @@ public class RunningState {
|
||||
|
||||
// Finally... whatever, just pick the first package's name.
|
||||
try {
|
||||
ApplicationInfo ai = pm.getApplicationInfo(pkgs[0], 0);
|
||||
ApplicationInfo ai = pm.getApplicationInfo(pkgs[0],
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
mDisplayLabel = ai.loadLabel(pm);
|
||||
mLabel = mDisplayLabel.toString();
|
||||
mPackageInfo = ai;
|
||||
@@ -455,7 +459,8 @@ public class RunningState {
|
||||
si = new ServiceItem(mUserId);
|
||||
si.mRunningService = service;
|
||||
try {
|
||||
si.mServiceInfo = pm.getServiceInfo(service.service, 0);
|
||||
si.mServiceInfo = pm.getServiceInfo(service.service,
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
si.mDisplayLabel = makeLabel(pm,
|
||||
@@ -818,12 +823,9 @@ public class RunningState {
|
||||
userItem.mUser = new UserState();
|
||||
UserInfo info = mUm.getUserInfo(newItem.mUserId);
|
||||
userItem.mUser.mInfo = info;
|
||||
if (info != null && info.iconPath != null) {
|
||||
try {
|
||||
userItem.mUser.mIcon = Drawable.createFromPath(info.iconPath);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Failure loading user picture " + info.iconPath, e);
|
||||
}
|
||||
if (info != null) {
|
||||
userItem.mUser.mIcon = UserUtils.getUserIcon(mUm, info,
|
||||
context.getResources());
|
||||
}
|
||||
String name = info != null ? info.name : null;
|
||||
if (name == null) {
|
||||
|
Reference in New Issue
Block a user