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

Commit 4360ba47 authored by Ling Ma's avatar Ling Ma Committed by Automerger Merge Worker
Browse files

Merge "Clear TelephonyManagerMap onStop" into udc-dev am: 5a29015e am: e3a9b819 am: 52738813

parents b31c8507 52738813
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3718,6 +3718,10 @@
         magnification settings and adjust the default magnification capability.  -->
    <bool name="config_magnification_area">true</bool>

    <!-- The default value for always on magnification feature flag if the remote feature
         flag does not exist -->
    <bool name="config_magnification_always_on_enabled">true</bool>

    <!-- If true, the display will be shifted around in ambient mode. -->
    <bool name="config_enableBurnInProtection">false</bool>

+1 −0
Original line number Diff line number Diff line
@@ -4537,6 +4537,7 @@
  <java-symbol type="string" name="dismiss_action" />

  <java-symbol type="bool" name="config_magnification_area" />
  <java-symbol type="bool" name="config_magnification_always_on_enabled" />

  <java-symbol type="bool" name="config_trackerAppNeedsPermissions"/>
  <!-- FullScreenMagnification thumbnail -->
+9 −4
Original line number Diff line number Diff line
@@ -153,14 +153,16 @@ public class InternetDialogController implements AccessPointController.AccessPoi
    @VisibleForTesting
    /** Should be accessible only to the main thread. */
    final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>();
    @VisibleForTesting
    /** Should be accessible only to the main thread. */
    final Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>();
    @VisibleForTesting
    /** Should be accessible only to the main thread. */
    final Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>();

    private WifiManager mWifiManager;
    private Context mContext;
    private SubscriptionManager mSubscriptionManager;
    /** Should be accessible only to the main thread. */
    private Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>();
    /** Should be accessible only to the main thread. */
    private Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>();
    private TelephonyManager mTelephonyManager;
    private ConnectivityManager mConnectivityManager;
    private CarrierConfigTracker mCarrierConfigTracker;
@@ -320,6 +322,9 @@ public class InternetDialogController implements AccessPointController.AccessPoi
                Log.e(TAG, "Unexpected null telephony call back for Sub " + tm.getSubscriptionId());
            }
        }
        mSubIdTelephonyManagerMap.clear();
        mSubIdTelephonyCallbackMap.clear();
        mSubIdTelephonyDisplayInfoMap.clear();
        mSubscriptionManager.removeOnSubscriptionsChangedListener(
                mOnSubscriptionsChangedListener);
        mAccessPointController.removeAccessPointCallback(this);
+21 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.testing.AndroidTestingRunner;
@@ -961,6 +962,26 @@ public class InternetDialogControllerTest extends SysuiTestCase {
        assertThat(dds).contains(mContext.getString(R.string.carrier_network_change_mode));
    }

    @Test
    public void onStop_cleanUp() {
        doReturn(SUB_ID).when(mTelephonyManager).getSubscriptionId();
        assertThat(mInternetDialogController.mSubIdTelephonyManagerMap.get(SUB_ID)).isEqualTo(
                mTelephonyManager);
        assertThat(mInternetDialogController.mSubIdTelephonyCallbackMap.get(SUB_ID)).isNotNull();

        mInternetDialogController.onStop();

        verify(mTelephonyManager).unregisterTelephonyCallback(any(TelephonyCallback.class));
        assertThat(mInternetDialogController.mSubIdTelephonyDisplayInfoMap.isEmpty()).isTrue();
        assertThat(mInternetDialogController.mSubIdTelephonyManagerMap.isEmpty()).isTrue();
        assertThat(mInternetDialogController.mSubIdTelephonyCallbackMap.isEmpty()).isTrue();
        verify(mSubscriptionManager).removeOnSubscriptionsChangedListener(mInternetDialogController
                .mOnSubscriptionsChangedListener);
        verify(mAccessPointController).removeAccessPointCallback(mInternetDialogController);
        verify(mConnectivityManager).unregisterNetworkCallback(
                any(ConnectivityManager.NetworkCallback.class));
    }

    private String getResourcesString(String name) {
        return mContext.getResources().getString(getResourcesId(name));
    }
+11 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.accessibility.magnification;

import android.annotation.NonNull;
import android.content.Context;
import android.provider.DeviceConfig;

/**
@@ -29,6 +31,13 @@ public class AlwaysOnMagnificationFeatureFlag extends MagnificationFeatureFlagBa
    private static final String FEATURE_NAME_ENABLE_ALWAYS_ON_MAGNIFICATION =
            "AlwaysOnMagnifier__enable_always_on_magnifier";

    private @NonNull Context mContext;

    AlwaysOnMagnificationFeatureFlag(@NonNull Context context) {
        super();
        mContext = context;
    }

    @Override
    String getNamespace() {
        return NAMESPACE;
@@ -41,6 +50,7 @@ public class AlwaysOnMagnificationFeatureFlag extends MagnificationFeatureFlagBa

    @Override
    boolean getDefaultValue() {
        return false;
        return mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_magnification_always_on_enabled);
    }
}
Loading