diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-04-16 01:20:40 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-04-16 01:20:40 +0000 |
commit | 536a9c2b67c5977d3bd567c44e4d16aa3c89e4fe (patch) | |
tree | 28e4d921095dde0be80ba47ca2c56075f758640d /service | |
parent | 4f3b0d84dfc064b7cb40713007bf606c3969a743 (diff) | |
parent | d13cd95984bc71dae7989d64dde1b4f5269d029b (diff) |
WifiServiceImpl: setWifiApEnabled unit tests am: 198804eb25 am: eb00f87e10
am: d13cd95984
Change-Id: I77413789b1b2a19c9330f4c9b9978c4a0f5b5bf8
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 |