Skip to content

Commit

Permalink
Fix Ignore on notification not working
Browse files Browse the repository at this point in the history
  • Loading branch information
fynngodau committed Jan 11, 2024
1 parent 9fbaf2e commit 224f822
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 224f822

Please sign in to comment.