diff options
author | jianzhou <jianzhou@codeaurora.org> | 2014-07-31 16:13:25 +0800 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:21:14 -0600 |
commit | e0d320fbc18e45d05796db670a12e84d35ab8185 (patch) | |
tree | 3263eaa3bfb18d5e1b2242b2578d9efb28517d94 /src/com | |
parent | 2b37944f5e0ddff1c786b7a3d372edeb4d9bbf15 (diff) | |
download | packages_apps_Settings-e0d320fbc18e45d05796db670a12e84d35ab8185.zip packages_apps_Settings-e0d320fbc18e45d05796db670a12e84d35ab8185.tar.gz packages_apps_Settings-e0d320fbc18e45d05796db670a12e84d35ab8185.tar.bz2 |
Settings: Add the read only APN feature.
Disable the edit screen for read only APNs
Some operators don't want their APNs to be edited by
end user to avoid mistaken changes. End user should
be able to only view the APNs, but not edit.
Change-Id: I89f26ccc687d6989c562f164dbe53961a4d8a057
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/settings/ApnEditor.java | 17 | ||||
-rw-r--r-- | src/com/android/settings/ApnPreference.java | 9 | ||||
-rw-r--r-- | src/com/android/settings/ApnSettings.java | 7 |
3 files changed, 30 insertions, 3 deletions
diff --git a/src/com/android/settings/ApnEditor.java b/src/com/android/settings/ApnEditor.java index 2a65f96..013d754 100644 --- a/src/com/android/settings/ApnEditor.java +++ b/src/com/android/settings/ApnEditor.java @@ -90,6 +90,7 @@ public class ApnEditor extends InstrumentedPreferenceActivity private String mCurMnc; private String mCurMcc; + private boolean mDisableEditor = false; private Uri mUri; private Cursor mCursor; @@ -203,6 +204,11 @@ public class ApnEditor extends InstrumentedPreferenceActivity final String action = intent.getAction(); mSubId = intent.getIntExtra(ApnSettings.SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); + mDisableEditor = intent.getBooleanExtra("DISABLE_EDITOR", false); + if (mDisableEditor) { + getPreferenceScreen().setEnabled(false); + Log.d(TAG, "ApnEditor form is disabled."); + } mFirstTime = icicle == null; @@ -537,6 +543,10 @@ public class ApnEditor extends InstrumentedPreferenceActivity @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); + if (mDisableEditor) { + Log.d(TAG, "Form is disabled. Do not create the options menu."); + return true; + } // If it's a new APN, then cancel will delete the new entry in onPause if (!mNewApn) { menu.add(0, MENU_DELETE, 0, R.string.menu_delete) @@ -598,6 +608,13 @@ public class ApnEditor extends InstrumentedPreferenceActivity * @return true if the data was saved */ private boolean validateAndSave(boolean force) { + + // If the form is not editable, do nothing and return. + if (mDisableEditor){ + Log.d(TAG, "Form is disabled. Nothing to save."); + return true; + } + String name = checkNotSet(mName.getText()); String apn = checkNotSet(mApn.getText()); String mcc = checkNotSet(mMcc.getText()); diff --git a/src/com/android/settings/ApnPreference.java b/src/com/android/settings/ApnPreference.java index 1e29d22..dc697ea 100644 --- a/src/com/android/settings/ApnPreference.java +++ b/src/com/android/settings/ApnPreference.java @@ -51,6 +51,7 @@ public class ApnPreference extends Preference implements private static CompoundButton mCurrentChecked = null; private boolean mProtectFromCheckedChange = false; private boolean mSelectable = true; + private boolean mApnReadOnly = false; @Override public View getView(View convertView, ViewGroup parent) { @@ -118,7 +119,9 @@ public class ApnPreference extends Preference implements if (context != null) { int pos = Integer.parseInt(getKey()); Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos); - context.startActivity(new Intent(Intent.ACTION_EDIT, url)); + Intent intent = new Intent(Intent.ACTION_EDIT, url); + intent.putExtra("DISABLE_EDITOR", mApnReadOnly); + context.startActivity(intent); } } } @@ -130,4 +133,8 @@ public class ApnPreference extends Preference implements public boolean getSelectable() { return mSelectable; } + + public void setApnReadOnly(boolean apnReadOnly) { + mApnReadOnly = apnReadOnly; + } } diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java index 226f8ab..cd4ec22 100644 --- a/src/com/android/settings/ApnSettings.java +++ b/src/com/android/settings/ApnSettings.java @@ -81,6 +81,7 @@ public class ApnSettings extends SettingsPreferenceFragment implements private static final int TYPES_INDEX = 3; private static final int MVNO_TYPE_INDEX = 4; private static final int MVNO_MATCH_DATA_INDEX = 5; + private static final int RO_INDEX = 6; private static final int MENU_NEW = Menu.FIRST; private static final int MENU_RESTORE = Menu.FIRST + 1; @@ -231,8 +232,8 @@ public class ApnSettings extends SettingsPreferenceFragment implements + "\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL))"; Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] { - "_id", "name", "apn", "type", "mvno_type", "mvno_match_data"}, where, null, - Telephony.Carriers.DEFAULT_SORT_ORDER); + "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only"}, where, + null, Telephony.Carriers.DEFAULT_SORT_ORDER); if (cursor != null) { IccRecords r = null; @@ -257,9 +258,11 @@ public class ApnSettings extends SettingsPreferenceFragment implements String type = cursor.getString(TYPES_INDEX); String mvnoType = cursor.getString(MVNO_TYPE_INDEX); String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX); + boolean readOnly = (cursor.getInt(RO_INDEX) == 1); ApnPreference pref = new ApnPreference(getActivity()); + pref.setApnReadOnly(readOnly); pref.setKey(key); pref.setTitle(name); pref.setSummary(apn); |