diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-04-16 01:25:07 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-04-16 01:25:07 +0000 |
commit | ddc421324e011c407a205c6596d8ec1f328e86ee (patch) | |
tree | 7d81e1793728682269f8760eadad28cf89de45a6 /service | |
parent | ca71a341baaf38de49d0a6bacdc9a7f1a65db598 (diff) | |
parent | 536a9c2b67c5977d3bd567c44e4d16aa3c89e4fe (diff) |
WifiServiceImpl: setWifiApEnabled unit tests am: 198804eb25 am: eb00f87e10 am: d13cd95984
am: 536a9c2b67
Change-Id: 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 |