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

@@ -34,6 +34,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
import android.preference.PreferenceActivity;
import android.provider.Settings;
import android.text.TextUtils;
@@ -455,6 +456,7 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
Uri.fromParts("package", mPackages[0], null));
intent.putExtra(Intent.EXTRA_PACKAGES, mPackages);
intent.putExtra(Intent.EXTRA_UID, mUid);
intent.putExtra(Intent.EXTRA_USER_HANDLE, mUid);
getActivity().sendOrderedBroadcast(intent, null, mCheckKillProcessesReceiver, null,
Activity.RESULT_CANCELED, null, null);
}

View File

@@ -767,15 +767,23 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
final int userId = mUserSippers.keyAt(i);
final List<BatterySipper> sippers = mUserSippers.valueAt(i);
UserInfo info = mUm.getUserInfo(userId);
Drawable icon = UserUtils.getUserIcon(mUm, info, getResources());
String name = info != null ? info.name : null;
if (name == null) {
name = Integer.toString(info.id);
Drawable icon;
String name;
if (info != null) {
icon = UserUtils.getUserIcon(mUm, info, getResources());
name = info != null ? info.name : null;
if (name == null) {
name = Integer.toString(info.id);
}
name = getActivity().getResources().getString(
R.string.running_process_item_user_label, name);
} else {
icon = null;
name = getActivity().getResources().getString(
R.string.running_process_item_removed_user_label);
}
double power = mUserPower.get(userId);
String label = getActivity().getResources().getString(
R.string.running_process_item_user_label, name);
BatterySipper bs = addEntry(label, DrainType.USER, 0, 0, power);
BatterySipper bs = addEntry(name, DrainType.USER, 0, 0, power);
bs.icon = icon;
aggregateSippers(bs, sippers, "User");
}