summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-09-18 23:39:03 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-09-18 23:39:03 +0000
commitc9d68061749a93378f575199798f676a2b5c37a8 (patch)
treee1a80cfb59d373558e35f5efd9096b2715b246b2 /service
parent9a3473bafbffd386b54743500ac875f10bab459b (diff)
parenta61a3c5c15c6564d60af0e8c08b879cdfa7c509d (diff)
Merge "WifiPermissionsUtil: Use getApplicationInfoAsUser for target SDK checks" into qt-qpr1-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java9
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java2
-rw-r--r--service/java/com/android/server/wifi/util/WifiPermissionsUtil.java7
3 files changed, 10 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index be75f96b3..354c0a555 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -853,7 +853,7 @@ public class WifiServiceImpl extends BaseWifiService {
* Note: Invoke mAppOps.checkPackage(uid, packageName) before to ensure correct package name.
*/
private boolean isTargetSdkLessThanQOrPrivileged(String packageName, int pid, int uid) {
- return mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q)
+ return mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q, uid)
|| isPrivileged(pid, uid)
// DO/PO apps should be able to add/modify saved networks.
|| isDeviceOrProfileOwner(uid)
@@ -875,7 +875,8 @@ public class WifiServiceImpl extends BaseWifiService {
}
boolean isPrivileged = isPrivileged(Binder.getCallingPid(), Binder.getCallingUid());
if (!isPrivileged && !isDeviceOrProfileOwner(Binder.getCallingUid())
- && !mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q)
+ && !mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q,
+ Binder.getCallingUid())
&& !isSystem(packageName)) {
mLog.info("setWifiEnabled not allowed for uid=%")
.c(Binder.getCallingUid()).flush();
@@ -2309,7 +2310,7 @@ public class WifiServiceImpl extends BaseWifiService {
final int uid = Binder.getCallingUid();
if (!mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)
&& !mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(uid)) {
- if (mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q)) {
+ if (mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q, uid)) {
return false;
}
throw new SecurityException(TAG + ": Permission denied");
@@ -2334,7 +2335,7 @@ public class WifiServiceImpl extends BaseWifiService {
mAppOps.checkPackage(uid, packageName);
if (!mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)
&& !mWifiPermissionsUtil.checkNetworkSetupWizardPermission(uid)) {
- if (mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q)) {
+ if (mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q, uid)) {
return new ArrayList<>();
}
throw new SecurityException(TAG + ": Permission denied");
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
index 1ac73aef8..5832ee898 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
@@ -1286,7 +1286,7 @@ public class WifiAwareDataPathStateManager {
// Note: checks are done on the manager. This is a backup for apps which bypass the
// check.
if (!allowNdpResponderFromAnyOverride && !wifiPermissionsUtil.isTargetSdkLessThan(
- client.getCallingPackage(), Build.VERSION_CODES.P)) {
+ client.getCallingPackage(), Build.VERSION_CODES.P, uid)) {
if (ns.type != WifiAwareNetworkSpecifier.NETWORK_SPECIFIER_TYPE_IB
&& ns.type != WifiAwareNetworkSpecifier.NETWORK_SPECIFIER_TYPE_OOB) {
Log.e(TAG, "processNetworkSpecifier: networkSpecifier=" + ns
diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
index 2834ad765..b1ceaf37a 100644
--- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
+++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
@@ -124,10 +124,11 @@ public class WifiPermissionsUtil {
/**
* Checks whether than the target SDK of the package is less than the specified version code.
*/
- public boolean isTargetSdkLessThan(String packageName, int versionCode) {
+ public boolean isTargetSdkLessThan(String packageName, int versionCode, int callingUid) {
long ident = Binder.clearCallingIdentity();
try {
- if (mContext.getPackageManager().getApplicationInfo(packageName, 0).targetSdkVersion
+ if (mContext.getPackageManager().getApplicationInfoAsUser(
+ packageName, 0, UserHandle.getUserId(callingUid)).targetSdkVersion
< versionCode) {
return true;
}
@@ -153,7 +154,7 @@ public class WifiPermissionsUtil {
*/
public boolean checkCallersLocationPermission(String pkgName, int uid,
boolean coarseForTargetSdkLessThanQ) {
- boolean isTargetSdkLessThanQ = isTargetSdkLessThan(pkgName, Build.VERSION_CODES.Q);
+ boolean isTargetSdkLessThanQ = isTargetSdkLessThan(pkgName, Build.VERSION_CODES.Q, uid);
String permissionType = Manifest.permission.ACCESS_FINE_LOCATION;
if (coarseForTargetSdkLessThanQ && isTargetSdkLessThanQ) {