Merge "Ignore broadcast intent from additional profile." into main
This commit is contained in:
@@ -63,8 +63,8 @@ public final class BatteryUsageBroadcastReceiver extends BroadcastReceiver {
|
||||
}
|
||||
final String action = intent.getAction();
|
||||
Log.d(TAG, "onReceive:" + action);
|
||||
if (com.android.settingslib.fuelgauge.BatteryUtils.isWorkProfile(context)) {
|
||||
Log.w(TAG, "do nothing for work profile action=" + action);
|
||||
if (com.android.settingslib.fuelgauge.BatteryUtils.isAdditionalProfile(context)) {
|
||||
Log.w(TAG, "do nothing for an additional profile action=" + action);
|
||||
return;
|
||||
}
|
||||
DatabaseUtils.recordDateTime(context, action);
|
||||
|
||||
@@ -110,8 +110,8 @@ public class BatteryUsageContentProvider extends ContentProvider {
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
if (BatteryUtils.isWorkProfile(getContext())) {
|
||||
Log.w(TAG, "do not create provider for work profile");
|
||||
if (BatteryUtils.isAdditionalProfile(getContext())) {
|
||||
Log.w(TAG, "do not create provider for an additional profile");
|
||||
return false;
|
||||
}
|
||||
mClock = Clock.systemUTC();
|
||||
|
||||
@@ -54,8 +54,8 @@ public final class BootBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent == null ? "" : intent.getAction();
|
||||
if (BatteryUtils.isWorkProfile(context)) {
|
||||
Log.w(TAG, "do not start job for work profile action=" + action);
|
||||
if (BatteryUtils.isAdditionalProfile(context)) {
|
||||
Log.w(TAG, "do not start job for an additional profile action=" + action);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ public final class DatabaseUtils {
|
||||
|
||||
/** Clear memory threshold for device booting phase. */
|
||||
private static final long CLEAR_MEMORY_THRESHOLD_MS = Duration.ofMinutes(5).toMillis();
|
||||
|
||||
private static final long CLEAR_MEMORY_DELAYED_MS = Duration.ofSeconds(2).toMillis();
|
||||
private static final long INVALID_TIMESTAMP = 0L;
|
||||
|
||||
@@ -527,9 +528,11 @@ public final class DatabaseUtils {
|
||||
return startCalendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
/** Returns the context with profile parent identity when current user is work profile. */
|
||||
/**
|
||||
* Returns the context with profile parent identity when current user is an additional profile.
|
||||
*/
|
||||
public static Context getParentContext(Context context) {
|
||||
if (com.android.settingslib.fuelgauge.BatteryUtils.isWorkProfile(context)) {
|
||||
if (com.android.settingslib.fuelgauge.BatteryUtils.isAdditionalProfile(context)) {
|
||||
try {
|
||||
return context.createPackageContextAsUser(
|
||||
/* packageName= */ context.getPackageName(),
|
||||
|
||||
@@ -50,10 +50,10 @@ public final class PeriodicJobReceiver extends BroadcastReceiver {
|
||||
Log.w(TAG, "receive unexpected action=" + action);
|
||||
return;
|
||||
}
|
||||
if (BatteryUtils.isWorkProfile(context)) {
|
||||
if (BatteryUtils.isAdditionalProfile(context)) {
|
||||
BatteryUsageLogUtils.writeLog(
|
||||
context, Action.SCHEDULE_JOB, "do not refresh job for work profile");
|
||||
Log.w(TAG, "do not refresh job for work profile action=" + action);
|
||||
context, Action.SCHEDULE_JOB, "do not refresh job for an additional profile");
|
||||
Log.w(TAG, "do not refresh job for an additional profile action=" + action);
|
||||
return;
|
||||
}
|
||||
BatteryUsageLogUtils.writeLog(context, Action.EXECUTE_JOB, "");
|
||||
|
||||
@@ -49,8 +49,8 @@ public final class BugReportContentProvider extends ContentProvider {
|
||||
Log.w(TAG, "failed to dump BatteryUsage state: null application context");
|
||||
return;
|
||||
}
|
||||
if (BatteryUtils.isWorkProfile(context)) {
|
||||
Log.w(TAG, "ignore battery usage states dump in the work profile");
|
||||
if (BatteryUtils.isAdditionalProfile(context)) {
|
||||
Log.w(TAG, "ignore battery usage states dump in the additional profile");
|
||||
return;
|
||||
}
|
||||
writer.println("dump BatteryUsage and AppUsage states:");
|
||||
|
||||
Reference in New Issue
Block a user