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

Commit 3a66cf3e authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Avoid data usage notifications in airplane mode.

Only for mobile networks.

Bug: 5995839
Change-Id: I6a6dba8cfe98c8e72861f90665c3e41da6d9a474
parent 127d4dea
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -524,6 +524,11 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            case MATCH_MOBILE_3G_LOWER:
            case MATCH_MOBILE_4G:
            case MATCH_MOBILE_ALL:
                // mobile templates aren't relevant in airplane mode
                if (isAirplaneModeOn(mContext)) {
                    return false;
                }

                // mobile templates are relevant when subscriberid is active
                return Objects.equal(getActiveSubscriberId(), template.getSubscriberId());
        }
@@ -1723,6 +1728,11 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        mHandler.getLooper().getQueue().addIdleHandler(handler);
    }

    public static boolean isAirplaneModeOn(Context context) {
        return Settings.System.getInt(
                context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
    }

    private static void collectKeys(SparseIntArray source, SparseBooleanArray target) {
        final int size = source.size();
        for (int i = 0; i < size; i++) {