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

Commit d9bf6707 authored by Bonian Chen's avatar Bonian Chen
Browse files

Revert "[Settings] Code Refactor - ActiveSubscip..."

There seems to be an issue on system when a modification on file name get referenced by multiple submit(s).
(ag/15106410 and ag/15102785).

It seems to me that, build system got build breakage immediately instead of merging all of the files (even within same package).

Reason for revert: Try to submit all of the modifications within single submit as a workaround.

Bug: 192204057
Test: build pass
Change-Id: Ie497088a58c6ac564fde193fad2c0b67a965933c
parent bc51750b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
 * A listener for active subscription change
 */
public abstract class ActiveSubsciptionsListener
public abstract class ActiveSubscriptionsListener
        extends SubscriptionManager.OnSubscriptionsChangedListener
        implements AutoCloseable {

@@ -73,7 +73,7 @@ public abstract class ActiveSubsciptionsListener
     * @param looper {@code Looper} of this listener
     * @param context {@code Context} of this listener
     */
    public ActiveSubsciptionsListener(Looper looper, Context context) {
    public ActiveSubscriptionsListener(Looper looper, Context context) {
        this(looper, context, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    }

@@ -84,7 +84,7 @@ public abstract class ActiveSubsciptionsListener
     * @param context {@code Context} of this listener
     * @param subscriptionId for subscription on this listener
     */
    public ActiveSubsciptionsListener(Looper looper, Context context, int subscriptionId) {
    public ActiveSubscriptionsListener(Looper looper, Context context, int subscriptionId) {
        super(looper);
        mLooper = looper;
        mContext = context;
+2 −2
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class ProxySubscriptionManager implements LifecycleObserver {
        mActiveSubscriptionsListeners =
                new ArrayList<OnActiveSubscriptionChangedListener>();

        mSubscriptionMonitor = new ActiveSubsciptionsListener(looper, context) {
        mSubscriptionMonitor = new ActiveSubscriptionsListener(looper, context) {
            public void onChanged() {
                notifyAllListeners();
            }
@@ -94,7 +94,7 @@ public class ProxySubscriptionManager implements LifecycleObserver {
    }

    private Lifecycle mLifecycle;
    private ActiveSubsciptionsListener mSubscriptionMonitor;
    private ActiveSubscriptionsListener mSubscriptionMonitor;
    private GlobalSettingsChangeListener mAirplaneModeMonitor;

    private List<OnActiveSubscriptionChangedListener> mActiveSubscriptionsListeners;
+11 −11
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.datausage.BillingCyclePreferenceController;
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
import com.android.settings.network.ActiveSubsciptionsListener;
import com.android.settings.network.ActiveSubscriptionsListener;
import com.android.settings.network.CarrierWifiTogglePreferenceController;
import com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController;
import com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController;
@@ -74,9 +74,9 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
    private UserManager mUserManager;
    private String mClickedPrefKey;

    private ActiveSubsciptionsListener mActiveSubsciptionsListener;
    private ActiveSubscriptionsListener mActiveSubscriptionsListener;
    private boolean mDropFirstSubscriptionChangeNotify;
    private int mActiveSubsciptionsListenerCount;
    private int mActiveSubscriptionsListenerCount;

    public MobileNetworkSettings() {
        super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
@@ -218,8 +218,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
        super.onResume();
        // TODO: remove log after fixing b/182326102
        Log.d(LOG_TAG, "onResume() subId=" + mSubId);
        if (mActiveSubsciptionsListener == null) {
            mActiveSubsciptionsListener = new ActiveSubsciptionsListener(
        if (mActiveSubscriptionsListener == null) {
            mActiveSubscriptionsListener = new ActiveSubscriptionsListener(
                    getContext().getMainLooper(), getContext(), mSubId) {
                public void onChanged() {
                    onSubscriptionDetailChanged();
@@ -227,7 +227,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
            };
            mDropFirstSubscriptionChangeNotify = true;
        }
        mActiveSubsciptionsListener.start();
        mActiveSubscriptionsListener.start();
    }

    private void onSubscriptionDetailChanged() {
@@ -236,21 +236,21 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
            Log.d(LOG_TAG, "Callback during onResume()");
            return;
        }
        mActiveSubsciptionsListenerCount++;
        if (mActiveSubsciptionsListenerCount != 1) {
        mActiveSubscriptionsListenerCount++;
        if (mActiveSubscriptionsListenerCount != 1) {
            return;
        }

        ThreadUtils.postOnMainThread(() -> {
            mActiveSubsciptionsListenerCount = 0;
            mActiveSubscriptionsListenerCount = 0;
            redrawPreferenceControllers();
        });
    }

    @Override
    public void onDestroy() {
        if (mActiveSubsciptionsListener != null) {
            mActiveSubsciptionsListener.stop();
        if (mActiveSubscriptionsListener != null) {
            mActiveSubscriptionsListener.stop();
        }
        super.onDestroy();
    }
+5 −5
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import java.util.ArrayList;
import java.util.List;

@RunWith(AndroidJUnit4.class)
public class ActiveSubsciptionsListenerTest {
public class ActiveSubscriptionsListenerTest {
    private static final int SUB_ID1 = 3;
    private static final int SUB_ID2 = 7;

@@ -68,7 +68,7 @@ public class ActiveSubsciptionsListenerTest {
    private SubscriptionManager mSubscriptionManager;
    private List<SubscriptionInfo> mActiveSubscriptions;

    private ActiveSubsciptionsListenerImpl mListener;
    private ActiveSubscriptionsListenerImpl mListener;
    private BroadcastReceiver mReceiver;

    @Before
@@ -83,7 +83,7 @@ public class ActiveSubsciptionsListenerTest {
        addMockSubscription(SUB_ID2);
        doReturn(mActiveSubscriptions).when(mSubscriptionManager).getActiveSubscriptionInfoList();

        mListener = spy(new ActiveSubsciptionsListenerImpl(Looper.getMainLooper(), mContext));
        mListener = spy(new ActiveSubscriptionsListenerImpl(Looper.getMainLooper(), mContext));
        doReturn(mSubscriptionManager).when(mListener).getSubscriptionManager();
        mReceiver = mListener.getSubscriptionChangeReceiver();
    }
@@ -99,8 +99,8 @@ public class ActiveSubsciptionsListenerTest {
        mListener.close();
    }

    public class ActiveSubsciptionsListenerImpl extends ActiveSubsciptionsListener {
        public ActiveSubsciptionsListenerImpl(Looper looper, Context context) {
    public class ActiveSubscriptionsListenerImpl extends ActiveSubscriptionsListener {
        public ActiveSubscriptionsListenerImpl(Looper looper, Context context) {
            super(looper, context);
        }