Fix tethering summary when airplane mode is off
When airplane mode is off, fall back to default summary (tether off summary). It should be fine because once tether state get updated again, it will go through original listener to update the summary. Change-Id: Iba9b56f452e72365ea964d841ee156a2625c0ae1 Fixes: 79721162 Test: RunSettingsRoboTests
This commit is contained in:
@@ -44,6 +44,7 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
private static final String WIFI_TETHER_SETTINGS = "wifi_tether";
|
||||
private static final IntentFilter AIRPLANE_INTENT_FILTER = new IntentFilter(
|
||||
Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
private static final int ID_NULL = -1;
|
||||
|
||||
private final ConnectivityManager mConnectivityManager;
|
||||
private final String[] mWifiRegexs;
|
||||
@@ -152,7 +153,7 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
|
||||
clearSummaryForAirplaneMode();
|
||||
clearSummaryForAirplaneMode(R.string.wifi_hotspot_off_subtext);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -194,10 +195,16 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
}
|
||||
|
||||
private void clearSummaryForAirplaneMode() {
|
||||
clearSummaryForAirplaneMode(ID_NULL);
|
||||
}
|
||||
|
||||
private void clearSummaryForAirplaneMode(int defaultId) {
|
||||
boolean isAirplaneMode = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
|
||||
if (isAirplaneMode) {
|
||||
mPreference.setSummary(R.string.wifi_tether_disabled_by_airplane);
|
||||
} else if (defaultId != ID_NULL){
|
||||
mPreference.setSummary(defaultId);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
Reference in New Issue
Block a user