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

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

Make policy data enabled flag static.

For devices with both CDMA and GSM stack, ConnectivityService only
connects with the GSM variant.  Making this flag static communicates
the policy state between all DCT.

Bug: 5586935
Change-Id: Iff0384027303470dd382d5173558d2d091ce4bf6
parent 6dee1a9d
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -225,8 +225,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {

    /** Set of currently active {@link Notification} tags. */
    private HashSet<String> mActiveNotifs = Sets.newHashSet();
    /** Current values from {@link #setPolicyDataEnable(int, boolean)}. */
    private SparseBooleanArray mActiveNetworkEnabled = new SparseBooleanArray();

    /** Foreground at both UID and PID granularity. */
    private SparseBooleanArray mUidForeground = new SparseBooleanArray();
@@ -1519,22 +1517,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
    }

    /**
     * Control {@link IConnectivityManager#setPolicyDataEnable(int, boolean)},
     * dispatching only when actually changed.
     * Control {@link IConnectivityManager#setPolicyDataEnable(int, boolean)}.
     */
    private void setPolicyDataEnable(int networkType, boolean enabled) {
        synchronized (mActiveNetworkEnabled) {
            final boolean prevEnabled = mActiveNetworkEnabled.get(networkType, true);
            if (prevEnabled == enabled) return;

        try {
            mConnManager.setPolicyDataEnable(networkType, enabled);
        } catch (RemoteException e) {
            // ignored; service lives in system_server
        }

            mActiveNetworkEnabled.put(networkType, enabled);
        }
    }

    private String getActiveSubscriberId() {
+6 −4
Original line number Diff line number Diff line
@@ -167,7 +167,9 @@ public abstract class DataConnectionTracker extends Handler {
    // independent of mInternalDataEnabled and requests for APN access
    // persisted
    protected boolean mUserDataEnabled = true;
    protected boolean mPolicyDataEnabled = true;

    // TODO: move away from static state once 5587429 is fixed.
    protected static boolean sPolicyDataEnabled = true;

    private boolean[] dataEnabled = new boolean[APN_NUM_TYPES];

@@ -766,7 +768,7 @@ public abstract class DataConnectionTracker extends Handler {
    public boolean getAnyDataEnabled() {
        final boolean result;
        synchronized (mDataEnabledLock) {
            result = (mInternalDataEnabled && mUserDataEnabled && mPolicyDataEnabled
            result = (mInternalDataEnabled && mUserDataEnabled && sPolicyDataEnabled
                    && (enabledCount != 0));
        }
        if (!result && DBG) log("getAnyDataEnabled " + result);
@@ -1132,8 +1134,8 @@ public abstract class DataConnectionTracker extends Handler {
    protected void onSetPolicyDataEnabled(boolean enabled) {
        synchronized (mDataEnabledLock) {
            final boolean prevEnabled = getAnyDataEnabled();
            if (mPolicyDataEnabled != enabled) {
                mPolicyDataEnabled = enabled;
            if (sPolicyDataEnabled != enabled) {
                sPolicyDataEnabled = enabled;
                if (prevEnabled != getAnyDataEnabled()) {
                    if (!prevEnabled) {
                        resetAllRetryCounts();
+1 −1
Original line number Diff line number Diff line
@@ -549,7 +549,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
    @Override
    public boolean getAnyDataEnabled() {
        synchronized (mDataEnabledLock) {
            if (!(mInternalDataEnabled && mUserDataEnabled && mPolicyDataEnabled)) return false;
            if (!(mInternalDataEnabled && mUserDataEnabled && sPolicyDataEnabled)) return false;
            for (ApnContext apnContext : mApnContexts.values()) {
                // Make sure we dont have a context that going down
                // and is explicitly disabled.