diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-10-10 15:05:42 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-10-10 15:05:42 -0700 |
commit | caefa9b5f03b595b81729407e4123fee18a4342c (patch) | |
tree | b50a80299e37718720dd500c532fbbc6555a9c47 /src/com/android/settings/DeviceInfoSettings.java | |
parent | 553074f0fc2aa46f44797b72f1457146697645b6 (diff) | |
download | packages_apps_settings-caefa9b5f03b595b81729407e4123fee18a4342c.zip packages_apps_settings-caefa9b5f03b595b81729407e4123fee18a4342c.tar.gz packages_apps_settings-caefa9b5f03b595b81729407e4123fee18a4342c.tar.bz2 |
Fix issue #7318666: hide developer options from user build
Change-Id: I4c5a66bd5f4d3fc36d439228a7a276d694291606
Diffstat (limited to 'src/com/android/settings/DeviceInfoSettings.java')
-rw-r--r-- | src/com/android/settings/DeviceInfoSettings.java | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 5f35871..f113da1 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -17,10 +17,8 @@ package com.android.settings; import android.app.Activity; -import android.content.ComponentName; +import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.os.Build; import android.os.Bundle; import android.os.SELinux; @@ -30,13 +28,12 @@ import android.os.UserHandle; import android.preference.Preference; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; -import android.provider.Settings; import android.util.Log; +import android.widget.Toast; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; -import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -68,6 +65,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid"; long[] mHits = new long[3]; + int mDevHitCountdown; + Toast mDevHitToast; @Override public void onCreate(Bundle icicle) { @@ -82,6 +81,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID); setStringSummary(KEY_DEVICE_MODEL, Build.MODEL); setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY); + findPreference(KEY_BUILD_NUMBER).setEnabled(true); findPreference(KEY_KERNEL_VERSION).setSummary(getFormattedKernelVersion()); if (!SELinux.isSELinuxEnabled()) { @@ -148,6 +148,15 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { } @Override + public void onResume() { + super.onResume(); + mDevHitCountdown = getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE, + Context.MODE_PRIVATE).getBoolean(DevelopmentSettings.PREF_SHOW, + android.os.Build.TYPE.equals("eng")) ? -1 : 7; + mDevHitToast = null; + } + + @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference.getKey().equals(KEY_FIRMWARE_VERSION)) { System.arraycopy(mHits, 1, mHits, 0, mHits.length-1); @@ -162,6 +171,36 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { Log.e(LOG_TAG, "Unable to start activity " + intent.toString()); } } + } else if (preference.getKey().equals(KEY_BUILD_NUMBER)) { + if (mDevHitCountdown > 0) { + mDevHitCountdown--; + if (mDevHitCountdown == 0) { + getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE, + Context.MODE_PRIVATE).edit().putBoolean( + DevelopmentSettings.PREF_SHOW, true).apply(); + if (mDevHitToast != null) { + mDevHitToast.cancel(); + } + mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on, + Toast.LENGTH_LONG); + mDevHitToast.show(); + } else if (mDevHitCountdown > 0) { + if (mDevHitToast != null) { + mDevHitToast.cancel(); + } + mDevHitToast = Toast.makeText(getActivity(), getResources().getString( + R.string.show_dev_countdown, mDevHitCountdown), + Toast.LENGTH_SHORT); + mDevHitToast.show(); + } + } else if (mDevHitCountdown < 0) { + if (mDevHitToast != null) { + mDevHitToast.cancel(); + } + mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already, + Toast.LENGTH_LONG); + mDevHitToast.show(); + } } return super.onPreferenceTreeClick(preferenceScreen, preference); } |