summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-09-20 19:59:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-09-20 19:59:48 +0000
commit7957387b5d459386191cf45ca90e45446ed13f93 (patch)
tree7f21746a02f0da4c1675c8935933e38931d75541 /service
parentec1e58cd439ae645ff4e5bf55f7961e359bf0e4c (diff)
parent4d27cab6de2984871ab38d22e13f7677f95a3341 (diff)
Merge "Fix a bunch of multi-user API calls" into qt-qpr1-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkFactory.java8
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java7
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java9
3 files changed, 14 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java
index 1f060cf73..c375e9f59 100644
--- a/service/java/com/android/server/wifi/WifiNetworkFactory.java
+++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java
@@ -1141,10 +1141,11 @@ public class WifiNetworkFactory extends NetworkFactory {
mConnectionTimeoutSet = true;
}
- private @NonNull CharSequence getAppName(@NonNull String packageName) {
+ private @NonNull CharSequence getAppName(@NonNull String packageName, int uid) {
ApplicationInfo applicationInfo = null;
try {
- applicationInfo = mContext.getPackageManager().getApplicationInfo(packageName, 0);
+ applicationInfo = mContext.getPackageManager().getApplicationInfoAsUser(
+ packageName, 0, UserHandle.getUserId(uid));
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to find app name for " + packageName);
return "";
@@ -1159,7 +1160,8 @@ public class WifiNetworkFactory extends NetworkFactory {
intent.addCategory(UI_START_INTENT_CATEGORY);
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(UI_START_INTENT_EXTRA_APP_NAME,
- getAppName(mActiveSpecificNetworkRequestSpecifier.requestorPackageName));
+ getAppName(mActiveSpecificNetworkRequestSpecifier.requestorPackageName,
+ mActiveSpecificNetworkRequestSpecifier.requestorUid));
intent.putExtra(UI_START_INTENT_EXTRA_REQUEST_IS_FOR_SINGLE_NETWORK,
isActiveRequestForSingleNetwork());
mContext.startActivityAsUser(intent, UserHandle.getUserHandleForUid(
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index 972d1c93f..644eb6523 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -761,10 +761,11 @@ public class WifiNetworkSuggestionsManager {
PendingIntent.FLAG_UPDATE_CURRENT);
}
- private @NonNull CharSequence getAppName(@NonNull String packageName) {
+ private @NonNull CharSequence getAppName(@NonNull String packageName, int uid) {
ApplicationInfo applicationInfo = null;
try {
- applicationInfo = mPackageManager.getApplicationInfo(packageName, 0);
+ applicationInfo = mContext.getPackageManager().getApplicationInfoAsUser(
+ packageName, 0, UserHandle.getUserId(uid));
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to find app name for " + packageName);
return "";
@@ -787,7 +788,7 @@ public class WifiNetworkSuggestionsManager {
packageName, uid))
.build();
- CharSequence appName = getAppName(packageName);
+ CharSequence appName = getAppName(packageName, uid);
Notification notification = new Notification.Builder(
mContext, SystemNotificationChannels.NETWORK_STATUS)
.setSmallIcon(R.drawable.stat_notify_wifi_in_range)
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 354c0a555..2d15af53c 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -755,10 +755,11 @@ public class WifiServiceImpl extends BaseWifiService {
}
// Helper method to check if the entity initiating the binder call is a system app.
- private boolean isSystem(String packageName) {
+ private boolean isSystem(String packageName, int uid) {
long ident = Binder.clearCallingIdentity();
try {
- ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(packageName, 0);
+ ApplicationInfo info = mContext.getPackageManager().getApplicationInfoAsUser(
+ packageName, 0, UserHandle.getUserId(uid));
return info.isSystemApp() || info.isUpdatedSystemApp();
} catch (PackageManager.NameNotFoundException e) {
// In case of exception, assume unknown app (more strict checking)
@@ -858,7 +859,7 @@ public class WifiServiceImpl extends BaseWifiService {
// DO/PO apps should be able to add/modify saved networks.
|| isDeviceOrProfileOwner(uid)
// TODO: Remove this system app bypass once Q is released.
- || isSystem(packageName)
+ || isSystem(packageName, uid)
|| mWifiPermissionsUtil.checkSystemAlertWindowPermission(uid, packageName);
}
@@ -877,7 +878,7 @@ public class WifiServiceImpl extends BaseWifiService {
if (!isPrivileged && !isDeviceOrProfileOwner(Binder.getCallingUid())
&& !mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q,
Binder.getCallingUid())
- && !isSystem(packageName)) {
+ && !isSystem(packageName, Binder.getCallingUid())) {
mLog.info("setWifiEnabled not allowed for uid=%")
.c(Binder.getCallingUid()).flush();
return false;