am ffb9258b: am 75c4204e: Merge "Remove sdcard developer option, avoid data crash." into klp-dev

* commit 'ffb9258b85b894377bef59a08d3466a6d0d12406':
  Remove sdcard developer option, avoid data crash.
This commit is contained in:
Jeff Sharkey
2013-09-09 21:48:48 -07:00
committed by Android Git Automerger
3 changed files with 13 additions and 77 deletions

View File

@@ -51,11 +51,6 @@
android:entries="@array/hdcp_checking_titles"
android:entryValues="@array/hdcp_checking_values" />
<CheckBoxPreference
android:key="enforce_read_external"
android:title="@string/enforce_read_external_title"
android:summary="@string/enforce_read_external_summary" />
<CheckBoxPreference
android:key="bt_hci_snoop_log"
android:title="@string/bt_hci_snoop_log"

View File

@@ -141,13 +141,13 @@ import com.android.settings.widget.ChartDataUsageView.DataUsageChartListener;
import com.android.settings.widget.PieChartView;
import com.google.android.collect.Lists;
import libcore.util.Objects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import libcore.util.Objects;
/**
* Panel showing data usage history across various networks, including options
* to inspect based on usage cycle and control through {@link NetworkPolicy}.
@@ -276,6 +276,16 @@ public class DataUsageSummary extends Fragment {
mPolicyEditor = new NetworkPolicyEditor(mPolicyManager);
mPolicyEditor.read();
try {
if (!mNetworkService.isBandwidthControlEnabled()) {
Log.w(TAG, "No bandwidth control; leaving");
getActivity().finish();
}
} catch (RemoteException e) {
Log.w(TAG, "No bandwidth control; leaving");
getActivity().finish();
}
try {
mStatsSession = mStatsService.openSession();
} catch (RemoteException e) {

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;