am 4e2eb658: Merge "Update airplane-mode manipulation for the new Settings namespace" into jb-mr1-dev
* commit '4e2eb6581f8ee91166cbfd80b531f628dedab89a': Update airplane-mode manipulation for the new Settings namespace
This commit is contained in:
@@ -36,6 +36,7 @@ import android.os.Message;
|
|||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -696,12 +697,12 @@ public class ConnectivityManagerTestActivity extends Activity {
|
|||||||
*/
|
*/
|
||||||
public void setAirplaneMode(Context context, boolean enableAM) {
|
public void setAirplaneMode(Context context, boolean enableAM) {
|
||||||
//set the airplane mode
|
//set the airplane mode
|
||||||
Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
|
Settings.Global.putInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON,
|
||||||
enableAM ? 1 : 0);
|
enableAM ? 1 : 0);
|
||||||
// Post the intent
|
// Post the intent
|
||||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
intent.putExtra("state", enableAM);
|
intent.putExtra("state", enableAM);
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String convertToQuotedString(String string) {
|
protected static String convertToQuotedString(String string) {
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ public class ConnectivityManagerMobileTest extends
|
|||||||
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "CMWakeLock");
|
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "CMWakeLock");
|
||||||
wl.acquire();
|
wl.acquire();
|
||||||
// Each test case will start with cellular connection
|
// Each test case will start with cellular connection
|
||||||
if (Settings.System.getInt(getInstrumentation().getContext().getContentResolver(),
|
if (Settings.Global.getInt(getInstrumentation().getContext().getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON) == 1) {
|
Settings.Global.AIRPLANE_MODE_ON) == 1) {
|
||||||
log("airplane is not disabled, disable it.");
|
log("airplane is not disabled, disable it.");
|
||||||
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
|
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
|
||||||
}
|
}
|
||||||
@@ -84,8 +84,8 @@ public class ConnectivityManagerMobileTest extends
|
|||||||
wl.release();
|
wl.release();
|
||||||
cmActivity.removeConfiguredNetworksAndDisableWifi();
|
cmActivity.removeConfiguredNetworksAndDisableWifi();
|
||||||
// if airplane mode is set, disable it.
|
// if airplane mode is set, disable it.
|
||||||
if (Settings.System.getInt(getInstrumentation().getContext().getContentResolver(),
|
if (Settings.Global.getInt(getInstrumentation().getContext().getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON) == 1) {
|
Settings.Global.AIRPLANE_MODE_ON) == 1) {
|
||||||
log("disable airplane mode if it is enabled");
|
log("disable airplane mode if it is enabled");
|
||||||
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
|
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.net.Uri;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.os.ParcelFileDescriptor.AutoCloseInputStream;
|
import android.os.ParcelFileDescriptor.AutoCloseInputStream;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -553,7 +554,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
|
|||||||
int state = enable ? 1 : 0;
|
int state = enable ? 1 : 0;
|
||||||
|
|
||||||
// Change the system setting
|
// Change the system setting
|
||||||
Settings.System.putInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
|
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON,
|
||||||
state);
|
state);
|
||||||
|
|
||||||
String timeoutMessage = "Timed out waiting for airplane mode to be " +
|
String timeoutMessage = "Timed out waiting for airplane mode to be " +
|
||||||
@@ -561,8 +562,8 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
|
|||||||
|
|
||||||
// wait for airplane mode to change state
|
// wait for airplane mode to change state
|
||||||
int currentWaitTime = 0;
|
int currentWaitTime = 0;
|
||||||
while (Settings.System.getInt(mContext.getContentResolver(),
|
while (Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON, -1) != state) {
|
Settings.Global.AIRPLANE_MODE_ON, -1) != state) {
|
||||||
timeoutWait(currentWaitTime, DEFAULT_WAIT_POLL_TIME, DEFAULT_MAX_WAIT_TIME,
|
timeoutWait(currentWaitTime, DEFAULT_WAIT_POLL_TIME, DEFAULT_MAX_WAIT_TIME,
|
||||||
timeoutMessage);
|
timeoutMessage);
|
||||||
}
|
}
|
||||||
@@ -570,7 +571,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
|
|||||||
// Post the intent
|
// Post the intent
|
||||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
intent.putExtra("state", true);
|
intent.putExtra("state", true);
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import android.hardware.display.DisplayManager;
|
|||||||
import android.hardware.display.WifiDisplay;
|
import android.hardware.display.WifiDisplay;
|
||||||
import android.hardware.display.WifiDisplayStatus;
|
import android.hardware.display.WifiDisplayStatus;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -147,7 +148,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
|
|||||||
// TODO: Sets the view to be "awaiting" if not already awaiting
|
// TODO: Sets the view to be "awaiting" if not already awaiting
|
||||||
|
|
||||||
// Change the system setting
|
// Change the system setting
|
||||||
Settings.System.putInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
|
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON,
|
||||||
enabled ? 1 : 0);
|
enabled ? 1 : 0);
|
||||||
|
|
||||||
// TODO: Update the UI to reflect system setting
|
// TODO: Update the UI to reflect system setting
|
||||||
@@ -156,7 +157,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
|
|||||||
// Post the intent
|
// Post the intent
|
||||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
intent.putExtra("state", enabled);
|
intent.putExtra("state", enabled);
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||||
}
|
}
|
||||||
// NetworkSignalChanged callback
|
// NetworkSignalChanged callback
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class AirplaneModeController extends BroadcastReceiver
|
|||||||
|
|
||||||
private boolean getAirplaneMode() {
|
private boolean getAirplaneMode() {
|
||||||
ContentResolver cr = mContext.getContentResolver();
|
ContentResolver cr = mContext.getContentResolver();
|
||||||
return 0 != Settings.System.getInt(cr, Settings.System.AIRPLANE_MODE_ON, 0);
|
return 0 != Settings.Global.getInt(cr, Settings.Global.AIRPLANE_MODE_ON, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this racy API by adding something better to TelephonyManager or
|
// TODO: Fix this racy API by adding something better to TelephonyManager or
|
||||||
@@ -82,9 +82,9 @@ public class AirplaneModeController extends BroadcastReceiver
|
|||||||
private void unsafe(final boolean enabled) {
|
private void unsafe(final boolean enabled) {
|
||||||
AsyncTask.execute(new Runnable() {
|
AsyncTask.execute(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Settings.System.putInt(
|
Settings.Global.putInt(
|
||||||
mContext.getContentResolver(),
|
mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON,
|
Settings.Global.AIRPLANE_MODE_ON,
|
||||||
enabled ? 1 : 0);
|
enabled ? 1 : 0);
|
||||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
||||||
|
|||||||
@@ -509,8 +509,8 @@ public class NetworkController extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAirplaneMode() {
|
private void updateAirplaneMode() {
|
||||||
mAirplaneMode = (Settings.System.getInt(mContext.getContentResolver(),
|
mAirplaneMode = (Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON, 0) == 1);
|
Settings.Global.AIRPLANE_MODE_ON, 0) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void updateTelephonySignalStrength() {
|
private final void updateTelephonySignalStrength() {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
|
|||||||
context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
|
mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
|
||||||
mContext.getContentResolver().registerContentObserver(
|
mContext.getContentResolver().registerContentObserver(
|
||||||
Settings.System.getUriFor(Settings.System.AIRPLANE_MODE_ON), true,
|
Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true,
|
||||||
mAirplaneModeObserver);
|
mAirplaneModeObserver);
|
||||||
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
mHasVibrator = vibrator != null && vibrator.hasVibrator();
|
mHasVibrator = vibrator != null && vibrator.hasVibrator();
|
||||||
@@ -849,9 +849,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
|
|||||||
// Let the service state callbacks handle the state.
|
// Let the service state callbacks handle the state.
|
||||||
if (mHasTelephony) return;
|
if (mHasTelephony) return;
|
||||||
|
|
||||||
boolean airplaneModeOn = Settings.System.getInt(
|
boolean airplaneModeOn = Settings.Global.getInt(
|
||||||
mContext.getContentResolver(),
|
mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON,
|
Settings.Global.AIRPLANE_MODE_ON,
|
||||||
0) == 1;
|
0) == 1;
|
||||||
mAirplaneState = airplaneModeOn ? ToggleAction.State.On : ToggleAction.State.Off;
|
mAirplaneState = airplaneModeOn ? ToggleAction.State.On : ToggleAction.State.Off;
|
||||||
mAirplaneModeOn.updateState(mAirplaneState);
|
mAirplaneModeOn.updateState(mAirplaneState);
|
||||||
@@ -861,9 +861,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
|
|||||||
* Change the airplane mode system setting
|
* Change the airplane mode system setting
|
||||||
*/
|
*/
|
||||||
private void changeAirplaneModeSystemSetting(boolean on) {
|
private void changeAirplaneModeSystemSetting(boolean on) {
|
||||||
Settings.System.putInt(
|
Settings.Global.putInt(
|
||||||
mContext.getContentResolver(),
|
mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON,
|
Settings.Global.AIRPLANE_MODE_ON,
|
||||||
on ? 1 : 0);
|
on ? 1 : 0);
|
||||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
||||||
|
|||||||
@@ -75,12 +75,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
|
|
||||||
private void registerForAirplaneMode(IntentFilter filter) {
|
private void registerForAirplaneMode(IntentFilter filter) {
|
||||||
final ContentResolver resolver = mContext.getContentResolver();
|
final ContentResolver resolver = mContext.getContentResolver();
|
||||||
final String airplaneModeRadios = Settings.System.getString(resolver,
|
final String airplaneModeRadios = Settings.Global.getString(resolver,
|
||||||
Settings.System.AIRPLANE_MODE_RADIOS);
|
Settings.Global.AIRPLANE_MODE_RADIOS);
|
||||||
final String toggleableRadios = Settings.System.getString(resolver,
|
final String toggleableRadios = Settings.Global.getString(resolver,
|
||||||
Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
|
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
|
||||||
boolean mIsAirplaneSensitive = airplaneModeRadios == null ? true :
|
boolean mIsAirplaneSensitive = airplaneModeRadios == null ? true :
|
||||||
airplaneModeRadios.contains(Settings.System.RADIO_BLUETOOTH);
|
airplaneModeRadios.contains(Settings.Global.RADIO_BLUETOOTH);
|
||||||
if (mIsAirplaneSensitive) {
|
if (mIsAirplaneSensitive) {
|
||||||
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
}
|
}
|
||||||
@@ -151,8 +151,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
* Returns true if airplane mode is currently on
|
* Returns true if airplane mode is currently on
|
||||||
*/
|
*/
|
||||||
private final boolean isAirplaneModeOn() {
|
private final boolean isAirplaneModeOn() {
|
||||||
return Settings.System.getInt(mContext.getContentResolver(),
|
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON, 0) == 1;
|
Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1179,17 +1179,17 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAirplaneSensitive() {
|
private boolean isAirplaneSensitive() {
|
||||||
String airplaneModeRadios = Settings.System.getString(mContext.getContentResolver(),
|
String airplaneModeRadios = Settings.Global.getString(mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_RADIOS);
|
Settings.Global.AIRPLANE_MODE_RADIOS);
|
||||||
return airplaneModeRadios == null
|
return airplaneModeRadios == null
|
||||||
|| airplaneModeRadios.contains(Settings.System.RADIO_WIFI);
|
|| airplaneModeRadios.contains(Settings.Global.RADIO_WIFI);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAirplaneToggleable() {
|
private boolean isAirplaneToggleable() {
|
||||||
String toggleableRadios = Settings.System.getString(mContext.getContentResolver(),
|
String toggleableRadios = Settings.Global.getString(mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
|
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
|
||||||
return toggleableRadios != null
|
return toggleableRadios != null
|
||||||
&& toggleableRadios.contains(Settings.System.RADIO_WIFI);
|
&& toggleableRadios.contains(Settings.Global.RADIO_WIFI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1198,8 +1198,8 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
* @return {@code true} if airplane mode is on.
|
* @return {@code true} if airplane mode is on.
|
||||||
*/
|
*/
|
||||||
private boolean isAirplaneModeOn() {
|
private boolean isAirplaneModeOn() {
|
||||||
return isAirplaneSensitive() && Settings.System.getInt(mContext.getContentResolver(),
|
return isAirplaneSensitive() && Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
Settings.System.AIRPLANE_MODE_ON, 0) == 1;
|
Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1213,8 +1213,8 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
}
|
}
|
||||||
pw.println("Wi-Fi is " + mWifiStateMachine.syncGetWifiStateByName());
|
pw.println("Wi-Fi is " + mWifiStateMachine.syncGetWifiStateByName());
|
||||||
pw.println("Stay-awake conditions: " +
|
pw.println("Stay-awake conditions: " +
|
||||||
Settings.System.getInt(mContext.getContentResolver(),
|
Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0));
|
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0));
|
||||||
pw.println();
|
pw.println();
|
||||||
|
|
||||||
pw.println("Internal state:");
|
pw.println("Internal state:");
|
||||||
|
|||||||
@@ -384,8 +384,8 @@ public class ComprehensiveCountryDetector extends CountryDetectorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAirplaneModeOff() {
|
protected boolean isAirplaneModeOff() {
|
||||||
return Settings.System.getInt(
|
return Settings.Global.getInt(
|
||||||
mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 0;
|
mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user