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

Commit 37edbd33 authored by Weng Su's avatar Weng Su
Browse files

Remove redundant WiFi tethering listener

- WiFi tethering settings currently listeners two sets of WiFi tethering
  state from framework at the same time, There is a timing issue when
  the deprecated callback is sent earlier than the available callback,
  it will cause WiFi tethering settings to start tethering twice in a
  short period of time, causing the WiFi framework to respond with a
  startup error.

- Remove redundant obsolete WiFi tethering state listener to avoid
  WiFi tethering startup error.

Bug: 227719584
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherSettingsTest

Change-Id: I59cb5222acb763f630fb621250d7740a240bbd92
parent 3ed73b7b
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.settings.wifi.tether;

import static android.net.TetheringManager.ACTION_TETHER_STATE_CHANGED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_CHANGED_ACTION;

import android.app.settings.SettingsEnums;
@@ -32,7 +31,6 @@ import android.util.FeatureFlagUtils;
import android.util.Log;

import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceGroup;

import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -79,8 +77,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
    TetherChangeReceiver mTetherChangeReceiver;

    static {
        TETHER_STATE_CHANGE_FILTER = new IntentFilter(ACTION_TETHER_STATE_CHANGED);
        TETHER_STATE_CHANGE_FILTER.addAction(WIFI_AP_STATE_CHANGED_ACTION);
        TETHER_STATE_CHANGE_FILTER = new IntentFilter(WIFI_AP_STATE_CHANGED_ACTION);
    }

    public WifiTetherSettings() {
@@ -269,12 +266,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
            String action = intent.getAction();
            Log.d(TAG, "updating display config due to receiving broadcast action " + action);
            updateDisplayWithNewConfig();
            if (action.equals(ACTION_TETHER_STATE_CHANGED)) {
                if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED
                        && mRestartWifiApAfterConfigChange) {
                    startTether();
                }
            } else if (action.equals(WIFI_AP_STATE_CHANGED_ACTION)) {
            if (action.equals(WIFI_AP_STATE_CHANGED_ACTION)) {
                int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_AP_STATE, 0);
                if (state == WifiManager.WIFI_AP_STATE_DISABLED
                        && mRestartWifiApAfterConfigChange) {