summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorAndroid Build Merger (Role) <noreply-android-build-merger@google.com>2018-04-04 21:57:14 +0000
committerAndroid Build Merger (Role) <noreply-android-build-merger@google.com>2018-04-04 21:57:14 +0000
commit54035f7af619fb84bae9f0a07560679bda626e21 (patch)
treeb76b1d615d26a1e4ab8ef313ddb525e8440f520a /service
parent3abc7f056111caae01f0cd47f57798903bf7b054 (diff)
parent5a9d8f6c081a4a8c8e60ba549590cab1dd93bb76 (diff)
[automerger] RESTRICT AUTOMERGE: WifiServiceImpl: fix and add tethering checks am: 38598d8d32 am: 8e4b6ba3c3 am: 5a9d8f6c08
Change-Id: I33b5c8ab4a770b8c0b5ee1f8c67b17c9d2cc331a
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java41
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 2eb100217..a16c81a57 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -555,6 +555,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.
@@ -625,11 +635,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();
@@ -657,6 +677,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();
}
@@ -684,7 +711,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)) {