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

Commit 7a5dccc9 authored by Amith Yamasani's avatar Amith Yamasani Committed by android-build-merger
Browse files

Merge "Update interface quota on the handler" into nyc-dev am: db0f3a70

am: 951dcd68

* commit '951dcd68':
  Update interface quota on the handler

Change-Id: I5a73bbbf0927ca25fc9509d538b727e393c65d38
parents 55639459 951dcd68
Loading
Loading
Loading
Loading
+23 −5
Original line number Original line Diff line number Diff line
@@ -260,6 +260,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
    private static final int MSG_ADVISE_PERSIST_THRESHOLD = 7;
    private static final int MSG_ADVISE_PERSIST_THRESHOLD = 7;
    private static final int MSG_SCREEN_ON_CHANGED = 8;
    private static final int MSG_SCREEN_ON_CHANGED = 8;
    private static final int MSG_RESTRICT_BACKGROUND_WHITELIST_CHANGED = 9;
    private static final int MSG_RESTRICT_BACKGROUND_WHITELIST_CHANGED = 9;
    private static final int MSG_UPDATE_INTERFACE_QUOTA = 10;
    private static final int MSG_REMOVE_INTERFACE_QUOTA = 11;


    private final Context mContext;
    private final Context mContext;
    private final IActivityManager mActivityManager;
    private final IActivityManager mActivityManager;
@@ -1275,8 +1277,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                }
                }


                for (String iface : ifaces) {
                for (String iface : ifaces) {
                    removeInterfaceQuota(iface);
                    // long quotaBytes split up into two ints to fit in message
                    setInterfaceQuota(iface, quotaBytes);
                    mHandler.obtainMessage(MSG_UPDATE_INTERFACE_QUOTA,
                            (int) (quotaBytes >> 32), (int) (quotaBytes & 0xFFFFFFFF), iface)
                            .sendToTarget();
                    newMeteredIfaces.add(iface);
                    newMeteredIfaces.add(iface);
                }
                }
            }
            }
@@ -1292,8 +1296,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {


        for (int i = connIfaces.size()-1; i >= 0; i--) {
        for (int i = connIfaces.size()-1; i >= 0; i--) {
            String iface = connIfaces.valueAt(i);
            String iface = connIfaces.valueAt(i);
            removeInterfaceQuota(iface);
            // long quotaBytes split up into two ints to fit in message
            setInterfaceQuota(iface, Long.MAX_VALUE);
            mHandler.obtainMessage(MSG_UPDATE_INTERFACE_QUOTA,
                    (int) (Long.MAX_VALUE >> 32), (int) (Long.MAX_VALUE & 0xFFFFFFFF), iface)
                    .sendToTarget();
            newMeteredIfaces.add(iface);
            newMeteredIfaces.add(iface);
        }
        }


@@ -1303,7 +1309,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        for (int i = mMeteredIfaces.size() - 1; i >= 0; i--) {
        for (int i = mMeteredIfaces.size() - 1; i >= 0; i--) {
            final String iface = mMeteredIfaces.valueAt(i);
            final String iface = mMeteredIfaces.valueAt(i);
            if (!newMeteredIfaces.contains(iface)) {
            if (!newMeteredIfaces.contains(iface)) {
                removeInterfaceQuota(iface);
                mHandler.obtainMessage(MSG_REMOVE_INTERFACE_QUOTA, iface)
                        .sendToTarget();
            }
            }
        }
        }
        mMeteredIfaces = newMeteredIfaces;
        mMeteredIfaces = newMeteredIfaces;
@@ -2950,6 +2957,17 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                    updateScreenOn();
                    updateScreenOn();
                    return true;
                    return true;
                }
                }
                case MSG_UPDATE_INTERFACE_QUOTA: {
                    removeInterfaceQuota((String) msg.obj);
                    // int params need to be stitched back into a long
                    setInterfaceQuota((String) msg.obj,
                            ((long) msg.arg1 << 32) | (msg.arg2 & 0xFFFFFFFFL));
                    return true;
                }
                case MSG_REMOVE_INTERFACE_QUOTA: {
                    removeInterfaceQuota((String) msg.obj);
                    return true;
                }
                default: {
                default: {
                    return false;
                    return false;
                }
                }