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

Commit 272c2191 authored by Tom Hsu's avatar Tom Hsu Committed by Android (Google) Code Review
Browse files

Merge "[Settings] Refractor ApnSettings code to independent package folder."

parents 3dd26e0e 2fd7c9ff
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -422,7 +422,7 @@
            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                android:value="true" />
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.network.ApnSettings" />
                       android:value="com.android.settings.network.apn.ApnSettings" />
        </activity>

        <!-- Keep compatibility with old shortcuts. -->
@@ -2003,7 +2003,7 @@
                <data android:mimeType="vnd.android.cursor.dir/telephony-carrier" />
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.network.ApnEditor" />
                       android:value="com.android.settings.network.apn.ApnEditor" />
        </activity>

        <activity
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import androidx.appcompat.app.AlertDialog;

import com.android.settings.core.InstrumentedFragment;
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settings.network.ApnSettings;
import com.android.settings.network.apn.ApnSettings;
import com.android.settingslib.RestrictedLockUtilsInternal;

/**
+2 −2
Original line number Diff line number Diff line
@@ -108,11 +108,11 @@ import com.android.settings.language.LanguageAndInputSettings;
import com.android.settings.localepicker.LocaleListEditor;
import com.android.settings.location.LocationSettings;
import com.android.settings.location.ScanningSettings;
import com.android.settings.network.ApnEditor;
import com.android.settings.network.ApnSettings;
import com.android.settings.network.MobileNetworkListFragment;
import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.network.NetworkProviderSettings;
import com.android.settings.network.apn.ApnEditor;
import com.android.settings.network.apn.ApnSettings;
import com.android.settings.nfc.AndroidBeam;
import com.android.settings.nfc.PaymentSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
+24 −15
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.settings.network;
package com.android.settings.network.apn;

import android.app.Dialog;
import android.app.settings.SettingsEnums;
@@ -53,6 +53,7 @@ import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.network.ProxySubscriptionManager;
import com.android.settingslib.utils.ThreadUtils;

import java.util.Arrays;
@@ -61,20 +62,21 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;

/** Use to edit apn settings. */
public class ApnEditor extends SettingsPreferenceFragment
        implements OnPreferenceChangeListener, OnKeyListener {

    private final static String TAG = ApnEditor.class.getSimpleName();
    private final static boolean VDBG = false;   // STOPSHIP if true
    private static final String TAG = ApnEditor.class.getSimpleName();
    private static final boolean VDBG = false;   // STOPSHIP if true

    private final static String KEY_AUTH_TYPE = "auth_type";
    private static final String KEY_AUTH_TYPE = "auth_type";
    private static final String KEY_APN_TYPE = "apn_type";
    private final static String KEY_PROTOCOL = "apn_protocol";
    private final static String KEY_ROAMING_PROTOCOL = "apn_roaming_protocol";
    private final static String KEY_CARRIER_ENABLED = "carrier_enabled";
    private final static String KEY_BEARER_MULTI = "bearer_multi";
    private final static String KEY_MVNO_TYPE = "mvno_type";
    private final static String KEY_PASSWORD = "apn_password";
    private static final String KEY_PROTOCOL = "apn_protocol";
    private static final String KEY_ROAMING_PROTOCOL = "apn_roaming_protocol";
    private static final String KEY_CARRIER_ENABLED = "carrier_enabled";
    private static final String KEY_BEARER_MULTI = "bearer_multi";
    private static final String KEY_MVNO_TYPE = "mvno_type";
    private static final String KEY_PASSWORD = "apn_password";

    private static final int MENU_DELETE = Menu.FIRST;
    private static final int MENU_SAVE = Menu.FIRST + 1;
@@ -583,7 +585,7 @@ public class ApnEditor extends SettingsPreferenceFragment
                }
            }

            if (mBearerInitialVal != 0 && bearers.contains("" + mBearerInitialVal) == false) {
            if (mBearerInitialVal != 0 && !bearers.contains("" + mBearerInitialVal)) {
                // add mBearerInitialVal to bearers
                bearers.add("" + mBearerInitialVal);
            }
@@ -699,7 +701,7 @@ public class ApnEditor extends SettingsPreferenceFragment
                            && Arrays.asList(mReadOnlyApnFields)
                            .contains(Telephony.Carriers.MVNO_MATCH_DATA));
            mMvnoMatchData.setEnabled(!mvnoMatchDataUneditable && mvnoIndex != 0);
            if (newValue != null && newValue.equals(oldValue) == false) {
            if (newValue != null && !newValue.equals(oldValue)) {
                if (values[mvnoIndex].equals("SPN")) {
                    TelephonyManager telephonyManager = (TelephonyManager)
                            getContext().getSystemService(TelephonyManager.class);
@@ -739,7 +741,9 @@ public class ApnEditor extends SettingsPreferenceFragment
            }
        }
    }

    /**
     * Callback when preference status changed.
     */
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        String key = preference.getKey();
        if (KEY_AUTH_TYPE.equals(key)) {
@@ -1342,8 +1346,13 @@ public class ApnEditor extends SettingsPreferenceFragment
        }
    }

    /**
     * Dialog of error message.
     */
    public static class ErrorDialog extends InstrumentedDialogFragment {

        /**
         * Show error dialog.
         */
        public static void showError(ApnEditor editor) {
            final ErrorDialog dialog = new ErrorDialog();
            dialog.setTargetFragment(editor, 0);
+28 −16
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.settings.network;
package com.android.settings.network.apn;

import android.content.ContentUris;
import android.content.Context;
@@ -40,7 +40,7 @@ import com.android.settings.R;
 */
public class ApnPreference extends Preference implements CompoundButton.OnCheckedChangeListener,
        View.OnClickListener {
    final static String TAG = "ApnPreference";
    private static final  String TAG = "ApnPreference";

    private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;

@@ -65,8 +65,8 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
        this(context, null);
    }

    private static String mSelectedKey = null;
    private static CompoundButton mCurrentChecked = null;
    private static String sSelectedKey = null;
    private static CompoundButton sCurrentChecked = null;
    private boolean mProtectFromCheckedChange = false;
    private boolean mSelectable = true;
    private boolean mHideDetails = false;
@@ -84,10 +84,10 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
            if (mSelectable) {
                rb.setOnCheckedChangeListener(this);

                final boolean isChecked = getKey().equals(mSelectedKey);
                final boolean isChecked = getKey().equals(sSelectedKey);
                if (isChecked) {
                    mCurrentChecked = rb;
                    mSelectedKey = getKey();
                    sCurrentChecked = rb;
                    sSelectedKey = getKey();
                }

                mProtectFromCheckedChange = true;
@@ -100,14 +100,23 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
        }
    }

    /**
     * Return the preference is checked or not.
     */
    public boolean isChecked() {
        return getKey().equals(mSelectedKey);
        return getKey().equals(sSelectedKey);
    }

    /**
     * Set preference checked.
     */
    public void setChecked() {
        mSelectedKey = getKey();
        sSelectedKey = getKey();
    }

    /**
     * Change the preference status.
     */
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        Log.i(TAG, "ID: " + getKey() + " :" + isChecked);
        if (mProtectFromCheckedChange) {
@@ -115,15 +124,15 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
        }

        if (isChecked) {
            if (mCurrentChecked != null) {
                mCurrentChecked.setChecked(false);
            if (sCurrentChecked != null) {
                sCurrentChecked.setChecked(false);
            }
            mCurrentChecked = buttonView;
            mSelectedKey = getKey();
            callChangeListener(mSelectedKey);
            sCurrentChecked = buttonView;
            sSelectedKey = getKey();
            callChangeListener(sSelectedKey);
        } else {
            mCurrentChecked = null;
            mSelectedKey = null;
            sCurrentChecked = null;
            sSelectedKey = null;
        }
    }

@@ -161,6 +170,9 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
        mSubId = subId;
    }

    /**
     * Hide details
     */
    public void setHideDetails() {
        mHideDetails = true;
    }
Loading