Revert "Change Settings to use URL_FILTERED and blocks menu options when DPC Apns are enforced."

This reverts commit ab1f251def.

Reason for revert: As per discussion in b/72484718, we are going to
block Access Point Name entry point in Network&Settings, so we no longer
need the change in ApnSettings fragment itself.
Bug: 72484718

Change-Id: I337a03e8baebaedb9e9ab83ccc4f7cf2f9c562c8
This commit is contained in:
Yueming Wang
2018-02-26 14:46:21 +00:00
committed by Alex Chau
parent ef5fd3c81d
commit 3fc11a6db4
2 changed files with 11 additions and 23 deletions

View File

@@ -16,12 +16,11 @@
package com.android.settings; package com.android.settings;
import static android.provider.Telephony.Carriers.FILTERED_URI;
import android.content.ContentUris; import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.provider.Telephony;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder; import android.support.v7.preference.PreferenceViewHolder;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
@@ -119,7 +118,7 @@ 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(Telephony.Carriers.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);

View File

@@ -16,9 +16,6 @@
package com.android.settings; package com.android.settings;
import static android.provider.Telephony.Carriers.ENFORCE_MANAGED_URI;
import static android.provider.Telephony.Carriers.FILTERED_URI;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
@@ -42,6 +39,7 @@ import android.os.UserManager;
import android.provider.Telephony; import android.provider.Telephony;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.telephony.CarrierConfigManager; import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
@@ -52,6 +50,7 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -247,17 +246,6 @@ public class ApnSettings extends RestrictedSettingsFragment implements
return null; return null;
} }
private boolean isDpcApnEnforced() {
try (Cursor enforceCursor = getContentResolver().query(ENFORCE_MANAGED_URI,
null, null, null, null)) {
if (enforceCursor == null || enforceCursor.getCount() != 1) {
return false;
}
enforceCursor.moveToFirst();
return enforceCursor.getInt(0) > 0;
}
}
private void fillList() { private void fillList() {
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId() final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
@@ -271,9 +259,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements
where.append(" AND NOT (type='ims')"); where.append(" AND NOT (type='ims')");
} }
Cursor cursor = getContentResolver().query(FILTERED_URI, Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
new String[] {"_id", "name", "apn", "type", "mvno_type", "mvno_match_data"}, "_id", "name", "apn", "type", "mvno_type", "mvno_match_data"}, where.toString(),
where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER); null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (cursor != null) { if (cursor != null) {
IccRecords r = null; IccRecords r = null;
@@ -355,14 +343,15 @@ public class ApnSettings extends RestrictedSettingsFragment implements
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (!mUnavailable && !isDpcApnEnforced()) { if (!mUnavailable) {
if (mAllowAddingApns) { if (mAllowAddingApns) {
menu.add(0, MENU_NEW, 0, menu.add(0, MENU_NEW, 0,
getResources().getString(R.string.menu_new)) getResources().getString(R.string.menu_new))
.setIcon(R.drawable.ic_menu_add_white) .setIcon(R.drawable.ic_menu_add_white)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
} }
menu.add(0, MENU_RESTORE, 0, getResources().getString(R.string.menu_restore)) menu.add(0, MENU_RESTORE, 0,
getResources().getString(R.string.menu_restore))
.setIcon(android.R.drawable.ic_menu_upload); .setIcon(android.R.drawable.ic_menu_upload);
} }
@@ -398,7 +387,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(Telephony.Carriers.CONTENT_URI, pos);
startActivity(new Intent(Intent.ACTION_EDIT, url)); startActivity(new Intent(Intent.ACTION_EDIT, url));
return true; return true;
} }