Use WM APIs to change rotation preference.
Bug: 5371750 Changing the system setting directly results in inconsistent behavior among the three different places where "auto-rotate" settings appear in the UI. Use the WM APIs instead. Change-Id: I1a8239af66b1cc3aeec8310383e72fc96c878d73
This commit is contained in:
@@ -28,6 +28,7 @@ import android.database.ContentObserver;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
@@ -35,6 +36,8 @@ import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.SettingNotFoundException;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.Surface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -230,9 +233,17 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||
if (preference == mAccelerometer) {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.ACCELEROMETER_ROTATION,
|
||||
mAccelerometer.isChecked() ? 1 : 0);
|
||||
try {
|
||||
IWindowManager wm = IWindowManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.WINDOW_SERVICE));
|
||||
if (mAccelerometer.isChecked()) {
|
||||
wm.thawRotation();
|
||||
} else {
|
||||
wm.freezeRotation(Surface.ROTATION_0);
|
||||
}
|
||||
} catch (RemoteException exc) {
|
||||
Log.w(TAG, "Unable to save auto-rotate setting");
|
||||
}
|
||||
} else if (preference == mNotificationPulse) {
|
||||
boolean value = mNotificationPulse.isChecked();
|
||||
Settings.System.putInt(getContentResolver(), Settings.System.NOTIFICATION_LIGHT_PULSE,
|
||||
|
Reference in New Issue
Block a user