Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c538b730 authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android Git Automerger
Browse files

am 8a64b1a7: Handle airplane settings properly

* commit '8a64b1a7':
  Handle airplane settings properly
parents 6f85bdca 8a64b1a7
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -275,9 +275,10 @@ public final class WifiService extends IWifiManager.Stub {
                new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        mSettingsStore.handleAirplaneModeToggled();
                        if (mSettingsStore.handleAirplaneModeToggled()) {
                            updateWifiState();
                        }
                    }
                },
                new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));

@@ -424,7 +425,10 @@ public final class WifiService extends IWifiManager.Stub {

        long ident = Binder.clearCallingIdentity();
        try {
            mSettingsStore.handleWifiToggled(enable);
            if (! mSettingsStore.handleWifiToggled(enable)) {
                // Nothing to do if wifi cannot be toggled
                return true;
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
+16 −5
Original line number Diff line number Diff line
@@ -70,10 +70,14 @@ final class WifiSettingsStore {
       return mAirplaneModeOn;
    }

    synchronized void handleWifiToggled(boolean wifiEnabled) {
        boolean airplaneEnabled = mAirplaneModeOn && isAirplaneToggleable();
    synchronized boolean handleWifiToggled(boolean wifiEnabled) {
        // Can Wi-Fi be toggled in airplane mode ?
        if (mAirplaneModeOn && !isAirplaneToggleable()) {
            return false;
        }

        if (wifiEnabled) {
            if (airplaneEnabled) {
            if (mAirplaneModeOn) {
                persistWifiState(WIFI_ENABLED_AIRPLANE_OVERRIDE);
            } else {
                persistWifiState(WIFI_ENABLED);
@@ -85,9 +89,15 @@ final class WifiSettingsStore {
            // is handled handleAirplaneModeToggled()
            persistWifiState(WIFI_DISABLED);
        }
        return true;
    }

    synchronized boolean handleAirplaneModeToggled() {
        // Is Wi-Fi sensitive to airplane mode changes ?
        if (!isAirplaneSensitive()) {
            return false;
        }

    synchronized void handleAirplaneModeToggled() {
        mAirplaneModeOn = getPersistedAirplaneModeOn();
        if (mAirplaneModeOn) {
            // Wifi disabled due to airplane on
@@ -101,6 +111,7 @@ final class WifiSettingsStore {
                persistWifiState(WIFI_ENABLED);
            }
        }
        return true;
    }

    void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
@@ -161,7 +172,7 @@ final class WifiSettingsStore {
    }

    private boolean getPersistedAirplaneModeOn() {
        return isAirplaneSensitive() && Settings.Global.getInt(mContext.getContentResolver(),
        return Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
    }
}