Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1439b570 authored by Hui Yu's avatar Hui Yu Committed by Android (Google) Code Review
Browse files

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.
parents 243f8b00 d652c3a9
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -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);
@@ -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
+10 −2
Original line number Diff line number Diff line
@@ -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;
                    }
                }
            }
+9 −5
Original line number Diff line number Diff line
@@ -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,