diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-04-12 22:39:16 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-04-19 16:52:21 +0000 |
commit | 3871ff67f4a6970f1831fc8951392746c9e2bfa2 (patch) | |
tree | 60e3508ad94acbf4ed930a9201179d20984703fc /service | |
parent | bd0447ff06c5719494960e2e3ec95b84941baf2a (diff) |
WifiServiceImpl: setWifiApEnabled unit tests
Add unit tests to cover setWifiApEnabled. This did require a small
change to check a tethering permission and add the user manager.
Bug: 37294233
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I7bdfdcbdfa60605bc2e61f18aa8abeb4bcaf5c56
Merged-In: I77413789b1b2a19c9330f4c9b9978c4a0f5b5bf8
Merged-In: I33ae84d7282dea967a53a644018e20eb2902eca3
Diffstat (limited to 'service')
3 files changed, 16 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index af470eee8..3d444a448 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -237,6 +237,10 @@ public class WifiInjector { return sWifiInjector; } + public UserManager getUserManager() { + return UserManager.get(mContext); + } + public WifiMetrics getWifiMetrics() { return mWifiMetrics; } diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index c6166cdb2..f83923979 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -39,7 +39,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; import android.database.ContentObserver; -import android.net.ConnectivityManager; import android.net.DhcpInfo; import android.net.DhcpResults; import android.net.IpConfiguration; @@ -332,7 +331,7 @@ public class WifiServiceImpl extends IWifiManager.Stub { mFacade = mWifiInjector.getFrameworkFacade(); mWifiMetrics = mWifiInjector.getWifiMetrics(); mTrafficPoller = mWifiInjector.getWifiTrafficPoller(); - mUserManager = UserManager.get(mContext); + mUserManager = mWifiInjector.getUserManager(); mCountryCode = mWifiInjector.getWifiCountryCode(); mWifiStateMachine = mWifiInjector.getWifiStateMachine(); mWifiStateMachine.enableRssiPolling(true); @@ -670,7 +669,7 @@ public class WifiServiceImpl extends IWifiManager.Stub { @Override public void setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) { enforceChangePermission(); - ConnectivityManager.enforceTetherChangePermission(mContext); + mWifiPermissionsUtil.enforceTetherChangePermission(mContext); mLog.trace("setWifiApEnabled uid=% enable=%").c(Binder.getCallingUid()).c(enabled).flush(); diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java index 2010dcfa7..6de39ac3d 100644 --- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java +++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java @@ -21,6 +21,7 @@ import android.app.AppOpsManager; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.UserInfo; +import android.net.ConnectivityManager; import android.net.NetworkScoreManager; import android.os.RemoteException; import android.os.UserManager; @@ -75,6 +76,15 @@ public class WifiPermissionsUtil { } /** + * Check and enforce tether change permission. + * + * @param context Context object of the caller. + */ + public void enforceTetherChangePermission(Context context) { + ConnectivityManager.enforceTetherChangePermission(context); + } + + /** * API to determine if the caller has permissions to get * scan results. * @param pkgName Packagename of the application requesting access |