The Android Open Source Project | de2d9f5 | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.settings; |
| 18 | |
| 19 | import android.os.Bundle; |
| 20 | import android.os.SystemProperties; |
| 21 | import android.preference.Preference; |
| 22 | import android.preference.PreferenceActivity; |
| 23 | import android.preference.PreferenceScreen; |
| 24 | import android.preference.CheckBoxPreference; |
| 25 | import android.provider.Settings; |
| 26 | import android.text.TextUtils; |
| 27 | |
| 28 | /* |
| 29 | * Displays preferences for application developers. |
| 30 | */ |
| 31 | public class DevelopmentSettings extends PreferenceActivity { |
| 32 | |
| 33 | private static final String ENABLE_ADB = "enable_adb"; |
| 34 | private static final String KEEP_SCREEN_ON = "keep_screen_on"; |
| 35 | |
| 36 | private CheckBoxPreference mEnableAdb; |
| 37 | private CheckBoxPreference mKeepScreenOn; |
| 38 | |
| 39 | @Override |
| 40 | protected void onCreate(Bundle icicle) { |
| 41 | super.onCreate(icicle); |
| 42 | |
| 43 | addPreferencesFromResource(R.xml.development_prefs); |
| 44 | |
| 45 | mEnableAdb = (CheckBoxPreference) findPreference(ENABLE_ADB); |
| 46 | mKeepScreenOn = (CheckBoxPreference) findPreference(KEEP_SCREEN_ON); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | protected void onResume() { |
| 51 | super.onResume(); |
| 52 | |
| 53 | mEnableAdb.setChecked(Settings.System.getInt(getContentResolver(), |
| 54 | Settings.System.ADB_ENABLED, 0) != 0); |
| 55 | mKeepScreenOn.setChecked(Settings.System.getInt(getContentResolver(), |
| 56 | Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0); |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { |
| 61 | |
| 62 | // Those monkeys kept committing suicide, so we add this property |
| 63 | // to disable this functionality |
| 64 | if (!TextUtils.isEmpty(SystemProperties.get("ro.monkey"))) { |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | if (preference == mEnableAdb) { |
| 69 | Settings.System.putInt(getContentResolver(), Settings.System.ADB_ENABLED, |
| 70 | mEnableAdb.isChecked() ? 1 : 0); |
| 71 | } else if (preference == mKeepScreenOn) { |
| 72 | Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, |
| 73 | mKeepScreenOn.isChecked() ? 1 : 0); |
| 74 | } |
| 75 | |
| 76 | return false; |
| 77 | } |
| 78 | } |