Merge "Fix tethering summary when airplane mode is off" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-05-18 00:49:50 +00:00
committed by Android (Google) Code Review
2 changed files with 24 additions and 2 deletions

View File

@@ -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);
}
}
//