Merge changes I8d88c8fb,I35bf3768 into rvc-dev
* changes:
updateOomAdjLocked() need to be called regardless outer block.
Debug missing foregrounsServiceType does not need procstate to be foreground service.
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index a458498..4cfcd2b 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -17633,7 +17633,6 @@
@GuardedBy("this")
final void updateProcessForegroundLocked(ProcessRecord proc, boolean isForeground,
int fgServiceTypes, boolean oomAdj) {
-
if (isForeground != proc.hasForegroundServices()
|| proc.getForegroundServiceTypes() != fgServiceTypes) {
proc.setHasForegroundServices(isForeground, fgServiceTypes);
@@ -17666,10 +17665,9 @@
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);
- }
+ }
+ if (oomAdj) {
+ updateOomAdjLocked(proc, OomAdjuster.OOM_ADJ_REASON_UI_VISIBILITY);
}
}
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index 2b1534b..d4a0502 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -1520,8 +1520,16 @@
!= 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;
}
}
}
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 2e2241f..6613d5f 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -670,15 +670,19 @@
}
// 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,