WifiController: remove wifi inactive code

Wifi no longer will enter an enabled, but inactive, state.  This CL
removes the unused code that creates the inactive states, checks for
transitions and the code to get settings values related to wifi
idle/inactive.

A follow-on CL will merge the DeviceActiveState in to StaEnabledState.

Bug: 71513253
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: wifi integration tests
Change-Id: Ie357987d47a055c0ed031ffba942658b2e723de4
diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java
index dc98595..9074bcd 100644
--- a/service/java/com/android/server/wifi/WifiController.java
+++ b/service/java/com/android/server/wifi/WifiController.java
@@ -16,36 +16,23 @@
 
 package com.android.server.wifi;
 
-import static android.net.wifi.WifiManager.WIFI_MODE_FULL;
-import static android.net.wifi.WifiManager.WIFI_MODE_FULL_HIGH_PERF;
-import static android.net.wifi.WifiManager.WIFI_MODE_NO_LOCKS_HELD;
-import static android.net.wifi.WifiManager.WIFI_MODE_SCAN_ONLY;
-
-import android.app.AlarmManager;
-import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.database.ContentObserver;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.net.wifi.WifiManager;
-import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 import android.os.SystemClock;
 import android.os.WorkSource;
 import android.provider.Settings;
-import android.util.Slog;
 
 import com.android.internal.util.Protocol;
 import com.android.internal.util.State;
 import com.android.internal.util.StateMachine;
 
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-
 /**
  * WifiController is the class used to manage on/off state of WifiStateMachine for various operating
  * modes (normal, airplane, wifi hotspot, etc.).
@@ -54,27 +41,8 @@
     private static final String TAG = "WifiController";
     private static final boolean DBG = false;
     private Context mContext;
-    private boolean mScreenOff;
-    private boolean mDeviceIdle;
-    private int mPluggedType;
-    private int mStayAwakeConditions;
-    private long mIdleMillis;
-    private int mSleepPolicy;
     private boolean mFirstUserSignOnSeen = false;
 
-    private AlarmManager mAlarmManager;
-    private PendingIntent mIdleIntent;
-    private static final int IDLE_REQUEST = 0;
-
-    /**
-     * See {@link Settings.Global#WIFI_IDLE_MS}. This is the default value if a
-     * Settings.Global value is not present. This timeout value is chosen as
-     * the approximate point at which the battery drain caused by Wi-Fi
-     * being enabled but not active exceeds the battery drain caused by
-     * re-establishing a connection to the mobile data network.
-     */
-    private static final long DEFAULT_IDLE_MS = 15 * 60 * 1000; /* 15 minutes */
-
     /**
      * See {@link Settings.Global#WIFI_REENABLE_DELAY_MS}.  This is the default value if a
      * Settings.Global value is not present.  This is the minimum time after wifi is disabled
@@ -83,19 +51,15 @@
     private static final long DEFAULT_REENABLE_DELAY_MS = 500;
 
     // finding that delayed messages can sometimes be delivered earlier than expected
-    // probably rounding errors..  add a margin to prevent problems
+    // probably rounding errors.  add a margin to prevent problems
     private static final long DEFER_MARGIN_MS = 5;
 
     NetworkInfo mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, "WIFI", "");
 
-    private static final String ACTION_DEVICE_IDLE =
-            "com.android.server.WifiManager.action.DEVICE_IDLE";
-
     /* References to values tracked in WifiService */
     private final WifiStateMachine mWifiStateMachine;
     private final WifiStateMachinePrime mWifiStateMachinePrime;
     private final WifiSettingsStore mSettingsStore;
-    private final WifiLockManager mWifiLockManager;
 
     /**
      * Temporary for computing UIDS that are responsible for starting WIFI.
@@ -110,11 +74,6 @@
     private static final int BASE = Protocol.BASE_WIFI_CONTROLLER;
 
     static final int CMD_EMERGENCY_MODE_CHANGED        = BASE + 1;
-    static final int CMD_SCREEN_ON                     = BASE + 2;
-    static final int CMD_SCREEN_OFF                    = BASE + 3;
-    static final int CMD_BATTERY_CHANGED               = BASE + 4;
-    static final int CMD_DEVICE_IDLE                   = BASE + 5;
-    static final int CMD_LOCKS_CHANGED                 = BASE + 6;
     static final int CMD_SCAN_ALWAYS_MODE_CHANGED      = BASE + 7;
     static final int CMD_WIFI_TOGGLED                  = BASE + 8;
     static final int CMD_AIRPLANE_TOGGLED              = BASE + 9;
@@ -136,37 +95,21 @@
     private StaDisabledWithScanState mStaDisabledWithScanState = new StaDisabledWithScanState();
     private ApEnabledState mApEnabledState = new ApEnabledState();
     private DeviceActiveState mDeviceActiveState = new DeviceActiveState();
-    private DeviceInactiveState mDeviceInactiveState = new DeviceInactiveState();
-    private ScanOnlyLockHeldState mScanOnlyLockHeldState = new ScanOnlyLockHeldState();
-    private FullLockHeldState mFullLockHeldState = new FullLockHeldState();
-    private FullHighPerfLockHeldState mFullHighPerfLockHeldState = new FullHighPerfLockHeldState();
-    private NoLockHeldState mNoLockHeldState = new NoLockHeldState();
     private EcmState mEcmState = new EcmState();
 
     WifiController(Context context, WifiStateMachine wsm, WifiSettingsStore wss,
-            WifiLockManager wifiLockManager, Looper looper, FrameworkFacade f,
-            WifiStateMachinePrime wsmp) {
+            Looper looper, FrameworkFacade f, WifiStateMachinePrime wsmp) {
         super(TAG, looper);
         mFacade = f;
         mContext = context;
         mWifiStateMachine = wsm;
         mWifiStateMachinePrime = wsmp;
         mSettingsStore = wss;
-        mWifiLockManager = wifiLockManager;
-
-        mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
-        Intent idleIntent = new Intent(ACTION_DEVICE_IDLE, null);
-        mIdleIntent = mFacade.getBroadcast(mContext, IDLE_REQUEST, idleIntent, 0);
 
         addState(mDefaultState);
             addState(mApStaDisabledState, mDefaultState);
             addState(mStaEnabledState, mDefaultState);
                 addState(mDeviceActiveState, mStaEnabledState);
-                addState(mDeviceInactiveState, mStaEnabledState);
-                    addState(mScanOnlyLockHeldState, mDeviceInactiveState);
-                    addState(mFullLockHeldState, mDeviceInactiveState);
-                    addState(mFullHighPerfLockHeldState, mDeviceInactiveState);
-                    addState(mNoLockHeldState, mDeviceInactiveState);
             addState(mStaDisabledWithScanState, mDefaultState);
             addState(mApEnabledState, mDefaultState);
             addState(mEcmState, mDefaultState);
@@ -189,7 +132,6 @@
         setLogOnlyTransitions(false);
 
         IntentFilter filter = new IntentFilter();
-        filter.addAction(ACTION_DEVICE_IDLE);
         filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
         filter.addAction(WifiManager.WIFI_AP_STATE_CHANGED_ACTION);
         filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
@@ -198,9 +140,7 @@
                     @Override
                     public void onReceive(Context context, Intent intent) {
                         String action = intent.getAction();
-                        if (action.equals(ACTION_DEVICE_IDLE)) {
-                            sendMessage(CMD_DEVICE_IDLE);
-                        } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
+                        if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
                             mNetworkInfo = (NetworkInfo) intent.getParcelableExtra(
                                     WifiManager.EXTRA_NETWORK_INFO);
                         } else if (action.equals(WifiManager.WIFI_AP_STATE_CHANGED_ACTION)) {
@@ -226,127 +166,16 @@
                 },
                 new IntentFilter(filter));
 
-        initializeAndRegisterForSettingsChange(looper);
-    }
-
-    private void initializeAndRegisterForSettingsChange(Looper looper) {
-        Handler handler = new Handler(looper);
-        readStayAwakeConditions();
-        registerForStayAwakeModeChange(handler);
-        readWifiIdleTime();
-        registerForWifiIdleTimeChange(handler);
-        readWifiSleepPolicy();
-        registerForWifiSleepPolicyChange(handler);
         readWifiReEnableDelay();
     }
 
-    private void readStayAwakeConditions() {
-        mStayAwakeConditions = mFacade.getIntegerSetting(mContext,
-                Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
-    }
-
-    private void readWifiIdleTime() {
-        mIdleMillis = mFacade.getLongSetting(mContext,
-                Settings.Global.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
-    }
-
-    private void readWifiSleepPolicy() {
-        // This should always set to default value because the settings menu to toggle this
-        // has been removed now.
-        mSleepPolicy = Settings.Global.WIFI_SLEEP_POLICY_NEVER;
-    }
-
     private void readWifiReEnableDelay() {
         mReEnableDelayMillis = mFacade.getLongSetting(mContext,
                 Settings.Global.WIFI_REENABLE_DELAY_MS, DEFAULT_REENABLE_DELAY_MS);
     }
 
-    /**
-     * Observes settings changes to scan always mode.
-     */
-    private void registerForStayAwakeModeChange(Handler handler) {
-        ContentObserver contentObserver = new ContentObserver(handler) {
-            @Override
-            public void onChange(boolean selfChange) {
-                readStayAwakeConditions();
-            }
-        };
-
-        mFacade.registerContentObserver(mContext,
-                Settings.Global.getUriFor(Settings.Global.STAY_ON_WHILE_PLUGGED_IN), false,
-                contentObserver);
-    }
-
-    /**
-     * Observes settings changes to wifi idle time.
-     */
-    private void registerForWifiIdleTimeChange(Handler handler) {
-        ContentObserver contentObserver = new ContentObserver(handler) {
-            @Override
-            public void onChange(boolean selfChange) {
-                readWifiIdleTime();
-            }
-        };
-
-        mFacade.registerContentObserver(mContext,
-                Settings.Global.getUriFor(Settings.Global.WIFI_IDLE_MS), false, contentObserver);
-    }
-
-    /**
-     * Observes changes to wifi sleep policy
-     */
-    private void registerForWifiSleepPolicyChange(Handler handler) {
-        ContentObserver contentObserver = new ContentObserver(handler) {
-            @Override
-            public void onChange(boolean selfChange) {
-                readWifiSleepPolicy();
-            }
-        };
-        mFacade.registerContentObserver(mContext,
-                Settings.Global.getUriFor(Settings.Global.WIFI_SLEEP_POLICY), false,
-                contentObserver);
-    }
-
-    /**
-     * Determines whether the Wi-Fi chipset should stay awake or be put to
-     * sleep. Looks at the setting for the sleep policy and the current
-     * conditions.
-     *
-     * @see #shouldDeviceStayAwake(int)
-     */
-    private boolean shouldWifiStayAwake(int pluggedType) {
-        if (mSleepPolicy == Settings.Global.WIFI_SLEEP_POLICY_NEVER) {
-            // Never sleep
-            return true;
-        } else if ((mSleepPolicy == Settings.Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED) &&
-                (pluggedType != 0)) {
-            // Never sleep while plugged, and we're plugged
-            return true;
-        } else {
-            // Default
-            return shouldDeviceStayAwake(pluggedType);
-        }
-    }
-
-    /**
-     * Determine whether the bit value corresponding to {@code pluggedType} is set in
-     * the bit string mStayAwakeConditions. This determines whether the device should
-     * stay awake based on the current plugged type.
-     *
-     * @param pluggedType the type of plug (USB, AC, or none) for which the check is
-     * being made
-     * @return {@code true} if {@code pluggedType} indicates that the device is
-     * supposed to stay awake, {@code false} otherwise.
-     */
-    private boolean shouldDeviceStayAwake(int pluggedType) {
-        return (mStayAwakeConditions & pluggedType) != 0;
-    }
-
     private void updateBatteryWorkSource() {
         mTmpWorkSource.clear();
-        if (mDeviceIdle) {
-            mTmpWorkSource.add(mWifiLockManager.createMergedWorkSource());
-        }
         mWifiStateMachine.updateBatteryWorkSource(mTmpWorkSource);
     }
 
@@ -354,58 +183,8 @@
         @Override
         public boolean processMessage(Message msg) {
             switch (msg.what) {
-                case CMD_SCREEN_ON:
-                    mAlarmManager.cancel(mIdleIntent);
-                    mScreenOff = false;
-                    mDeviceIdle = false;
-                    updateBatteryWorkSource();
-                    break;
-                case CMD_SCREEN_OFF:
-                    mScreenOff = true;
-                    /*
-                    * Set a timer to put Wi-Fi to sleep, but only if the screen is off
-                    * AND the "stay on while plugged in" setting doesn't match the
-                    * current power conditions (i.e, not plugged in, plugged in to USB,
-                    * or plugged in to AC).
-                    */
-                    if (!shouldWifiStayAwake(mPluggedType)) {
-                        //Delayed shutdown if wifi is connected
-                        if (mNetworkInfo.getDetailedState() ==
-                                NetworkInfo.DetailedState.CONNECTED) {
-                            if (DBG) Slog.d(TAG, "set idle timer: " + mIdleMillis + " ms");
-                            mAlarmManager.set(AlarmManager.RTC_WAKEUP,
-                                    System.currentTimeMillis() + mIdleMillis, mIdleIntent);
-                        } else {
-                            sendMessage(CMD_DEVICE_IDLE);
-                        }
-                    }
-                    break;
-                case CMD_DEVICE_IDLE:
-                    mDeviceIdle = true;
-                    updateBatteryWorkSource();
-                    break;
-                case CMD_BATTERY_CHANGED:
-                    /*
-                    * Set a timer to put Wi-Fi to sleep, but only if the screen is off
-                    * AND we are transitioning from a state in which the device was supposed
-                    * to stay awake to a state in which it is not supposed to stay awake.
-                    * If "stay awake" state is not changing, we do nothing, to avoid resetting
-                    * the already-set timer.
-                    */
-                    int pluggedType = msg.arg1;
-                    if (DBG) Slog.d(TAG, "battery changed pluggedType: " + pluggedType);
-                    if (mScreenOff && shouldWifiStayAwake(mPluggedType) &&
-                            !shouldWifiStayAwake(pluggedType)) {
-                        long triggerTime = System.currentTimeMillis() + mIdleMillis;
-                        if (DBG) Slog.d(TAG, "set idle timer for " + mIdleMillis + "ms");
-                        mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent);
-                    }
-
-                    mPluggedType = pluggedType;
-                    break;
                 case CMD_SET_AP:
                 case CMD_SCAN_ALWAYS_MODE_CHANGED:
-                case CMD_LOCKS_CHANGED:
                 case CMD_WIFI_TOGGLED:
                 case CMD_AIRPLANE_TOGGLED:
                 case CMD_EMERGENCY_MODE_CHANGED:
@@ -459,16 +238,12 @@
                             mHaveDeferredEnable = !mHaveDeferredEnable;
                             break;
                         }
-                        if (mDeviceIdle == false) {
-                            // wifi is toggled, we need to explicitly tell WifiStateMachine that we
-                            // are headed to connect mode before going to the DeviceActiveState
-                            // since that will start supplicant and WifiStateMachine may not know
-                            // what state to head to (it might go to scan mode).
-                            mWifiStateMachine.setOperationalMode(WifiStateMachine.CONNECT_MODE);
-                            transitionTo(mDeviceActiveState);
-                        } else {
-                            checkLocksAndTransitionWhenDeviceIdle();
-                        }
+                        // wifi is toggled, we need to explicitly tell WifiStateMachine that we
+                        // are headed to connect mode before going to the DeviceActiveState
+                        // since that will start supplicant and WifiStateMachine may not know
+                        // what state to head to (it might go to scan mode).
+                        mWifiStateMachine.setOperationalMode(WifiStateMachine.CONNECT_MODE);
+                        transitionTo(mDeviceActiveState);
                     } else if (mSettingsStore.isScanAlwaysAvailable()) {
                         transitionTo(mStaDisabledWithScanState);
                     }
@@ -618,11 +393,7 @@
                             mHaveDeferredEnable = !mHaveDeferredEnable;
                             break;
                         }
-                        if (mDeviceIdle == false) {
-                            transitionTo(mDeviceActiveState);
-                        } else {
-                            checkLocksAndTransitionWhenDeviceIdle();
-                        }
+                        transitionTo(mDeviceActiveState);
                     }
                     break;
                 case CMD_AIRPLANE_TOGGLED:
@@ -744,13 +515,7 @@
                          */
                         mPendingState = getNextWifiState();
                     }
-                    if (mPendingState == mDeviceActiveState && mDeviceIdle) {
-                        checkLocksAndTransitionWhenDeviceIdle();
-                    } else {
-                        // go ahead and transition because we are not idle or we are not going
-                        // to the active state.
-                        transitionTo(mPendingState);
-                    }
+                    transitionTo(mPendingState);
                     break;
                 case CMD_EMERGENCY_CALL_STATE_CHANGED:
                 case CMD_EMERGENCY_MODE_CHANGED:
@@ -822,11 +587,7 @@
 
             if (exitEcm) {
                 if (mSettingsStore.isWifiToggleEnabled()) {
-                    if (mDeviceIdle == false) {
-                        transitionTo(mDeviceActiveState);
-                    } else {
-                        checkLocksAndTransitionWhenDeviceIdle();
-                    }
+                    transitionTo(mDeviceActiveState);
                 } else if (mSettingsStore.isScanAlwaysAvailable()) {
                     transitionTo(mStaDisabledWithScanState);
                 } else {
@@ -846,10 +607,7 @@
 
         @Override
         public boolean processMessage(Message msg) {
-            if (msg.what == CMD_DEVICE_IDLE) {
-                checkLocksAndTransitionWhenDeviceIdle();
-                // We let default state handle the rest of work
-            } else if (msg.what == CMD_USER_PRESENT) {
+            if (msg.what == CMD_USER_PRESENT) {
                 // TLS networks can't connect until user unlocks keystore. KeyStore
                 // unlocks when the user punches PIN after the reboot. So use this
                 // trigger to get those networks connected.
@@ -866,89 +624,4 @@
             return NOT_HANDLED;
         }
     }
-
-    /* Parent: StaEnabledState */
-    class DeviceInactiveState extends State {
-        @Override
-        public boolean processMessage(Message msg) {
-            switch (msg.what) {
-                case CMD_LOCKS_CHANGED:
-                    checkLocksAndTransitionWhenDeviceIdle();
-                    updateBatteryWorkSource();
-                    return HANDLED;
-                case CMD_SCREEN_ON:
-                    transitionTo(mDeviceActiveState);
-                    // More work in default state
-                    return NOT_HANDLED;
-                default:
-                    return NOT_HANDLED;
-            }
-        }
-    }
-
-    /* Parent: DeviceInactiveState. Device is inactive, but an app is holding a scan only lock. */
-    class ScanOnlyLockHeldState extends State {
-        @Override
-        public void enter() {
-            mWifiStateMachine.setOperationalMode(WifiStateMachine.SCAN_ONLY_MODE);
-        }
-    }
-
-    /* Parent: DeviceInactiveState. Device is inactive, but an app is holding a full lock. */
-    class FullLockHeldState extends State {
-        @Override
-        public void enter() {
-            mWifiStateMachine.setOperationalMode(WifiStateMachine.CONNECT_MODE);
-            mWifiStateMachine.setHighPerfModeEnabled(false);
-        }
-    }
-
-    /* Parent: DeviceInactiveState. Device is inactive, but an app is holding a high perf lock. */
-    class FullHighPerfLockHeldState extends State {
-        @Override
-        public void enter() {
-            mWifiStateMachine.setOperationalMode(WifiStateMachine.CONNECT_MODE);
-            mWifiStateMachine.setHighPerfModeEnabled(true);
-        }
-    }
-
-    /* Parent: DeviceInactiveState. Device is inactive and no app is holding a wifi lock. */
-    class NoLockHeldState extends State {
-        @Override
-        public void enter() {
-            mWifiStateMachine.setOperationalMode(WifiStateMachine.DISABLED_MODE);
-        }
-    }
-
-    private void checkLocksAndTransitionWhenDeviceIdle() {
-        switch (mWifiLockManager.getStrongestLockMode()) {
-            case WIFI_MODE_NO_LOCKS_HELD:
-                if (mSettingsStore.isScanAlwaysAvailable()) {
-                    transitionTo(mScanOnlyLockHeldState);
-                } else {
-                    transitionTo(mNoLockHeldState);
-                }
-                break;
-            case WIFI_MODE_FULL:
-                transitionTo(mFullLockHeldState);
-                break;
-            case WIFI_MODE_FULL_HIGH_PERF:
-                transitionTo(mFullHighPerfLockHeldState);
-                break;
-            case WIFI_MODE_SCAN_ONLY:
-                transitionTo(mScanOnlyLockHeldState);
-                break;
-        }
-    }
-
-    @Override
-    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        super.dump(fd, pw, args);
-
-        pw.println("mScreenOff " + mScreenOff);
-        pw.println("mDeviceIdle " + mDeviceIdle);
-        pw.println("mPluggedType " + mPluggedType);
-        pw.println("mIdleMillis " + mIdleMillis);
-        pw.println("mSleepPolicy " + mSleepPolicy);
-    }
 }
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 9cb464f..f33b6f2 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -250,8 +250,7 @@
                 mWifiConfigManager, mWifiConfigStore, this, mFrameworkFacade);
         mLockManager = new WifiLockManager(mContext, BatteryStatsService.getService());
         mWifiController = new WifiController(mContext, mWifiStateMachine, mSettingsStore,
-                mLockManager, mWifiServiceHandlerThread.getLooper(), mFrameworkFacade,
-                mWifiStateMachinePrime);
+                mWifiServiceHandlerThread.getLooper(), mFrameworkFacade, mWifiStateMachinePrime);
         mSelfRecovery = new SelfRecovery(mWifiController, mClock);
         mWifiLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mWifiMetrics);
         mWifiMulticastLockManager = new WifiMulticastLockManager(mWifiStateMachine,
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index e6bea37..a6809d6 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -30,13 +30,9 @@
 
 import static com.android.server.wifi.LocalOnlyHotspotRequestInfo.HOTSPOT_NO_ERROR;
 import static com.android.server.wifi.WifiController.CMD_AIRPLANE_TOGGLED;
-import static com.android.server.wifi.WifiController.CMD_BATTERY_CHANGED;
 import static com.android.server.wifi.WifiController.CMD_EMERGENCY_CALL_STATE_CHANGED;
 import static com.android.server.wifi.WifiController.CMD_EMERGENCY_MODE_CHANGED;
-import static com.android.server.wifi.WifiController.CMD_LOCKS_CHANGED;
 import static com.android.server.wifi.WifiController.CMD_SCAN_ALWAYS_MODE_CHANGED;
-import static com.android.server.wifi.WifiController.CMD_SCREEN_OFF;
-import static com.android.server.wifi.WifiController.CMD_SCREEN_ON;
 import static com.android.server.wifi.WifiController.CMD_SET_AP;
 import static com.android.server.wifi.WifiController.CMD_USER_PRESENT;
 import static com.android.server.wifi.WifiController.CMD_WIFI_TOGGLED;
@@ -2108,15 +2104,8 @@
         @Override
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
-            if (action.equals(Intent.ACTION_SCREEN_ON)) {
-                mWifiController.sendMessage(CMD_SCREEN_ON);
-            } else if (action.equals(Intent.ACTION_USER_PRESENT)) {
+            if (action.equals(Intent.ACTION_USER_PRESENT)) {
                 mWifiController.sendMessage(CMD_USER_PRESENT);
-            } else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
-                mWifiController.sendMessage(CMD_SCREEN_OFF);
-            } else if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
-                int pluggedType = intent.getIntExtra("plugged", 0);
-                mWifiController.sendMessage(CMD_BATTERY_CHANGED, pluggedType, 0, null);
             } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
                 int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,
                         BluetoothAdapter.STATE_DISCONNECTED);
@@ -2225,10 +2214,7 @@
 
     private void registerForBroadcasts() {
         IntentFilter intentFilter = new IntentFilter();
-        intentFilter.addAction(Intent.ACTION_SCREEN_ON);
         intentFilter.addAction(Intent.ACTION_USER_PRESENT);
-        intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
-        intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
         intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
         intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
         intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
@@ -2334,13 +2320,18 @@
         }
     }
 
+    /**
+     * NOTE: WifiLocks do not serve a useful purpose in their current impl and will be removed
+     * (including the methods below).
+     *
+     * TODO: b/71548157
+     */
     @Override
     public boolean acquireWifiLock(IBinder binder, int lockMode, String tag, WorkSource ws) {
         mLog.info("acquireWifiLock uid=% lockMode=%")
                 .c(Binder.getCallingUid())
                 .c(lockMode).flush();
         if (mWifiLockManager.acquireWifiLock(lockMode, tag, binder, ws)) {
-            mWifiController.sendMessage(CMD_LOCKS_CHANGED);
             return true;
         }
         return false;
@@ -2356,7 +2347,6 @@
     public boolean releaseWifiLock(IBinder binder) {
         mLog.info("releaseWifiLock uid=%").c(Binder.getCallingUid()).flush();
         if (mWifiLockManager.releaseWifiLock(binder)) {
-            mWifiController.sendMessage(CMD_LOCKS_CHANGED);
             return true;
         }
         return false;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java
index dc8db1a..f3e9fdd 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiControllerTest.java
@@ -16,26 +16,17 @@
 
 package com.android.server.wifi;
 
-import static android.net.wifi.WifiManager.WIFI_MODE_FULL;
-
 import static com.android.server.wifi.WifiController.CMD_AP_STOPPED;
-import static com.android.server.wifi.WifiController.CMD_DEVICE_IDLE;
 import static com.android.server.wifi.WifiController.CMD_EMERGENCY_CALL_STATE_CHANGED;
 import static com.android.server.wifi.WifiController.CMD_EMERGENCY_MODE_CHANGED;
 import static com.android.server.wifi.WifiController.CMD_RESTART_WIFI;
-import static com.android.server.wifi.WifiController.CMD_SCREEN_ON;
 import static com.android.server.wifi.WifiController.CMD_SET_AP;
 import static com.android.server.wifi.WifiController.CMD_WIFI_TOGGLED;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.*;
 
-import android.app.AlarmManager;
-import android.content.ContentResolver;
 import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.WorkSource;
 import android.os.test.TestLooper;
 import android.test.suitebuilder.annotation.SmallTest;
 import android.util.Log;
@@ -46,7 +37,6 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.ArgumentCaptor;
 import org.mockito.InOrder;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
@@ -54,7 +44,6 @@
 import java.io.ByteArrayOutputStream;
 import java.io.PrintWriter;
 import java.lang.reflect.Method;
-import java.util.List;
 
 /**
  * Test WifiController for changes in and out of ECM and SoftAP modes.
@@ -90,12 +79,6 @@
     @Mock WifiSettingsStore mSettingsStore;
     @Mock WifiStateMachine mWifiStateMachine;
     @Mock WifiStateMachinePrime mWifiStateMachinePrime;
-    @Mock WifiLockManager mWifiLockManager;
-    @Mock ContentResolver mContentResolver;
-
-    ContentObserver mStayAwakeObserver;
-    ContentObserver mWifiIdleTimeObserver;
-    ContentObserver mWifiSleepPolicyObserver;
 
     WifiController mWifiController;
 
@@ -107,22 +90,8 @@
 
         initializeSettingsStore();
 
-        when(mContext.getContentResolver()).thenReturn(mContentResolver);
-        when(mContext.getSystemService(eq(Context.ALARM_SERVICE))).thenReturn(
-                mock(AlarmManager.class));
-        ArgumentCaptor<ContentObserver> observerCaptor =
-                ArgumentCaptor.forClass(ContentObserver.class);
-
         mWifiController = new WifiController(mContext, mWifiStateMachine,
-                mSettingsStore, mWifiLockManager, mLooper.getLooper(), mFacade,
-                mWifiStateMachinePrime);
-        verify(mFacade, times(3)).registerContentObserver(eq(mContext), any(Uri.class), eq(false),
-                observerCaptor.capture());
-
-        List<ContentObserver> observers = observerCaptor.getAllValues();
-        mStayAwakeObserver = observers.get(0);
-        mWifiIdleTimeObserver = observers.get(1);
-        mWifiSleepPolicyObserver = observers.get(2);
+                mSettingsStore, mLooper.getLooper(), mFacade, mWifiStateMachinePrime);
 
         mWifiController.start();
         mLooper.dispatchAll();
@@ -321,68 +290,6 @@
     }
 
     /**
-     * Make sure we handle WorkSources we obtain from WifiLockManager correctly.
-     */
-    @Test
-    public void testWorkSourcesPassedToWifiStateMachine() throws Exception {
-        enableWifi();
-
-        WorkSource workSource = new WorkSource(100);
-        workSource.createWorkChain().addNode(500, "foo");
-
-        // make sure mDeviceIdle is set to true
-        when(mWifiLockManager.getStrongestLockMode()).thenReturn(WIFI_MODE_FULL);
-        when(mWifiLockManager.createMergedWorkSource()).thenReturn(workSource);
-
-        mWifiController.sendMessage(CMD_DEVICE_IDLE);
-        mLooper.dispatchAll();
-        InOrder inOrder = inOrder(mWifiStateMachine);
-        inOrder.verify(mWifiStateMachine).updateBatteryWorkSource(eq(workSource));
-
-        // Now transition back to screen on and make sure the work source is updated again.
-        workSource = new WorkSource(100);
-        when(mWifiLockManager.createMergedWorkSource()).thenReturn(workSource);
-
-        mWifiController.sendMessage(CMD_SCREEN_ON);
-        mLooper.dispatchAll();
-        inOrder = inOrder(mWifiStateMachine);
-        inOrder.verify(mWifiStateMachine).updateBatteryWorkSource(eq(new WorkSource()));
-    }
-
-    /**
-     * When the wifi device is idle, AP mode is enabled and disabled
-     * we should return to the appropriate Idle state.
-     * Enter DeviceActiveState, indicate idle device, activate AP mode, disable AP mode.
-     * <p>
-     * Expected: AP should successfully start and exit, then return to a device idle state.
-     */
-    @Test
-    public void testReturnToDeviceIdleStateAfterAPModeShutdown() throws Exception {
-        enableWifi();
-        assertEquals("DeviceActiveState", getCurrentState().getName());
-
-        // make sure mDeviceIdle is set to true
-        when(mWifiLockManager.getStrongestLockMode()).thenReturn(WIFI_MODE_FULL);
-        when(mWifiLockManager.createMergedWorkSource()).thenReturn(new WorkSource());
-        mWifiController.sendMessage(CMD_DEVICE_IDLE);
-        mLooper.dispatchAll();
-        assertEquals("FullLockHeldState", getCurrentState().getName());
-
-        mWifiController.obtainMessage(CMD_SET_AP, 1, 0).sendToTarget();
-        mLooper.dispatchAll();
-        assertEquals("ApEnabledState", getCurrentState().getName());
-
-        when(mSettingsStore.getWifiSavedState()).thenReturn(1);
-        mWifiController.obtainMessage(CMD_AP_STOPPED).sendToTarget();
-        mLooper.dispatchAll();
-
-        InOrder inOrder = inOrder(mWifiStateMachine);
-        inOrder.verify(mWifiStateMachine).setSupplicantRunning(true);
-        inOrder.verify(mWifiStateMachine).setOperationalMode(WifiStateMachine.CONNECT_MODE);
-        assertEquals("FullLockHeldState", getCurrentState().getName());
-    }
-
-    /**
      * The command to trigger a WiFi reset should not trigger any action by WifiController if we
      * are not in STA mode.
      * WiFi is not in connect mode, so any calls to reset the wifi stack due to connection failures
@@ -398,11 +305,8 @@
         when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false);
         when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(false);
 
-        when(mContext.getContentResolver()).thenReturn(mock(ContentResolver.class));
-
         mWifiController = new WifiController(mContext, mWifiStateMachine,
-                mSettingsStore, mWifiLockManager, mLooper.getLooper(), mFacade,
-                mWifiStateMachinePrime);
+                mSettingsStore, mLooper.getLooper(), mFacade, mWifiStateMachinePrime);
 
         mWifiController.start();
         mLooper.dispatchAll();