Fix issue #7328934: change threshold of developer options countdown toast

Delay showing toasts until the third tap.  Also harden the dev
settings code that pokes system property changes to not crash
if a system service throws an exception back.

Change-Id: I1351e2c950f2bcc4fc72afb60995fd7f84319e3d
This commit is contained in:
Dianne Hackborn
2012-10-11 11:03:36 -07:00
parent 84b90d5332
commit d6a24d505a
2 changed files with 9 additions and 2 deletions

View File

@@ -56,6 +56,7 @@ import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.HardwareRenderer; import android.view.HardwareRenderer;
import android.view.IWindowManager; import android.view.IWindowManager;
@@ -1111,6 +1112,9 @@ public class DevelopmentSettings extends PreferenceFragment
try { try {
obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0); obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0);
} catch (RemoteException e) { } catch (RemoteException e) {
} catch (Exception e) {
Log.i("DevSettings", "Somone wrote a bad service '" + service
+ "' that doesn't like to be poked: " + e);
} }
data.recycle(); data.recycle();
} }

View File

@@ -64,6 +64,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id"; private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id";
private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid"; private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
static final int TAPS_TO_BE_A_DEVELOPER = 7;
long[] mHits = new long[3]; long[] mHits = new long[3];
int mDevHitCountdown; int mDevHitCountdown;
Toast mDevHitToast; Toast mDevHitToast;
@@ -152,7 +154,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
super.onResume(); super.onResume();
mDevHitCountdown = getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE, mDevHitCountdown = getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE,
Context.MODE_PRIVATE).getBoolean(DevelopmentSettings.PREF_SHOW, Context.MODE_PRIVATE).getBoolean(DevelopmentSettings.PREF_SHOW,
android.os.Build.TYPE.equals("eng")) ? -1 : 7; android.os.Build.TYPE.equals("eng")) ? -1 : TAPS_TO_BE_A_DEVELOPER;
mDevHitToast = null; mDevHitToast = null;
} }
@@ -184,7 +186,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on, mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on,
Toast.LENGTH_LONG); Toast.LENGTH_LONG);
mDevHitToast.show(); mDevHitToast.show();
} else if (mDevHitCountdown > 0) { } else if (mDevHitCountdown > 0
&& mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER-2)) {
if (mDevHitToast != null) { if (mDevHitToast != null) {
mDevHitToast.cancel(); mDevHitToast.cancel();
} }