diff options
author | Roshan Pius <rpius@google.com> | 2020-01-08 12:18:31 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2020-01-08 12:23:26 -0800 |
commit | d176767af2c5baf8d8187f642fda226dd945e64f (patch) | |
tree | 2d6d6c2a79415bdf3db3793790cbc8b4b55f7dea /service | |
parent | 929e6e1536ba7f7cff8551a06a89e1b903fce1c6 (diff) |
WifiShellCommand: Avoid @hide ServiceManager.getService call
The WifiShellcommand is already processing commands from within wifi
service context. There is no need to retrieve the raw IWifiManager
service to make calls into WifiService. Instead, pass in the instance of
WifiServiceImpl into WifiShellCommand for invoking the necessary API
calls.
Bug: 147344816
Test: "adb shell cmd wifi set-wifi-enabled enabled"
Test: "adb shell cmd wifi set-wifi-enabled disabled"
Test: make com.android.wifi & ensured that the
ServiceManager.getService() @hide API's from WifiShellCommand
no longer show up in appcompat analysis.
Change-Id: I993911cac44597b093f3277e9145ec44c9bbbf9e
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 2 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiShellCommand.java | 18 |
2 files changed, 7 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index e8fae501b..afd0291fd 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -2843,7 +2843,7 @@ public class WifiServiceImpl extends BaseWifiService { public int handleShellCommand(@NonNull ParcelFileDescriptor in, @NonNull ParcelFileDescriptor out, @NonNull ParcelFileDescriptor err, @NonNull String[] args) { - return new WifiShellCommand(mWifiInjector).exec( + return new WifiShellCommand(mWifiInjector, this).exec( this, in.getFileDescriptor(), out.getFileDescriptor(), err.getFileDescriptor(), args); } diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java index afbcba3c5..da207b561 100644 --- a/service/java/com/android/server/wifi/WifiShellCommand.java +++ b/service/java/com/android/server/wifi/WifiShellCommand.java @@ -16,14 +16,11 @@ package com.android.server.wifi; -import android.content.Context; -import android.net.wifi.IWifiManager; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiScanner; import android.net.wifi.wificond.WifiCondManager; import android.os.BasicShellCommandHandler; import android.os.Binder; -import android.os.ServiceManager; import com.android.server.wifi.util.ApConfigUtil; @@ -55,8 +52,9 @@ public class WifiShellCommand extends BasicShellCommandHandler { private final HostapdHal mHostapdHal; private final WifiCountryCode mWifiCountryCode; private final WifiLastResortWatchdog mWifiLastResortWatchdog; + private final WifiServiceImpl mWifiService; - WifiShellCommand(WifiInjector wifiInjector) { + WifiShellCommand(WifiInjector wifiInjector, WifiServiceImpl wifiService) { mClientModeImpl = wifiInjector.getClientModeImpl(); mWifiLockManager = wifiInjector.getWifiLockManager(); mWifiNetworkSuggestionsManager = wifiInjector.getWifiNetworkSuggestionsManager(); @@ -65,6 +63,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { mWifiNative = wifiInjector.getWifiNative(); mWifiCountryCode = wifiInjector.getWifiCountryCode(); mWifiLastResortWatchdog = wifiInjector.getWifiLastResortWatchdog(); + mWifiService = wifiService; } @Override @@ -214,13 +213,10 @@ public class WifiShellCommand extends BasicShellCommandHandler { return -1; } - // validate that device support this band - IWifiManager wifiManager = IWifiManager.Stub.asInterface( - ServiceManager.getService(Context.WIFI_SERVICE)); if ((band == SoftApConfiguration.BAND_5GHZ - && !wifiManager.is5GHzBandSupported()) + && !mWifiService.is5GHzBandSupported()) || (band == SoftApConfiguration.BAND_6GHZ - && !wifiManager.is6GHzBandSupported())) { + && !mWifiService.is6GHzBandSupported())) { pw.println("Invalid argument to 'force-softap-channel enabled' " + "- channel band is not supported by the device"); return -1; @@ -305,9 +301,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { + " or 'disabled'"); return -1; } - IWifiManager wifiManager = IWifiManager.Stub.asInterface( - ServiceManager.getService(Context.WIFI_SERVICE)); - wifiManager.setWifiEnabled("com.android.shell", enabled); + mWifiService.setWifiEnabled("com.android.shell", enabled); return 0; } default: |