Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
2024-01-25 16:54:00 +01:00
12 changed files with 115 additions and 87 deletions

View File

@ -427,6 +427,12 @@ public class ActivityPermissions extends Activity
if(!havePermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, workingContext))
addToArrayListUnique(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, requiredPermissions);
if(Build.VERSION.SDK_INT >= 33 && BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
{
if (!havePermission(android.Manifest.permission.POST_NOTIFICATIONS, workingContext))
addToArrayListUnique(android.Manifest.permission.POST_NOTIFICATIONS, requiredPermissions);
}
if(!havePermission(Manifest.permission.READ_EXTERNAL_STORAGE, workingContext))
{
for (Profile p : Profile.getProfileCollection())

View File

@ -265,7 +265,6 @@ public class NotificationListener extends NotificationListenerService// implemen
cancelNotification(sbn.getPackageName(), sbn.getTag(), sbn.getId());
else
cancelNotification(sbn.getKey());
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@ -298,46 +297,4 @@ public class NotificationListener extends NotificationListenerService// implemen
if(!buttonFound)
Miscellaneous.logEvent("w", "clickNotificationButton()", "Button with text \n" + buttonText + "\n could not found.", 2);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static boolean mayRuleStillBeActivatedForPendingNotifications(Rule rule)
{
for(RuleNotificationPair pair : notificationUsed)
Miscellaneous.logEvent("i", "mayRuleStillBeActivatedForPendingCalendarEvents()", "Existing pair of " + pair.rule.getName() + " and " + pair.notification, 5);
for(StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications())
{
for(Trigger t : rule.getTriggerSet())
{
if(t.getTriggerType().equals(Trigger.Trigger_Enum.notification) && NotificationListener.getInstance().checkNotification(true, sbn))
{
if (!hasNotificationBeenUsedInRule(rule, convertNotificationToSimpleNotification(true, sbn)))
{
/*
If there are multiple parallel calendar events and a rule has multiple
triggers of type calendar event, we don't want the rule to fire only once.
*/
if(rule.getAmountOfTriggersForType(Trigger.Trigger_Enum.notification) == 1)
{
Miscellaneous.logEvent("i", "mayRuleStillBeActivatedForPendingNotifications()", "Rule " + rule.getName() + " has not been used in conjunction with notification " + sbn, 4);
return true;
}
}
}
}
}
return false;
}
public static boolean hasNotificationBeenUsedInRule(Rule rule, SimpleNotification notification)
{
for (RuleNotificationPair executedPair : notificationUsed)
{
if (executedPair.rule.equals(rule) && executedPair.notification.equals(notification))
return true;
}
return false;
}
}