From 224f822e745079d9f72e69ed036bd3777c2ad167 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Thu, 11 Jan 2024 23:38:34 +0100 Subject: [PATCH] Fix Ignore on notification not working --- .../licensing/LicenseServiceNotificationRunnable.java | 7 ++++++- .../com/android/vending/licensing/LicensingService.java | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java b/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java index 7a82341ba2..34567d1d9a 100644 --- a/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java +++ b/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java @@ -70,7 +70,7 @@ public void run() { ignoreIntent.putExtra(INTENT_KEY_IGNORE_PACKAGE_NAME, callerPackageName); ignoreIntent.putExtra(INTENT_KEY_NOTIFICATION_ID, callerUid); PendingIntent ignorePendingIntent = PendingIntent.getBroadcast( - context, callerUid * 2 + 1, ignoreIntent, PendingIntent.FLAG_IMMUTABLE + context, callerUid * 2 + 1, ignoreIntent, PendingIntent.FLAG_MUTABLE ); Notification notification = new NotificationCompat.Builder(context, CHANNEL_ID) @@ -128,6 +128,11 @@ public void onReceive(Context context, Intent intent) { ); String newIgnorePackage = intent.getStringExtra(INTENT_KEY_IGNORE_PACKAGE_NAME); + if (newIgnorePackage == null) { + Log.e(TAG, "Received no ignore package; can't add to ignore list."); + return; + } + Log.d(TAG, "Adding package " + newIgnorePackage + " to ignore list"); ignoreList.add(newIgnorePackage); diff --git a/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java b/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java index 95b4a02723..c66e9b7274 100644 --- a/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java +++ b/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java @@ -163,11 +163,15 @@ private void checkLicenseV2(String packageName, PackageManager packageManager, } private void handleNoAccounts(String packageName, PackageManager packageManager) { + notificationRunnable.callerPackageName = packageName; try { Log.e(TAG, "not checking license, as user is not signed in"); PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0); notificationRunnable.callerUid = packageInfo.applicationInfo.uid; notificationRunnable.callerAppName = packageManager.getApplicationLabel(packageInfo.applicationInfo); + if (notificationRunnable.callerAppName == null) { + notificationRunnable.callerAppName = packageName; + } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "ignored license request, but package name " + packageName + " was not known!"); notificationRunnable.callerAppName = packageName;