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

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

Merge "FGS BG start restriction enforcement mode."

parents 40127f04 b9a91a63
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -1994,12 +1994,11 @@ public final class OomAdjuster {
        if (app.hasForegroundServices()) {
        if (app.hasForegroundServices()) {
            capability |= capabilityFromFGS;
            capability |= capabilityFromFGS;
        } else if (!ActivityManager.isProcStateBackground(procState)) {
        } else if (!ActivityManager.isProcStateBackground(procState)) {
            // procState higher than PROCESS_STATE_TRANSIENT_BACKGROUND implicitly has
            // procState higher than PROCESS_STATE_BOUND_FOREGROUND_SERVICE implicitly has
            // camera/microphone capability
            // camera/microphone capability
            if (procState == PROCESS_STATE_FOREGROUND_SERVICE && procStateFromFGSClient) {
            if (procState == PROCESS_STATE_FOREGROUND_SERVICE && procStateFromFGSClient) {
                // if the FGS state is passed down from client, do not grant implicit capabilities.
                // if the FGS state is passed down from client, do not grant implicit capabilities.
            } else {
            } else {
                //TODO: remove this line when enforcing the feature.
                capability |= PROCESS_CAPABILITY_ALL_IMPLICIT;
                capability |= PROCESS_CAPABILITY_ALL_IMPLICIT;
            }
            }
        }
        }
+5 −10
Original line number Original line Diff line number Diff line
@@ -536,9 +536,8 @@ public class AppOpsService extends IAppOpsService.Stub {
                                // The FGS has the location capability, but due to FGS BG start
                                // The FGS has the location capability, but due to FGS BG start
                                // restriction it lost the capability, use temp location capability
                                // restriction it lost the capability, use temp location capability
                                // to mark this case.
                                // to mark this case.
                                // TODO change to MODE_IGNORED when enforcing the feature.
                                maybeShowWhileInUseDebugToast(op, mode);
                                maybeShowWhileInUseDebugToast(op, mode);
                                return AppOpsManager.MODE_ALLOWED;
                                return AppOpsManager.MODE_IGNORED;
                            } else {
                            } else {
                                return AppOpsManager.MODE_IGNORED;
                                return AppOpsManager.MODE_IGNORED;
                            }
                            }
@@ -546,17 +545,15 @@ public class AppOpsService extends IAppOpsService.Stub {
                            if ((capability & PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
                            if ((capability & PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
                                return AppOpsManager.MODE_ALLOWED;
                                return AppOpsManager.MODE_ALLOWED;
                            } else {
                            } else {
                                //TODO change to MODE_IGNORED when enforcing the feature.
                                maybeShowWhileInUseDebugToast(op, mode);
                                maybeShowWhileInUseDebugToast(op, mode);
                                return AppOpsManager.MODE_ALLOWED;
                                return AppOpsManager.MODE_IGNORED;
                            }
                            }
                        case OP_RECORD_AUDIO:
                        case OP_RECORD_AUDIO:
                            if ((capability & PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
                            if ((capability & PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
                                return AppOpsManager.MODE_ALLOWED;
                                return AppOpsManager.MODE_ALLOWED;
                            } else {
                            } else {
                                //TODO change to MODE_IGNORED when enforcing the feature.
                                maybeShowWhileInUseDebugToast(op, mode);
                                maybeShowWhileInUseDebugToast(op, mode);
                                return AppOpsManager.MODE_ALLOWED;
                                return AppOpsManager.MODE_IGNORED;
                            }
                            }
                        default:
                        default:
                            return AppOpsManager.MODE_ALLOWED;
                            return AppOpsManager.MODE_ALLOWED;
@@ -571,17 +568,15 @@ public class AppOpsService extends IAppOpsService.Stub {
                        if ((capability & PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
                        if ((capability & PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
                            return AppOpsManager.MODE_ALLOWED;
                            return AppOpsManager.MODE_ALLOWED;
                        } else {
                        } else {
                            //TODO change to MODE_IGNORED when enforcing the feature.
                            maybeShowWhileInUseDebugToast(op, mode);
                            maybeShowWhileInUseDebugToast(op, mode);
                            return AppOpsManager.MODE_ALLOWED;
                            return AppOpsManager.MODE_IGNORED;
                        }
                        }
                    case OP_RECORD_AUDIO:
                    case OP_RECORD_AUDIO:
                        if ((capability & PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
                        if ((capability & PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
                            return AppOpsManager.MODE_ALLOWED;
                            return AppOpsManager.MODE_ALLOWED;
                        } else {
                        } else {
                            //TODO change to MODE_IGNORED when enforcing the feature.
                            maybeShowWhileInUseDebugToast(op, mode);
                            maybeShowWhileInUseDebugToast(op, mode);
                            return AppOpsManager.MODE_ALLOWED;
                            return AppOpsManager.MODE_IGNORED;
                        }
                        }
                    default:
                    default:
                        return MODE_ALLOWED;
                        return MODE_ALLOWED;