Fix power usage detail page is launched in wrong user
Two issues: 1. UID of settings app == system UID. But isSystemUid failed to recognize Settings in secondary user is also a system uid. 2. For USER drain type, we should launch the detail page in current user. Fix: 64506728 Test: make ROBOTEST_FILTER=AdvancedPowerUsageDetailTest -j40 RunSettingsRoboTests Test: Switch to seconday user. Go to Settings->Battery, tap owner user battery entry, observe that detail page is shown. Test: Stay long enough in Settings app, make sure no either Settings nor Android Framework battery entry. Change-Id: I8d66ad55f18fcb3d9567b3bf753f737f5b98c609
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.LoaderManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
@@ -152,7 +154,14 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
|
||||
R.string.battery_details_title, null,
|
||||
new UserHandle(UserHandle.getUserId(sipper.getUid())));
|
||||
new UserHandle(getUserIdToLaunchAdvancePowerUsageDetail(sipper)));
|
||||
}
|
||||
|
||||
private static @UserIdInt int getUserIdToLaunchAdvancePowerUsageDetail(BatterySipper bs) {
|
||||
if (bs.drainType == BatterySipper.DrainType.USER) {
|
||||
return ActivityManager.getCurrentUser();
|
||||
}
|
||||
return UserHandle.getUserId(bs.getUid());
|
||||
}
|
||||
|
||||
public static void startBatteryDetailPage(SettingsActivity caller, PreferenceFragment fragment,
|
||||
|
@@ -428,7 +428,8 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
}
|
||||
|
||||
private static boolean isSystemUid(int uid) {
|
||||
return uid >= Process.SYSTEM_UID && uid < Process.FIRST_APPLICATION_UID;
|
||||
final int appUid = UserHandle.getAppId(uid);
|
||||
return appUid >= Process.SYSTEM_UID && appUid < Process.FIRST_APPLICATION_UID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user