Foreground service type
This commit is contained in:
@@ -79,6 +79,7 @@
|
||||
<!--android:maxSdkVersion="32" />
|
||||
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
|
||||
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
|
||||
<uses-permission android:name="com.termux.permission.FOREGROUND_SERVICE_TYPE_SPECIAL_USE" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
@@ -124,7 +125,8 @@
|
||||
<service
|
||||
android:name=".AutomationService"
|
||||
android:exported="false"
|
||||
android:label="@string/app_name" />
|
||||
android:label="@string/app_name"
|
||||
android:foregroundServiceType="specialUse" />
|
||||
|
||||
<receiver android:name=".receivers.StartupIntentReceiver" android:enabled="true" android:exported="true">
|
||||
<intent-filter>
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
<!--android:maxSdkVersion="32" />
|
||||
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
|
||||
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
|
||||
<uses-permission android:name="com.termux.permission.FOREGROUND_SERVICE_TYPE_SPECIAL_USE" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
@@ -122,7 +123,8 @@
|
||||
<service
|
||||
android:name=".AutomationService"
|
||||
android:exported="false"
|
||||
android:label="@string/app_name" />
|
||||
android:label="@string/app_name"
|
||||
android:foregroundServiceType="specialUse" />
|
||||
|
||||
<receiver android:name=".receivers.StartupIntentReceiver" android:enabled="true" android:exported="true">
|
||||
<intent-filter>
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<!--android:maxSdkVersion="32" />
|
||||
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
|
||||
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
|
||||
<uses-permission android:name="com.termux.permission.FOREGROUND_SERVICE_TYPE_SPECIAL_USE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -106,7 +107,12 @@
|
||||
<service
|
||||
android:name=".AutomationService"
|
||||
android:exported="false"
|
||||
android:label="@string/app_name" />
|
||||
android:label="@string/app_name"
|
||||
android:foregroundServiceType="specialUse">
|
||||
<property
|
||||
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
||||
android:value="Automating things on the device" />
|
||||
</service>
|
||||
|
||||
<receiver android:name=".receivers.StartupIntentReceiver"
|
||||
android:enabled="true"
|
||||
|
||||
@@ -533,6 +533,13 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
return;
|
||||
}
|
||||
|
||||
if(Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 34 && !ActivityPermissions.havePermission(Manifest.permission.FOREGROUND_SERVICE_SPECIAL_USE, context))
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.permissionForegroundServiceTypeSpecialUseRequired), Toast.LENGTH_LONG).show();
|
||||
activityMainScreenInstance.toggleService.setChecked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AutomationService.isMyServiceRunning(context))
|
||||
{
|
||||
myServiceIntent = new Intent(context, AutomationService.class);
|
||||
|
||||
@@ -424,6 +424,11 @@ public class ActivityPermissions extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
if(Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 34 && !havePermission(Manifest.permission.FOREGROUND_SERVICE_SPECIAL_USE, workingContext))
|
||||
{
|
||||
addToArrayListUnique(Manifest.permission.FOREGROUND_SERVICE_SPECIAL_USE, requiredPermissions);
|
||||
}
|
||||
|
||||
if(!havePermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, workingContext))
|
||||
addToArrayListUnique(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, requiredPermissions);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
@@ -660,7 +661,10 @@ public class AutomationService extends Service implements OnInitListener
|
||||
myNotification.flags |= Notification.FLAG_NO_CLEAR;
|
||||
// notificationManager.notify(notificationId, myNotification);
|
||||
|
||||
instance.startForeground(notificationId, myNotification);
|
||||
if(Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 34)
|
||||
instance.startForeground(notificationId, myNotification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
|
||||
else
|
||||
instance.startForeground(notificationId, myNotification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -543,7 +543,7 @@ public class Profile implements Comparable<Profile>
|
||||
{
|
||||
AudioManager am = (AudioManager) Miscellaneous.getAnyContext().getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
if(changeSoundMode)
|
||||
if(changeSoundMode)
|
||||
Actions.setSound(context, soundMode);
|
||||
|
||||
if(changeDndMode)
|
||||
|
||||
@@ -959,4 +959,5 @@
|
||||
<string name="screenBrightGoogleComment">Because someone at Google seems to have been smoking something the screen brightness setting has been behaving very weird for some Android versions. This behavior has nothing to do with what you\'d think it does according to their own documentation. I\'ve tried to adapt to this as best as I could, but do not expect very precise settings. That means the resulting setting may deviate a bit from what you configure here.</string>
|
||||
<string name="disable">Disable</string>
|
||||
<string name="enable">Enable</string>
|
||||
<string name="permissionForegroundServiceTypeSpecialUseRequired">Permission FOREGROUND_SERVICE_TYPE_SPECIAL_USE is required to start.</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user