[Settings] Refractor ApnSettings code to independent package folder.
Bug: 169750507 Test: make RunSettingsRoboTests Change-Id: I8b2709ba8d16c625863d8a17abc3d0ab5d019bb8
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
@@ -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;
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network;
|
||||
package com.android.settings.network.apn;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
@@ -56,10 +56,12 @@ import androidx.preference.PreferenceGroup;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedSettingsFragment;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/** Handle each different apn setting. */
|
||||
public class ApnSettings extends RestrictedSettingsFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
static final String TAG = "ApnSettings";
|
||||
@@ -104,7 +106,7 @@ public class ApnSettings extends RestrictedSettingsFragment
|
||||
private static final Uri DEFAULTAPN_URI = Uri.parse(RESTORE_CARRIERS_URI);
|
||||
private static final Uri PREFERAPN_URI = Uri.parse(PREFERRED_APN_URI);
|
||||
|
||||
private static boolean mRestoreDefaultApnMode;
|
||||
private boolean mRestoreDefaultApnMode;
|
||||
|
||||
private UserManager mUserManager;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
@@ -388,7 +390,6 @@ public class ApnSettings extends RestrictedSettingsFragment
|
||||
case MENU_NEW:
|
||||
addNewApn();
|
||||
return true;
|
||||
|
||||
case MENU_RESTORE:
|
||||
restoreDefaultApn();
|
||||
return true;
|
||||
@@ -451,8 +452,7 @@ public class ApnSettings extends RestrictedSettingsFragment
|
||||
mRestoreApnUiHandler = new RestoreApnUiHandler();
|
||||
}
|
||||
|
||||
if (mRestoreApnProcessHandler == null ||
|
||||
mRestoreDefaultApnThread == null) {
|
||||
if (mRestoreApnProcessHandler == null || mRestoreDefaultApnThread == null) {
|
||||
mRestoreDefaultApnThread = new HandlerThread(
|
||||
"Restore default APN Handler: Process Thread");
|
||||
mRestoreDefaultApnThread.start();
|
||||
@@ -503,7 +503,7 @@ public class ApnSettings extends RestrictedSettingsFragment
|
||||
private class RestoreApnProcessHandler extends Handler {
|
||||
private Handler mRestoreApnUiHandler;
|
||||
|
||||
public RestoreApnProcessHandler(Looper looper, Handler restoreApnUiHandler) {
|
||||
RestoreApnProcessHandler(Looper looper, Handler restoreApnUiHandler) {
|
||||
super(looper);
|
||||
this.mRestoreApnUiHandler = restoreApnUiHandler;
|
||||
}
|
@@ -32,7 +32,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.network.ApnSettings;
|
||||
import com.android.settings.network.apn.ApnSettings;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
|
@@ -54,8 +54,8 @@ com.android.settings.inputmethod.KeyboardLayoutPickerFragment
|
||||
com.android.settings.inputmethod.SpellCheckersSettings
|
||||
com.android.settings.location.LocationPersonalSettings
|
||||
com.android.settings.location.LocationWorkProfileSettings
|
||||
com.android.settings.network.ApnEditor
|
||||
com.android.settings.network.ApnSettings
|
||||
com.android.settings.network.apn.ApnEditor
|
||||
com.android.settings.network.apn.ApnSettings
|
||||
com.android.settings.network.telephony.NetworkSelectSettings
|
||||
com.android.settings.notification.app.AppNotificationSettings
|
||||
com.android.settings.notification.app.ChannelNotificationSettings
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network;
|
||||
package com.android.settings.network.apn;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -46,7 +46,8 @@ import androidx.preference.MultiSelectListPreference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.ApnEditor.ApnData;
|
||||
import com.android.settings.network.ProxySubscriptionManager;
|
||||
import com.android.settings.network.apn.ApnEditor.ApnData;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -93,7 +94,7 @@ public class ApnEditorTest {
|
||||
private static final int CURSOR_INTEGER_INDEX = 0;
|
||||
private static final int CURSOR_STRING_INDEX = 1;
|
||||
|
||||
private static final Uri mApnUri = Uri.parse("Apn://row/1");
|
||||
private static final Uri APN_URI = Uri.parse("Apn://row/1");
|
||||
|
||||
@Mock
|
||||
private Cursor mCursor;
|
||||
@@ -382,7 +383,7 @@ public class ApnEditorTest {
|
||||
public void testApnData_invalidIntegerType_throwsInvalidTypeException() {
|
||||
// GIVEN a ApnData constructed from cursor
|
||||
initCursor();
|
||||
final ApnData data = new ApnData(mApnUri, mCursor);
|
||||
final ApnData data = new ApnData(APN_URI, mCursor);
|
||||
|
||||
// WHEN get a string from an integer column
|
||||
// THEN the InvalidTypeException is threw
|
||||
@@ -393,7 +394,7 @@ public class ApnEditorTest {
|
||||
public void testApnData_invalidStringType_throwsInvalidTypeException() {
|
||||
// GIVEN a ApnData constructed from cursor
|
||||
initCursor();
|
||||
final ApnData data = new ApnData(mApnUri, mCursor);
|
||||
final ApnData data = new ApnData(APN_URI, mCursor);
|
||||
|
||||
// WHEN get a integer from a string column
|
||||
// THEN the InvalidTypeException is threw
|
||||
@@ -404,7 +405,7 @@ public class ApnEditorTest {
|
||||
public void testApnData_validIntegerType_returnCorrectValue() {
|
||||
// GIVEN a ApnData constructed from cursor
|
||||
initCursor();
|
||||
final ApnData data = new ApnData(mApnUri, mCursor);
|
||||
final ApnData data = new ApnData(APN_URI, mCursor);
|
||||
|
||||
// WHEN get integer from an integer column
|
||||
final int val = data.getInteger(CURSOR_INTEGER_INDEX);
|
||||
@@ -417,7 +418,7 @@ public class ApnEditorTest {
|
||||
public void testApnData_validStringType_returnCorrectValue() {
|
||||
// GIVEN a ApnData constructed from cursor
|
||||
initCursor();
|
||||
final ApnData data = new ApnData(mApnUri, mCursor);
|
||||
final ApnData data = new ApnData(APN_URI, mCursor);
|
||||
|
||||
// WHEN get string from a string column
|
||||
final String str = data.getString(CURSOR_STRING_INDEX);
|
@@ -34,7 +34,7 @@ import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.android.settings.network.ApnSettings;
|
||||
import com.android.settings.network.apn.ApnSettings;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
|
@@ -37,7 +37,7 @@ import android.telephony.TelephonyManager;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.network.ApnSettings;
|
||||
import com.android.settings.network.apn.ApnSettings;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
|
Reference in New Issue
Block a user