Merge "Fix the crash when editing or deleting APN."
This commit is contained in:
committed by
Android (Google) Code Review
commit
74ea7efe8f
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import static android.provider.Telephony.Carriers.CONTENT_URI;
|
||||||
import static android.provider.Telephony.Carriers.FILTERED_URI;
|
import static android.provider.Telephony.Carriers.FILTERED_URI;
|
||||||
|
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
@@ -36,6 +37,7 @@ import android.widget.RelativeLayout;
|
|||||||
public class ApnPreference extends Preference implements
|
public class ApnPreference extends Preference implements
|
||||||
CompoundButton.OnCheckedChangeListener, OnClickListener {
|
CompoundButton.OnCheckedChangeListener, OnClickListener {
|
||||||
final static String TAG = "ApnPreference";
|
final static String TAG = "ApnPreference";
|
||||||
|
private boolean mDpcEnforced = false;
|
||||||
|
|
||||||
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
|
||||||
@@ -119,7 +121,8 @@ public class ApnPreference extends Preference implements
|
|||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
int pos = Integer.parseInt(getKey());
|
int pos = Integer.parseInt(getKey());
|
||||||
Uri url = ContentUris.withAppendedId(FILTERED_URI, pos);
|
Uri url = ContentUris.withAppendedId(
|
||||||
|
mDpcEnforced ? FILTERED_URI : CONTENT_URI, pos);
|
||||||
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
|
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
|
||||||
editIntent.putExtra(ApnSettings.SUB_ID, mSubId);
|
editIntent.putExtra(ApnSettings.SUB_ID, mSubId);
|
||||||
context.startActivity(editIntent);
|
context.startActivity(editIntent);
|
||||||
@@ -138,4 +141,8 @@ public class ApnPreference extends Preference implements
|
|||||||
public void setSubId(int subId) {
|
public void setSubId(int subId) {
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDpcEnforced(boolean enforced) {
|
||||||
|
mDpcEnforced = enforced;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import static android.provider.Telephony.Carriers.CONTENT_URI;
|
||||||
import static android.provider.Telephony.Carriers.ENFORCE_MANAGED_URI;
|
import static android.provider.Telephony.Carriers.ENFORCE_MANAGED_URI;
|
||||||
import static android.provider.Telephony.Carriers.FILTERED_URI;
|
import static android.provider.Telephony.Carriers.FILTERED_URI;
|
||||||
|
|
||||||
@@ -291,6 +292,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
|
|||||||
|
|
||||||
mSelectedKey = getSelectedApnKey();
|
mSelectedKey = getSelectedApnKey();
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
|
boolean enforced = isDpcApnEnforced();
|
||||||
while (!cursor.isAfterLast()) {
|
while (!cursor.isAfterLast()) {
|
||||||
String name = cursor.getString(NAME_INDEX);
|
String name = cursor.getString(NAME_INDEX);
|
||||||
String apn = cursor.getString(APN_INDEX);
|
String apn = cursor.getString(APN_INDEX);
|
||||||
@@ -307,6 +309,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
|
|||||||
pref.setPersistent(false);
|
pref.setPersistent(false);
|
||||||
pref.setOnPreferenceChangeListener(this);
|
pref.setOnPreferenceChangeListener(this);
|
||||||
pref.setSubId(subId);
|
pref.setSubId(subId);
|
||||||
|
pref.setDpcEnforced(enforced);
|
||||||
|
|
||||||
boolean selectable = ((type == null) || !type.equals("mms"));
|
boolean selectable = ((type == null) || !type.equals("mms"));
|
||||||
pref.setSelectable(selectable);
|
pref.setSelectable(selectable);
|
||||||
@@ -398,7 +401,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(Preference preference) {
|
public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
int pos = Integer.parseInt(preference.getKey());
|
int pos = Integer.parseInt(preference.getKey());
|
||||||
Uri url = ContentUris.withAppendedId(FILTERED_URI, pos);
|
Uri url = ContentUris.withAppendedId(isDpcApnEnforced() ? FILTERED_URI : CONTENT_URI, pos);
|
||||||
startActivity(new Intent(Intent.ACTION_EDIT, url));
|
startActivity(new Intent(Intent.ACTION_EDIT, url));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user