Loading services/core/java/com/android/server/am/ActivityManagerService.java +3 −5 Original line number Diff line number Diff line Loading @@ -17633,7 +17633,6 @@ public class ActivityManagerService extends IActivityManager.Stub @GuardedBy("this") final void updateProcessForegroundLocked(ProcessRecord proc, boolean isForeground, int fgServiceTypes, boolean oomAdj) { if (isForeground != proc.hasForegroundServices() || proc.getForegroundServiceTypes() != fgServiceTypes) { proc.setHasForegroundServices(isForeground, fgServiceTypes); Loading Loading @@ -17666,12 +17665,11 @@ public class ActivityManagerService extends IActivityManager.Stub ProcessChangeItem item = enqueueProcessChangeItemLocked(proc.pid, proc.info.uid); item.changes = ProcessChangeItem.CHANGE_FOREGROUND_SERVICES; item.foregroundServiceTypes = fgServiceTypes; } if (oomAdj) { updateOomAdjLocked(proc, OomAdjuster.OOM_ADJ_REASON_UI_VISIBILITY); } } } // TODO(b/111541062): This method is only used for updating OOM adjustments. We need to update // the logic there and in mBatteryStatsService to make them aware of multiple resumed activities services/core/java/com/android/server/am/OomAdjuster.java +10 −2 Original line number Diff line number Diff line Loading @@ -1520,8 +1520,16 @@ public final class OomAdjuster { != 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE : TEMP_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; } else { capabilityFromFGS |= PROCESS_CAPABILITY_FOREGROUND_CAMERA | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; // Remove fgsType check and assign PROCESS_CAPABILITY_FOREGROUND_CAMERA // and MICROPHONE when finish debugging. capabilityFromFGS |= (fgsType & FOREGROUND_SERVICE_TYPE_CAMERA) != 0 ? PROCESS_CAPABILITY_FOREGROUND_CAMERA : TEMP_PROCESS_CAPABILITY_FOREGROUND_CAMERA; capabilityFromFGS |= (fgsType & FOREGROUND_SERVICE_TYPE_MICROPHONE) != 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE : TEMP_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; } } } Loading services/core/java/com/android/server/appop/AppOpsService.java +9 −5 Original line number Diff line number Diff line Loading @@ -670,15 +670,19 @@ public class AppOpsService extends IAppOpsService.Stub { } // TODO: remove this toast after feature development is done // If the procstate is foreground service and while-in-use permission is denied, show a // toast message to ask user to file a bugreport so we know how many apps are impacted by // the new background started foreground service while-in-use permission restriction. // For DEBUG_FGS_ALLOW_WHILE_IN_USE, if the procstate is foreground service and while-in-use // permission is denied, show a toast message and generate a WTF log so we know // how many apps are impacted by the new background started foreground service while-in-use // permission restriction. // For DEBUG_FGS_ENFORCE_TYPE, The process has a foreground service that does not have // camera/microphone foregroundServiceType in manifest file, and the process is asking // AppOps for camera/microphone ops, show a toast message and generate a WTF log. void maybeShowWhileInUseDebugToast(int op, int mode) { if (state != UID_STATE_FOREGROUND_SERVICE) { if (mode == DEBUG_FGS_ALLOW_WHILE_IN_USE && state != UID_STATE_FOREGROUND_SERVICE) { return; } final long now = System.currentTimeMillis(); if (lastTimeShowDebugToast == 0 || now - lastTimeShowDebugToast > 3600000) { if (lastTimeShowDebugToast == 0 || now - lastTimeShowDebugToast > 600000) { lastTimeShowDebugToast = now; mHandler.sendMessage(PooledLambda.obtainMessage( ActivityManagerInternal::showWhileInUseDebugToast, Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +3 −5 Original line number Diff line number Diff line Loading @@ -17633,7 +17633,6 @@ public class ActivityManagerService extends IActivityManager.Stub @GuardedBy("this") final void updateProcessForegroundLocked(ProcessRecord proc, boolean isForeground, int fgServiceTypes, boolean oomAdj) { if (isForeground != proc.hasForegroundServices() || proc.getForegroundServiceTypes() != fgServiceTypes) { proc.setHasForegroundServices(isForeground, fgServiceTypes); Loading Loading @@ -17666,12 +17665,11 @@ public class ActivityManagerService extends IActivityManager.Stub ProcessChangeItem item = enqueueProcessChangeItemLocked(proc.pid, proc.info.uid); item.changes = ProcessChangeItem.CHANGE_FOREGROUND_SERVICES; item.foregroundServiceTypes = fgServiceTypes; } if (oomAdj) { updateOomAdjLocked(proc, OomAdjuster.OOM_ADJ_REASON_UI_VISIBILITY); } } } // TODO(b/111541062): This method is only used for updating OOM adjustments. We need to update // the logic there and in mBatteryStatsService to make them aware of multiple resumed activities
services/core/java/com/android/server/am/OomAdjuster.java +10 −2 Original line number Diff line number Diff line Loading @@ -1520,8 +1520,16 @@ public final class OomAdjuster { != 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE : TEMP_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; } else { capabilityFromFGS |= PROCESS_CAPABILITY_FOREGROUND_CAMERA | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; // Remove fgsType check and assign PROCESS_CAPABILITY_FOREGROUND_CAMERA // and MICROPHONE when finish debugging. capabilityFromFGS |= (fgsType & FOREGROUND_SERVICE_TYPE_CAMERA) != 0 ? PROCESS_CAPABILITY_FOREGROUND_CAMERA : TEMP_PROCESS_CAPABILITY_FOREGROUND_CAMERA; capabilityFromFGS |= (fgsType & FOREGROUND_SERVICE_TYPE_MICROPHONE) != 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE : TEMP_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; } } } Loading
services/core/java/com/android/server/appop/AppOpsService.java +9 −5 Original line number Diff line number Diff line Loading @@ -670,15 +670,19 @@ public class AppOpsService extends IAppOpsService.Stub { } // TODO: remove this toast after feature development is done // If the procstate is foreground service and while-in-use permission is denied, show a // toast message to ask user to file a bugreport so we know how many apps are impacted by // the new background started foreground service while-in-use permission restriction. // For DEBUG_FGS_ALLOW_WHILE_IN_USE, if the procstate is foreground service and while-in-use // permission is denied, show a toast message and generate a WTF log so we know // how many apps are impacted by the new background started foreground service while-in-use // permission restriction. // For DEBUG_FGS_ENFORCE_TYPE, The process has a foreground service that does not have // camera/microphone foregroundServiceType in manifest file, and the process is asking // AppOps for camera/microphone ops, show a toast message and generate a WTF log. void maybeShowWhileInUseDebugToast(int op, int mode) { if (state != UID_STATE_FOREGROUND_SERVICE) { if (mode == DEBUG_FGS_ALLOW_WHILE_IN_USE && state != UID_STATE_FOREGROUND_SERVICE) { return; } final long now = System.currentTimeMillis(); if (lastTimeShowDebugToast == 0 || now - lastTimeShowDebugToast > 3600000) { if (lastTimeShowDebugToast == 0 || now - lastTimeShowDebugToast > 600000) { lastTimeShowDebugToast = now; mHandler.sendMessage(PooledLambda.obtainMessage( ActivityManagerInternal::showWhileInUseDebugToast, Loading