Merge "Don't allow airplane mode to affect location status icon. Gps still operates when airplane mode is on, and consumes just as much power so the icon shouldn't be hidden." into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2163bb0924
@@ -53,7 +53,6 @@ public class LocationController extends BroadcastReceiver {
|
|||||||
private StatusBarManager mStatusBarManager;
|
private StatusBarManager mStatusBarManager;
|
||||||
|
|
||||||
private boolean mAreActiveLocationRequests;
|
private boolean mAreActiveLocationRequests;
|
||||||
private boolean mIsAirplaneMode;
|
|
||||||
|
|
||||||
private ArrayList<LocationSettingsChangeCallback> mSettingsChangeCallbacks =
|
private ArrayList<LocationSettingsChangeCallback> mSettingsChangeCallbacks =
|
||||||
new ArrayList<LocationSettingsChangeCallback>();
|
new ArrayList<LocationSettingsChangeCallback>();
|
||||||
@@ -76,9 +75,6 @@ public class LocationController extends BroadcastReceiver {
|
|||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION);
|
filter.addAction(LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION);
|
||||||
// Listen for a change in the airplane mode setting so we can defensively turn off the
|
|
||||||
// high power location icon when radios are disabled.
|
|
||||||
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
|
||||||
context.registerReceiver(this, filter);
|
context.registerReceiver(this, filter);
|
||||||
|
|
||||||
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||||
@@ -100,7 +96,6 @@ public class LocationController extends BroadcastReceiver {
|
|||||||
|
|
||||||
// Examine the current location state and initialize the status view.
|
// Examine the current location state and initialize the status view.
|
||||||
updateActiveLocationRequests();
|
updateActiveLocationRequests();
|
||||||
updateAirplaneMode();
|
|
||||||
refreshViews();
|
refreshViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,11 +165,9 @@ public class LocationController extends BroadcastReceiver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the status view based on the current state of location requests and airplane mode.
|
// Updates the status view based on the current state of location requests.
|
||||||
private void refreshViews() {
|
private void refreshViews() {
|
||||||
// The airplane mode check is defensive - there shouldn't be any active high power
|
if (mAreActiveLocationRequests) {
|
||||||
// location requests when airplane mode is on.
|
|
||||||
if (!mIsAirplaneMode && mAreActiveLocationRequests) {
|
|
||||||
mStatusBarManager.setIcon(LOCATION_STATUS_ICON_PLACEHOLDER, LOCATION_STATUS_ICON_ID, 0,
|
mStatusBarManager.setIcon(LOCATION_STATUS_ICON_PLACEHOLDER, LOCATION_STATUS_ICON_ID, 0,
|
||||||
mContext.getString(R.string.accessibility_location_active));
|
mContext.getString(R.string.accessibility_location_active));
|
||||||
} else {
|
} else {
|
||||||
@@ -191,25 +184,11 @@ public class LocationController extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads the airplane mode setting and updates the status view if necessary.
|
|
||||||
private void updateAirplaneMode() {
|
|
||||||
boolean wasAirplaneMode = mIsAirplaneMode;
|
|
||||||
// TODO This probably warrants a utility method in Settings.java.
|
|
||||||
mIsAirplaneMode = (Settings.Global.getInt(
|
|
||||||
mContext.getContentResolver(),
|
|
||||||
Settings.Global.AIRPLANE_MODE_ON, 0) == 1);
|
|
||||||
if (mIsAirplaneMode != wasAirplaneMode) {
|
|
||||||
refreshViews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION.equals(action)) {
|
if (LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION.equals(action)) {
|
||||||
updateActiveLocationRequests();
|
updateActiveLocationRequests();
|
||||||
} else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
|
|
||||||
updateAirplaneMode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user