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

Commit 7881ffd0 authored by Robert Horvath's avatar Robert Horvath Committed by Gerrit Code Review
Browse files

Merge "Add Low Power Standby support to NetworkPolicyManagerService"

parents 4e7f5518 56317f3c
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -176,6 +176,9 @@ public class NetworkPolicyManager {
    public static final int FOREGROUND_THRESHOLD_STATE =
            ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE;

    /** @hide */
    public static final int TOP_THRESHOLD_STATE = ActivityManager.PROCESS_STATE_BOUND_TOP;

    /**
     * {@link Intent} extra that indicates which {@link NetworkTemplate} rule it
     * applies to.
@@ -246,6 +249,20 @@ public class NetworkPolicyManager {
     * @hide
     */
    public static final int ALLOWED_REASON_RESTRICTED_MODE_PERMISSIONS = 1 << 4;
    /**
     * Flag to indicate that app is exempt from certain network restrictions because of it being
     * in the bound top or top procstate.
     *
     * @hide
     */
    public static final int ALLOWED_REASON_TOP = 1 << 5;
    /**
     * Flag to indicate that app is exempt from low power standby restrictions because of it being
     * allowlisted.
     *
     * @hide
     */
    public static final int ALLOWED_REASON_LOW_POWER_STANDBY_ALLOWLIST = 1 << 6;
    /**
     * Flag to indicate that app is exempt from certain metered network restrictions because user
     * explicitly exempted it.
@@ -770,6 +787,14 @@ public class NetworkPolicyManager {
                || (capability & ActivityManager.PROCESS_CAPABILITY_NETWORK) != 0;
    }

    /** @hide */
    public static boolean isProcStateAllowedWhileInLowPowerStandby(@Nullable UidState uidState) {
        if (uidState == null) {
            return false;
        }
        return uidState.procState <= TOP_THRESHOLD_STATE;
    }

    /**
     * Returns true if {@param procState} is considered foreground and as such will be allowed
     * to access network when the device is in data saver mode. Otherwise, false.
+6 −0
Original line number Diff line number Diff line
@@ -91,4 +91,10 @@ public abstract class NetworkPolicyManagerInternal {
     */
    public abstract void setMeteredRestrictedPackagesAsync(
            Set<String> packageNames, int userId);

    /** Informs that Low Power Standby has become active */
    public abstract void setLowPowerStandbyActive(boolean active);

    /** Informs that the Low Power Standby allowlist has changed */
    public abstract void setLowPowerStandbyAllowlist(int[] uids);
}
+196 −7

File changed.

Preview size limit exceeded, changes collapsed.

+93 −44

File changed.

Preview size limit exceeded, changes collapsed.