Merge change 27177 into eclair
* changes: Add auto-brightness mode to the list of backed-up settings
This commit is contained in:
@@ -1416,6 +1416,7 @@ public final class Settings {
|
||||
DIM_SCREEN,
|
||||
SCREEN_OFF_TIMEOUT,
|
||||
SCREEN_BRIGHTNESS,
|
||||
SCREEN_BRIGHTNESS_MODE,
|
||||
VIBRATE_ON,
|
||||
NOTIFICATIONS_USE_RING_VOLUME,
|
||||
MODE_RINGER,
|
||||
|
||||
@@ -40,16 +40,23 @@ public class SettingsHelper {
|
||||
private Context mContext;
|
||||
private AudioManager mAudioManager;
|
||||
private IContentService mContentService;
|
||||
private IPowerManager mPowerManager;
|
||||
private static final String[] PROVIDERS = { "gmail-ls", "calendar", "contacts" };
|
||||
|
||||
private boolean mSilent;
|
||||
private boolean mVibrate;
|
||||
private boolean mHasAutoBrightness;
|
||||
|
||||
public SettingsHelper(Context context) {
|
||||
mContext = context;
|
||||
mAudioManager = (AudioManager) context
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
mContentService = ContentResolver.getContentService();
|
||||
mPowerManager = IPowerManager.Stub.asInterface(
|
||||
ServiceManager.getService("power"));
|
||||
|
||||
mHasAutoBrightness = context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_automatic_brightness_available);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,6 +71,18 @@ public class SettingsHelper {
|
||||
public boolean restoreValue(String name, String value) {
|
||||
if (Settings.System.SCREEN_BRIGHTNESS.equals(name)) {
|
||||
setBrightness(Integer.parseInt(value));
|
||||
} else if (Settings.System.SCREEN_BRIGHTNESS_MODE.equals(name)) {
|
||||
if (mHasAutoBrightness) {
|
||||
// When setting auto-brightness, must reset the brightness afterwards
|
||||
try {
|
||||
int curBrightness = Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.SCREEN_BRIGHTNESS);
|
||||
setAutoBrightness(Integer.parseInt(value) != 0);
|
||||
setBrightness(curBrightness);
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
// no brightness setting at all? weird. skip this then.
|
||||
}
|
||||
}
|
||||
} else if (Settings.System.SOUND_EFFECTS_ENABLED.equals(name)) {
|
||||
setSoundEffects(Integer.parseInt(value) == 1);
|
||||
} else if (Settings.Secure.LOCATION_PROVIDERS_ALLOWED.equals(name)) {
|
||||
@@ -73,6 +92,16 @@ public class SettingsHelper {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setAutoBrightness(boolean value) {
|
||||
if (mPowerManager != null) {
|
||||
try {
|
||||
mPowerManager.setAutoBrightness(value);
|
||||
} catch (RemoteException e) {
|
||||
// unable to reach the power manager; skip
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setGpsLocation(String value) {
|
||||
final String GPS = LocationManager.GPS_PROVIDER;
|
||||
boolean enabled =
|
||||
|
||||
Reference in New Issue
Block a user