diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-09-14 20:49:34 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-09-14 20:49:34 +0000 |
commit | 54d724d38f88c072c6c7828d557cb2e23baf404c (patch) | |
tree | aecbcd2b653bcae8aa59cfdfb23953d4163bc9af | |
parent | 0b3cfeb5e46d2b270a289f76e7a0ecacee2551fa (diff) | |
parent | 5b6734b829bfb0532245b64c542e3a2f18711e94 (diff) | |
download | wifi-nougat-mr0.5-release.tar.gz |
Merge cherrypicks of [5027797, 5027798, 5029209, 5030032, 5023135, 5028893, 5028915, 5028916, 5028917, 5028948, 5028949, 5028950, 5030131, 5030132, 5030133, 5030134, 5030135, 5028894, 5028918, 5030033, 5023136, 5030136, 5029210, 5030171, 5030172, 5030173, 5030174, 5030175, 5030176, 5030177, 5030178, 5030179, 5030180, 5029076, 5029077, 5029078, 5029079, 5029080, 5029081, 5029082, 5029083, 5029084, 5029085, 5029086, 5029087, 5029088, 5029089, 5029090, 5030211, 5030212, 5030213, 5030214, 5030215, 5030216, 5030217, 5020440, 5020441, 5020442, 5030137, 5030034, 5020443, 5030138, 5029124, 5027799, 5029125, 5029126, 5029127, 5023137, 5030139, 5030140, 5029132, 5030141, 5030142, 5030143, 5030181, 5030182, 5030183, 5030184, 5030185, 5030186, 5030187, 5030188, 5030189, 5030190, 5030231, 5030232, 5030233, 5030234, 5030235, 5030236, 5030237, 5030238, 5030239, 5030240, 5030241, 5030242, 5030243, 5030244, 5030245, 5030246, 5030247, 5030248, 5030249, 5030250, 5030271, 5030272, 5030273, 5030274, 5030275, 5030276, 5030277, 5030278, 5030279, 5030280, 5030281, 5020444, 5027800, 5030144] into nyc-bugfix-releaseandroid-7.0.0_r36nougat-mr0.5-release
Change-Id: I369823c9c8d8b4f3ddc22a095fba494b9641b0d6
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 7193580de..b4ed6cefd 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -543,6 +543,16 @@ public class WifiServiceImpl extends IWifiManager.Stub { "ConnectivityService"); } + private void enforceTetheringRestriction() { + // check if the user has the tethering restriction + UserManager um = UserManager.get(mContext); + UserHandle userHandle = Binder.getCallingUserHandle(); + Slog.d(TAG, "setWifiApEnabled - calling userId: " + userHandle.getIdentifier()); + if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING, userHandle)) { + throw new SecurityException("DISALLOW_CONFIG_TETHERING is enabled for this user."); + } + } + /** * see {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)} * @param enable {@code true} to enable, {@code false} to disable. @@ -593,11 +603,21 @@ public class WifiServiceImpl extends IWifiManager.Stub { * @param enabled true to enable and false to disable */ public void setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) { + Slog.d(TAG, "setWifiApEnabled: " + enabled + " pid=" + Binder.getCallingPid() + + ", uid=" + Binder.getCallingUid()); enforceChangePermission(); ConnectivityManager.enforceTetherChangePermission(mContext); - if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) { - throw new SecurityException("DISALLOW_CONFIG_TETHERING is enabled for this user."); + + // check if the user has the tethering restriction + enforceTetheringRestriction(); + Slog.d(TAG, "setWifiApEnabled - passed the config_tethering check"); + + // now check if this is the primary user + if (Binder.getCallingUserHandle().getIdentifier() != UserHandle.USER_OWNER) { + Slog.e(TAG, "Only the device owner can enable wifi tethering"); + return; } + // null wifiConfig is a meaningful input for CMD_SET_AP if (wifiConfig == null || isValid(wifiConfig)) { mWifiController.obtainMessage(CMD_SET_AP, enabled ? 1 : 0, 0, wifiConfig).sendToTarget(); @@ -625,6 +645,13 @@ public class WifiServiceImpl extends IWifiManager.Stub { */ public WifiConfiguration getWifiApConfiguration() { enforceAccessPermission(); + enforceTetheringRestriction(); + // now check if this is the primary user + if (Binder.getCallingUserHandle().getIdentifier() != UserHandle.USER_OWNER) { + Slog.e(TAG, "Only the device owner can retrieve the ap config"); + return null; + } + return mWifiStateMachine.syncGetWifiApConfiguration(); } @@ -652,7 +679,17 @@ public class WifiServiceImpl extends IWifiManager.Stub { * @param wifiConfig WifiConfiguration details for soft access point */ public void setWifiApConfiguration(WifiConfiguration wifiConfig) { + Slog.d(TAG, "setWifiApConfiguration: " + wifiConfig); enforceChangePermission(); + + enforceTetheringRestriction(); + + // now check if this is the primary user + if (Binder.getCallingUserHandle().getIdentifier() != UserHandle.USER_OWNER) { + Slog.e(TAG, "Only the device owner can set the ap config"); + return; + } + if (wifiConfig == null) return; if (isValid(wifiConfig)) { |