In isTetheringSupported, call isAdmin user from system.

This avoids requiring the MANAGE_USERS permission in this function.

Bug: 32671528
Test: Manual. Also seeking unit test guidance from reviewer.
Change-Id: I841e721013b0e4b6db34d629a1e97b3cd54cd73b
This commit is contained in:
Jeremy Klein
2017-03-17 14:30:02 -07:00
parent 45a54e122b
commit a380d3f60b

View File

@@ -3082,7 +3082,17 @@ public class ConnectivityService extends IConnectivityManager.Stub
boolean tetherEnabledInSettings = (Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.TETHER_SUPPORTED, defaultVal) != 0)
&& !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
return tetherEnabledInSettings && mUserManager.isAdminUser() &&
// Elevate to system UID to avoid caller requiring MANAGE_USERS permission.
boolean adminUser = false;
final long token = Binder.clearCallingIdentity();
try {
adminUser = mUserManager.isAdminUser();
} finally {
Binder.restoreCallingIdentity(token);
}
return tetherEnabledInSettings && adminUser &&
mTethering.hasTetherableConfiguration();
}