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

@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "com.jens.automation2"
minSdkVersion 16
compileSdkVersion 31
compileSdkVersion 33
buildToolsVersion '29.0.2'
useLibrary 'org.apache.http.legacy'
versionCode 138

View File

@ -71,6 +71,7 @@
android:name="android.permission.WRITE_SECURE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!--android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
@ -107,7 +108,9 @@
android:exported="false"
android:label="@string/app_name" />
<receiver android:name=".receivers.StartupIntentReceiver" android:enabled="true" android:exported="true">
<receiver android:name=".receivers.StartupIntentReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<!--<action android:name="android.intent.action.SCREEN_ON" />-->
<!--<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />-->
@ -214,7 +217,6 @@
<activity android:name=".ActivityManageActionStartActivity" />
<activity android:name=".ActivityManageTriggerNfc" />
<activity android:name=".ActivityManageActionSpeakText" />
<activity android:name=".ActivityManageActionPlaySound" />
<activity android:name=".ActivityManageTriggerBluetooth" />
<activity android:name=".ActivityMainProfiles" />
<activity android:name=".ActivityManageProfile" />
@ -235,8 +237,6 @@
</service>
<activity android:name=".ActivityPermissions" />
<!-- https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p-->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
@ -259,7 +259,8 @@
/>
<service android:name=".MyAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:exported="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>

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;
}
}