Use userid of sender, not notification target.

When trying to find a package.

Bug: 33178040
Test: manual, ./vendor/google/tools/fake-ota on
Change-Id: I0b69c37f16e7e1763bff4df1650911fe3435bc77
This commit is contained in:
Julia Reynolds
2016-12-19 14:14:25 -05:00
parent 76ab11d470
commit d5261e1d0a
3 changed files with 4 additions and 14 deletions

View File

@@ -246,7 +246,7 @@ public class StatusBarNotification implements Parcelable {
}
/**
* Returns a userHandle for the instance of the app that posted this notification.
* Returns a userid for whom this notification is intended.
*
* @deprecated Use {@link #getUser()} instead.
*/

View File

@@ -25,6 +25,7 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -136,15 +137,9 @@ public final class NotificationRecord {
private boolean isPreChannelsNotification() {
try {
if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(getChannel().getId())) {
final boolean isSystemNotification =
NotificationManagerService.isUidSystem(sbn.getUid())
|| ("android".equals(sbn.getPackageName()));
if (isSystemNotification) {
return false;
}
final ApplicationInfo applicationInfo =
final ApplicationInfo applicationInfo =
mContext.getPackageManager().getApplicationInfoAsUser(sbn.getPackageName(),
0, sbn.getUserId());
0, UserHandle.getUserId(sbn.getUid()));
if (applicationInfo.targetSdkVersion <= Build.VERSION_CODES.N_MR1) {
return true;
}

View File

@@ -784,11 +784,6 @@ public class RankingHelper implements RankingConfig {
}
}
private static boolean isUidSystem(int uid) {
final int appid = UserHandle.getAppId(uid);
return (appid == Process.SYSTEM_UID || appid == Process.PHONE_UID || uid == 0);
}
private static class Record {
static int UNKNOWN_UID = UserHandle.USER_NULL;