Merge change 24870 into eclair
* changes:
Transient patch for the WifiConfiguration change.
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e61d375..7a1760d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -6,6 +6,7 @@
<uses-permission android:name="com.google.android.providers.gmail.permission.READ_GMAIL" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+ <uses-permission android:name="android.permission.DEVICE_POWER" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.VIBRATE" />
diff --git a/res/layout/preference_dialog_brightness.xml b/res/layout/preference_dialog_brightness.xml
new file mode 100644
index 0000000..071beed
--- /dev/null
+++ b/res/layout/preference_dialog_brightness.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Copyright (C) 2009 Motorola, Inc.
+ March 23, 2009 - Motorola - Allow automatic brightness changes.
+-->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ android:gravity="center_horizontal"
+ android:paddingBottom="20dip">
+
+ <ImageView android:id="@android:id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="20dip" />
+
+ <CheckBox android:id="@+id/automatic_mode"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/automatic_brightness"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:layout_marginTop="6dip"
+ android:layout_marginLeft="20dip"
+ android:layout_marginRight="20dip" />
+
+ <SeekBar android:id="@*android:id/seekbar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="20dip" />
+
+ </LinearLayout>
+</ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4db2104..d39c90b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -916,6 +916,8 @@
<string name="screen_timeout">Screen timeout</string>
<!-- Sound & display settings screen, setting option summary to change screen timeout -->
<string name="screen_timeout_summary">Adjust the delay before the screen automatically turns off</string>
+ <!-- Sound & display settings screen, setting option name to change whether the screen adjusts automatically based on lighting conditions -->
+ <string name="automatic_brightness">Automatic brightness</string>
<!-- SIM lock settings title -->
<string name="sim_lock_settings">SIM card lock settings</string>
@@ -2057,7 +2059,7 @@
<!-- Description for the confirm-new-password input box -->
<string name="cstor_confirm_password">Confirm new password:</string>
<!-- Description when user set up the storage for the very first time -->
- <string name="cstor_first_time_hint">Set a password for the credential storage.</string>
+ <string name="cstor_first_time_hint">Set a password for the credential storage (at least 8 characters).</string>
<!-- Description when user set up the storage for the very first time from an action that requires the credential storage-->
<string name="cstor_first_time_hint_from_action">Set a password for the credential storage.</string>
<string name="cstor_password_error">Please enter the correct password.</string>
diff --git a/src/com/android/settings/BrightnessPreference.java b/src/com/android/settings/BrightnessPreference.java
index 9f55463..e2fe0f2 100644
--- a/src/com/android/settings/BrightnessPreference.java
+++ b/src/com/android/settings/BrightnessPreference.java
@@ -18,7 +18,7 @@
import android.content.Context;
import android.os.RemoteException;
-import android.os.IHardwareService;
+import android.os.IPowerManager;
import android.os.ServiceManager;
import android.preference.SeekBarPreference;
import android.provider.Settings;
@@ -26,16 +26,22 @@
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
import android.widget.SeekBar;
import java.util.Map;
public class BrightnessPreference extends SeekBarPreference implements
- SeekBar.OnSeekBarChangeListener {
+ SeekBar.OnSeekBarChangeListener, CheckBox.OnCheckedChangeListener {
private SeekBar mSeekBar;
+ private CheckBox mCheckBox;
private int mOldBrightness;
+ private int mOldAutomatic;
+
+ private boolean mAutomaticAvailable;
// Backlight range is from 0 - 255. Need to make sure that user
// doesn't set the backlight to 0 and get stuck
@@ -44,6 +50,11 @@
public BrightnessPreference(Context context, AttributeSet attrs) {
super(context, attrs);
+
+ mAutomaticAvailable = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_automatic_brightness_available);
+
+ setDialogLayoutResource(R.layout.preference_dialog_brightness);
}
@Override
@@ -60,6 +71,20 @@
mOldBrightness = MAXIMUM_BACKLIGHT;
}
mSeekBar.setProgress(mOldBrightness - MINIMUM_BACKLIGHT);
+
+ mCheckBox = (CheckBox)view.findViewById(R.id.automatic_mode);
+ if (mAutomaticAvailable) {
+ mCheckBox.setOnCheckedChangeListener(this);
+ try {
+ mOldAutomatic = Settings.System.getInt(getContext().getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_MODE);
+ } catch (SettingNotFoundException snfe) {
+ mOldAutomatic = 0;
+ }
+ mCheckBox.setChecked(mOldAutomatic != 0);
+ } else {
+ mCheckBox.setVisibility(View.GONE);
+ }
}
public void onProgressChanged(SeekBar seekBar, int progress,
@@ -75,6 +100,13 @@
// NA
}
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ setMode(isChecked ? 1 : 0);
+ if (!isChecked) {
+ setBrightness(mSeekBar.getProgress() + MINIMUM_BACKLIGHT);
+ }
+ }
+
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
@@ -83,21 +115,45 @@
Settings.System.putInt(getContext().getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS,
mSeekBar.getProgress() + MINIMUM_BACKLIGHT);
+ if (mAutomaticAvailable) {
+ Settings.System.putInt(getContext().getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_MODE,
+ mCheckBox.isChecked() ? 1 : 0);
+ }
} else {
setBrightness(mOldBrightness);
+ if (mAutomaticAvailable) {
+ setMode(mOldAutomatic);
+ }
}
}
private void setBrightness(int brightness) {
try {
- IHardwareService hardware = IHardwareService.Stub.asInterface(
- ServiceManager.getService("hardware"));
- if (hardware != null) {
- hardware.setBacklights(brightness);
+ IPowerManager power = IPowerManager.Stub.asInterface(
+ ServiceManager.getService("power"));
+ if (power != null) {
+ power.setBacklightBrightness(brightness);
}
} catch (RemoteException doe) {
}
}
+
+ private void setMode(int automatic) {
+ if (automatic != 0) {
+ mSeekBar.setVisibility(View.GONE);
+ } else {
+ mSeekBar.setVisibility(View.VISIBLE);
+ }
+ try {
+ IPowerManager power = IPowerManager.Stub.asInterface(
+ ServiceManager.getService("power"));
+ if (power != null) {
+ power.setAutoBrightness(automatic != 0);
+ }
+ } catch (RemoteException doe) {
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
index 7052bfb..046cd76 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
@@ -140,7 +140,12 @@
*/
public String getName(BluetoothDevice device) {
CachedBluetoothDevice cachedDevice = findDevice(device);
- return cachedDevice != null ? cachedDevice.getName() : device.getAddress();
+ if (cachedDevice != null) return cachedDevice.getName();
+
+ String name = device.getName();
+ if (name != null) return name;
+
+ return device.getAddress();
}
private void dispatchDeviceAdded(CachedBluetoothDevice cachedDevice) {
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
index 501f767..7037582 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
@@ -256,7 +256,10 @@
CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(device);
String name = null;
if (cachedDevice == null) {
- name = mContext.getString(R.string.bluetooth_remote_device);
+ name = device.getName();
+ if (name == null) {
+ name = mContext.getString(R.string.bluetooth_remote_device);
+ }
} else {
name = cachedDevice.getName();
}
diff --git a/src/com/android/settings/vpn/L2tpEditor.java b/src/com/android/settings/vpn/L2tpEditor.java
index 29036f2..05d51d6 100644
--- a/src/com/android/settings/vpn/L2tpEditor.java
+++ b/src/com/android/settings/vpn/L2tpEditor.java
@@ -57,7 +57,7 @@
final L2tpProfile profile = (L2tpProfile) getProfile();
CheckBoxPreference secret = mSecret = new CheckBoxPreference(c);
boolean enabled = profile.isSecretEnabled();
- setSecretTitle(secret, R.string.vpn_l2tp_secret, enabled);
+ setCheckBoxTitle(secret, R.string.vpn_l2tp_secret);
secret.setChecked(enabled);
setSecretSummary(secret, enabled);
secret.setOnPreferenceChangeListener(
@@ -67,8 +67,6 @@
boolean enabled = (Boolean) newValue;
profile.setSecretEnabled(enabled);
mSecretHandler.getPreference().setEnabled(enabled);
- setSecretTitle(mSecret, R.string.vpn_l2tp_secret,
- enabled);
setSecretSummary(mSecret, enabled);
return true;
}
diff --git a/src/com/android/settings/vpn/PptpEditor.java b/src/com/android/settings/vpn/PptpEditor.java
index fafe6a7..cfb3fa3 100644
--- a/src/com/android/settings/vpn/PptpEditor.java
+++ b/src/com/android/settings/vpn/PptpEditor.java
@@ -45,7 +45,7 @@
final PptpProfile profile = (PptpProfile) getProfile();
CheckBoxPreference encryption = mEncryption = new CheckBoxPreference(c);
boolean enabled = profile.isEncryptionEnabled();
- setSecretTitle(encryption, R.string.vpn_pptp_encryption_title, enabled);
+ setCheckBoxTitle(encryption, R.string.vpn_pptp_encryption_title);
encryption.setChecked(enabled);
setEncryptionSummary(encryption, enabled);
encryption.setOnPreferenceChangeListener(
@@ -54,8 +54,6 @@
Preference pref, Object newValue) {
boolean enabled = (Boolean) newValue;
profile.setEncryptionEnabled(enabled);
- setSecretTitle(mEncryption,
- R.string.vpn_pptp_encryption_title, enabled);
setEncryptionSummary(mEncryption, enabled);
return true;
}
diff --git a/src/com/android/settings/vpn/VpnProfileEditor.java b/src/com/android/settings/vpn/VpnProfileEditor.java
index 8dc3643..100b78e 100644
--- a/src/com/android/settings/vpn/VpnProfileEditor.java
+++ b/src/com/android/settings/vpn/VpnProfileEditor.java
@@ -174,12 +174,9 @@
: v);
}
- protected void setSecretTitle(
- CheckBoxPreference pref, int fieldNameId, boolean enabled) {
+ protected void setCheckBoxTitle(CheckBoxPreference pref, int fieldNameId) {
Context c = pref.getContext();
- String formatString = enabled
- ? c.getString(R.string.vpn_disable_field)
- : c.getString(R.string.vpn_enable_field);
+ String formatString = c.getString(R.string.vpn_enable_field);
pref.setTitle(String.format(formatString, c.getString(fieldNameId)));
}
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
index eddeb63..1f3c9f1 100644
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
@@ -30,7 +30,7 @@
import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
-import android.os.IHardwareService;
+import android.os.IPowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
@@ -318,9 +318,9 @@
*/
private static boolean getBrightness(Context context) {
try {
- IHardwareService hardware = IHardwareService.Stub.asInterface(
- ServiceManager.getService("hardware"));
- if (hardware != null) {
+ IPowerManager power = IPowerManager.Stub.asInterface(
+ ServiceManager.getService("power"));
+ if (power != null) {
int brightness = Settings.System.getInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS);
return brightness > 100;
@@ -338,9 +338,9 @@
*/
private void toggleBrightness(Context context) {
try {
- IHardwareService hardware = IHardwareService.Stub.asInterface(
- ServiceManager.getService("hardware"));
- if (hardware != null) {
+ IPowerManager power = IPowerManager.Stub.asInterface(
+ ServiceManager.getService("power"));
+ if (power != null) {
ContentResolver cr = context.getContentResolver();
int brightness = Settings.System.getInt(cr,
Settings.System.SCREEN_BRIGHTNESS);
@@ -353,7 +353,7 @@
} else {
brightness = MINIMUM_BACKLIGHT;
}
- hardware.setBacklights(brightness);
+ power.setBacklightBrightness(brightness);
Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, brightness);
brightness = Settings.System.getInt(cr,
Settings.System.SCREEN_BRIGHTNESS);