Development option to toggle StrictMode flashing.
Change-Id: I89a6907a8d0a8a635d7af1c9d124b4531915ba2f
This commit is contained in:
@@ -74,10 +74,16 @@
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="@string/development_settings_show_updates_text" />
|
||||
|
||||
<Spinner android:id="@+id/strictmode_visual"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/show_updates"
|
||||
android:layout_alignParentLeft="true" />
|
||||
|
||||
<CheckBox android:id="@+id/compatibility_mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/show_updates"
|
||||
android:layout_below="@id/strictmode_visual"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="@string/development_settings_compatibility_mode_text" />
|
||||
|
||||
|
||||
@@ -23,23 +23,26 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.RemoteException;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.ServiceManagerNative;
|
||||
import android.os.StrictMode;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -53,6 +56,7 @@ public class DevelopmentSettings extends Activity {
|
||||
private CheckBox mWaitForDebuggerCB;
|
||||
private CheckBox mAlwaysFinishCB;
|
||||
private Spinner mPointerLocationSpinner;
|
||||
private Spinner mStrictModeVisualSpinner;
|
||||
private CheckBox mShowLoadCB;
|
||||
private CheckBox mShowCpuCB;
|
||||
private CheckBox mEnableGLCB;
|
||||
@@ -106,6 +110,17 @@ public class DevelopmentSettings extends Activity {
|
||||
"Pointer Location" });
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mPointerLocationSpinner.setAdapter(adapter);
|
||||
mStrictModeVisualSpinner = (Spinner)findViewById(R.id.strictmode_visual);
|
||||
adapter = new ArrayAdapter<String>(
|
||||
this,
|
||||
android.R.layout.simple_spinner_item,
|
||||
new String[] {
|
||||
"StrictMode visual indicator: build variant default",
|
||||
"StrictMode visual indicator: on",
|
||||
"StrictMode visual indicator: off" });
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mStrictModeVisualSpinner.setAdapter(adapter);
|
||||
mStrictModeVisualSpinner.setOnItemSelectedListener(mStrictModeVisualChanged);
|
||||
mShowLoadCB = (CheckBox)findViewById(R.id.show_load);
|
||||
mShowLoadCB.setOnClickListener(mShowLoadClicked);
|
||||
mShowCpuCB = (CheckBox)findViewById(R.id.show_cpu);
|
||||
@@ -182,6 +197,7 @@ public class DevelopmentSettings extends Activity {
|
||||
updateDebugOptions();
|
||||
updateFinishOptions();
|
||||
updatePointerLocationOptions();
|
||||
updateStrictModeVisualOptions();
|
||||
updateProcessLimitOptions();
|
||||
updateSharedOptions();
|
||||
updateFlingerOptions();
|
||||
@@ -245,6 +261,24 @@ public class DevelopmentSettings extends Activity {
|
||||
mPointerLocationSpinner.setSelection(mPointerLocation);
|
||||
}
|
||||
|
||||
// Returns the current state of the system property that controls
|
||||
// strictmode flashes. One of:
|
||||
// 0: not explicitly set one way or another
|
||||
// 1: on
|
||||
// 2: off
|
||||
// These are the indices in the Spinner's ArrayAdapter.
|
||||
private int currentStrictModeActiveIndex() {
|
||||
if (TextUtils.isEmpty(SystemProperties.get(StrictMode.VISUAL_PROPERTY))) {
|
||||
return 0;
|
||||
}
|
||||
boolean enabled = SystemProperties.getBoolean(StrictMode.VISUAL_PROPERTY, false);
|
||||
return enabled ? 1 : 2;
|
||||
}
|
||||
|
||||
private void updateStrictModeVisualOptions() {
|
||||
mStrictModeVisualSpinner.setSelection(currentStrictModeActiveIndex());
|
||||
}
|
||||
|
||||
private void writeProcessLimitOptions() {
|
||||
try {
|
||||
ActivityManagerNative.getDefault().setProcessLimit(mProcessLimit);
|
||||
@@ -456,6 +490,41 @@ public class DevelopmentSettings extends Activity {
|
||||
}
|
||||
};
|
||||
|
||||
private Spinner.OnItemSelectedListener mStrictModeVisualChanged
|
||||
= new Spinner.OnItemSelectedListener() {
|
||||
public void onItemSelected(android.widget.AdapterView av, View v,
|
||||
int position, long id) {
|
||||
if (position == currentStrictModeActiveIndex()) {
|
||||
// at the existing position, so don't show a Toast.
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
switch (position) {
|
||||
case 0: // default
|
||||
mWindowManager.setStrictModeVisualIndicatorPreference("");
|
||||
break;
|
||||
case 1: // on
|
||||
mWindowManager.setStrictModeVisualIndicatorPreference("1");
|
||||
break;
|
||||
case 2: // off
|
||||
mWindowManager.setStrictModeVisualIndicatorPreference("0");
|
||||
break;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Error calling setStrictModeVisualIndicatorPreference", e);
|
||||
}
|
||||
|
||||
Toast.makeText(
|
||||
DevelopmentSettings.this,
|
||||
"Setting changed; will take effect per-app next launch, or on reboot",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void onNothingSelected(android.widget.AdapterView av) {
|
||||
}
|
||||
};
|
||||
|
||||
private Spinner.OnItemSelectedListener mMaxProcsChanged
|
||||
= new Spinner.OnItemSelectedListener() {
|
||||
public void onItemSelected(android.widget.AdapterView av, View v,
|
||||
|
||||
Reference in New Issue
Block a user