Fix issue that read-only apns can be edited
When entering to ApnEditor with ApnSettings#onPreferenceTreeClick(), subId is not passed. So invalid subId is used and it gets wrong carrier config values. To resolve this issue, remove unnecessary ApnSettings click event. The only click event for launching ApnEditor is ApnPreference click event. Test: manual - Check that the read-only APN can't be edited when tap the edge of the APN settings screen Bug: 117302653 Change-Id: I0a61b409539d6e4f6aa9860235e61c43c76640fa
This commit is contained in:
committed by
takeshi tanigawa
parent
8b16aba0dd
commit
8d1eee08f7
@@ -27,15 +27,12 @@ import android.telephony.SubscriptionManager;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class ApnPreference extends Preference implements
|
public class ApnPreference extends Preference implements CompoundButton.OnCheckedChangeListener {
|
||||||
CompoundButton.OnCheckedChangeListener, OnClickListener {
|
|
||||||
final static String TAG = "ApnPreference";
|
final static String TAG = "ApnPreference";
|
||||||
|
|
||||||
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
@@ -81,11 +78,6 @@ public class ApnPreference extends Preference implements
|
|||||||
rb.setVisibility(View.GONE);
|
rb.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
View textLayout = view.findViewById(R.id.text_layout);
|
|
||||||
if ((textLayout != null) && textLayout instanceof RelativeLayout) {
|
|
||||||
textLayout.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
@@ -115,16 +107,16 @@ public class ApnPreference extends Preference implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(android.view.View v) {
|
@Override
|
||||||
if ((v != null) && (R.id.text_layout == v.getId())) {
|
protected void onClick() {
|
||||||
Context context = getContext();
|
super.onClick();
|
||||||
if (context != null) {
|
Context context = getContext();
|
||||||
int pos = Integer.parseInt(getKey());
|
if (context != null) {
|
||||||
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
|
int pos = Integer.parseInt(getKey());
|
||||||
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
|
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
|
||||||
editIntent.putExtra(ApnSettings.SUB_ID, mSubId);
|
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
|
||||||
context.startActivity(editIntent);
|
editIntent.putExtra(ApnSettings.SUB_ID, mSubId);
|
||||||
}
|
context.startActivity(editIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@ import android.app.Dialog;
|
|||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentUris;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -64,8 +63,7 @@ import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ApnSettings extends RestrictedSettingsFragment implements
|
public class ApnSettings extends RestrictedSettingsFragment {
|
||||||
Preference.OnPreferenceChangeListener {
|
|
||||||
static final String TAG = "ApnSettings";
|
static final String TAG = "ApnSettings";
|
||||||
|
|
||||||
public static final String EXTRA_POSITION = "position";
|
public static final String EXTRA_POSITION = "position";
|
||||||
@@ -312,7 +310,6 @@ public class ApnSettings extends RestrictedSettingsFragment implements
|
|||||||
pref.setTitle(name);
|
pref.setTitle(name);
|
||||||
pref.setSummary(apn);
|
pref.setSummary(apn);
|
||||||
pref.setPersistent(false);
|
pref.setPersistent(false);
|
||||||
pref.setOnPreferenceChangeListener(this);
|
|
||||||
pref.setSubId(subId);
|
pref.setSubId(subId);
|
||||||
|
|
||||||
boolean selectable = ((type == null) || !type.equals("mms"));
|
boolean selectable = ((type == null) || !type.equals("mms"));
|
||||||
@@ -404,14 +401,6 @@ public class ApnSettings extends RestrictedSettingsFragment implements
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceTreeClick(Preference preference) {
|
|
||||||
int pos = Integer.parseInt(preference.getKey());
|
|
||||||
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
|
|
||||||
startActivity(new Intent(Intent.ACTION_EDIT, url));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
Log.d(TAG, "onPreferenceChange(): Preference - " + preference
|
Log.d(TAG, "onPreferenceChange(): Preference - " + preference
|
||||||
+ ", newValue - " + newValue + ", newValue type - "
|
+ ", newValue - " + newValue + ", newValue type - "
|
||||||
|
Reference in New Issue
Block a user