Remove sdcard developer option, avoid data crash.

Remove READ_EXTERNAL_STORAGE enforcement UI, since the permission is
now always enforced.  Check to see if bandwidth module is enabled
when launching data usage, and finish gracefully if disabled.

Bug: 10116515, 10392597
Change-Id: Id0295c405b780a53867934b3bcd0a5f56db7d87a
This commit is contained in:
Jeff Sharkey
2013-09-09 18:42:33 -07:00
parent 5999658ef8
commit 78ff1b8f10
3 changed files with 13 additions and 77 deletions

View File

@@ -16,15 +16,11 @@
package com.android.settings;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import android.app.ActionBar;
import android.app.Activity;
import android.app.ActivityManagerNative;
import android.app.ActivityThread;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.admin.DevicePolicyManager;
import android.app.backup.IBackupManager;
import android.bluetooth.BluetoothAdapter;
@@ -59,11 +55,11 @@ import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebViewFactory;
import android.view.Gravity;
import android.view.HardwareRenderer;
import android.view.IWindowManager;
import android.view.View;
import android.webkit.WebViewFactory;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
@@ -103,7 +99,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String ALLOW_MOCK_LOCATION = "allow_mock_location";
private static final String HDCP_CHECKING_KEY = "hdcp_checking";
private static final String HDCP_CHECKING_PROPERTY = "persist.sys.hdcp_checking";
private static final String ENFORCE_READ_EXTERNAL = "enforce_read_external";
private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password";
private static final String HARDWARE_UI_PROPERTY = "persist.sys.ui.hw";
private static final String MSAA_PROPERTY = "debug.egl.force_msaa";
@@ -171,7 +166,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private CheckBoxPreference mBugreportInPower;
private CheckBoxPreference mKeepScreenOn;
private CheckBoxPreference mBtHciSnoopLog;
private CheckBoxPreference mEnforceReadExternal;
private CheckBoxPreference mAllowMockLocation;
private PreferenceScreen mPassword;
@@ -263,7 +257,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mBugreportInPower = findAndInitCheckboxPref(BUGREPORT_IN_POWER_KEY);
mKeepScreenOn = findAndInitCheckboxPref(KEEP_SCREEN_ON);
mBtHciSnoopLog = findAndInitCheckboxPref(BT_HCI_SNOOP_LOG);
mEnforceReadExternal = findAndInitCheckboxPref(ENFORCE_READ_EXTERNAL);
mAllowMockLocation = findAndInitCheckboxPref(ALLOW_MOCK_LOCATION);
mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
mAllPrefs.add(mPassword);
@@ -492,7 +485,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
updateCheckBox(mBtHciSnoopLog, Settings.Secure.getInt(cr,
Settings.Secure.BLUETOOTH_HCI_LOG, 0) != 0);
updateCheckBox(mEnforceReadExternal, isPermissionEnforced(READ_EXTERNAL_STORAGE));
updateCheckBox(mAllowMockLocation, Settings.Secure.getInt(cr,
Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
updateRuntimeValue();
@@ -1250,12 +1242,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
(BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
} else if (preference == mBtHciSnoopLog) {
writeBtHciSnoopLogOptions();
} else if (preference == mEnforceReadExternal) {
if (mEnforceReadExternal.isChecked()) {
ConfirmEnforceFragment.show(this);
} else {
setPermissionEnforced(getActivity(), READ_EXTERNAL_STORAGE, false);
}
} else if (preference == mAllowMockLocation) {
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.ALLOW_MOCK_LOCATION,
@@ -1477,61 +1463,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
}
}
/**
* Dialog to confirm enforcement of {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}.
*/
public static class ConfirmEnforceFragment extends DialogFragment {
public static void show(DevelopmentSettings parent) {
final ConfirmEnforceFragment dialog = new ConfirmEnforceFragment();
dialog.setTargetFragment(parent, 0);
dialog.show(parent.getFragmentManager(), TAG_CONFIRM_ENFORCE);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.enforce_read_external_confirm_title);
builder.setMessage(R.string.enforce_read_external_confirm_message);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setPermissionEnforced(context, READ_EXTERNAL_STORAGE, true);
((DevelopmentSettings) getTargetFragment()).updateAllOptions();
}
});
builder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((DevelopmentSettings) getTargetFragment()).updateAllOptions();
}
});
return builder.create();
}
}
private static boolean isPermissionEnforced(String permission) {
try {
return ActivityThread.getPackageManager().isPermissionEnforced(permission);
} catch (RemoteException e) {
throw new RuntimeException("Problem talking with PackageManager", e);
}
}
private static void setPermissionEnforced(
Context context, String permission, boolean enforced) {
try {
// TODO: offload to background thread
ActivityThread.getPackageManager()
.setPermissionEnforced(READ_EXTERNAL_STORAGE, enforced);
} catch (RemoteException e) {
throw new RuntimeException("Problem talking with PackageManager", e);
}
}
private static boolean isPackageInstalled(Context context, String packageName) {
try {
return context.getPackageManager().getPackageInfo(packageName, 0) != null;