2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.os.BatteryManager;
20 import android.os.Bundle;
21 import android.os.SystemProperties;
22 import android.preference.Preference;
23 import android.preference.PreferenceActivity;
24 import android.preference.PreferenceScreen;
25 import android.preference.CheckBoxPreference;
26 import android.provider.Settings;
27 import android.text.TextUtils;
30 * Displays preferences for application developers.
32 public class DevelopmentSettings extends PreferenceActivity {
34 private static final String ENABLE_ADB = "enable_adb";
35 private static final String KEEP_SCREEN_ON = "keep_screen_on";
36 private static final String ALLOW_MOCK_LOCATION = "allow_mock_location";
38 private CheckBoxPreference mEnableAdb;
39 private CheckBoxPreference mKeepScreenOn;
40 private CheckBoxPreference mAllowMockLocation;
43 protected void onCreate(Bundle icicle) {
44 super.onCreate(icicle);
46 addPreferencesFromResource(R.xml.development_prefs);
48 mEnableAdb = (CheckBoxPreference) findPreference(ENABLE_ADB);
49 mKeepScreenOn = (CheckBoxPreference) findPreference(KEEP_SCREEN_ON);
50 mAllowMockLocation = (CheckBoxPreference) findPreference(ALLOW_MOCK_LOCATION);
54 protected void onResume() {
57 mEnableAdb.setChecked(Settings.Secure.getInt(getContentResolver(),
58 Settings.Secure.ADB_ENABLED, 0) != 0);
59 mKeepScreenOn.setChecked(Settings.System.getInt(getContentResolver(),
60 Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
61 mAllowMockLocation.setChecked(Settings.Secure.getInt(getContentResolver(),
62 Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
66 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
68 // Those monkeys kept committing suicide, so we add this property
69 // to disable this functionality
70 if (!TextUtils.isEmpty(SystemProperties.get("ro.monkey"))) {
74 if (preference == mEnableAdb) {
75 Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED,
76 mEnableAdb.isChecked() ? 1 : 0);
77 } else if (preference == mKeepScreenOn) {
78 Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN,
79 mKeepScreenOn.isChecked() ?
80 (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
81 } else if (preference == mAllowMockLocation) {
82 Settings.Secure.putInt(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION,
83 mAllowMockLocation.isChecked() ? 1 : 0);