1
0
mirror of https://github.com/termux/termux-app synced 2024-06-17 22:57:08 +00:00
This commit is contained in:
Fredrik Fornwall 2024-04-19 19:00:04 +03:00 committed by GitHub
commit f9d2b08707
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 6 deletions

View File

@ -36,6 +36,7 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<application
android:name=".app.TermuxApplication"
@ -196,11 +197,13 @@
<service
android:name=".app.TermuxService"
android:foregroundServiceType="specialUse"
android:exported="false" />
<service
android:name=".app.RunCommandService"
android:exported="true"
android:foregroundServiceType="specialUse"
android:permission="${TERMUX_PACKAGE_NAME}.permission.RUN_COMMAND">
<intent-filter>
<action android:name="${TERMUX_PACKAGE_NAME}.RUN_COMMAND" />

View File

@ -259,7 +259,11 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
try {
// Start the {@link TermuxService} and make it run regardless of who is bound to it
Intent serviceIntent = new Intent(this, TermuxService.class);
startService(serviceIntent);
if (Build.VERSION.SDK_INT >= 26) {
startForegroundService(serviceIntent);
} else {
startService(serviceIntent);
};
// Attempt to bind to the service, this will call the {@link #onServiceConnected(ComponentName, IBinder)}
// callback if it succeeds.
@ -932,7 +936,11 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
intentFilter.addAction(TERMUX_ACTIVITY.ACTION_RELOAD_STYLE);
intentFilter.addAction(TERMUX_ACTIVITY.ACTION_REQUEST_PERMISSIONS);
registerReceiver(mTermuxActivityBroadcastReceiver, intentFilter);
if (Build.VERSION.SDK_INT >= 28) {
registerReceiver(mTermuxActivityBroadcastReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED);
} else {
registerReceiver(mTermuxActivityBroadcastReceiver, intentFilter);
}
}
private void unregisterTermuxActivityBroadcastReceiver() {

View File

@ -784,7 +784,7 @@ public final class TermuxService extends Service implements AppShell.AppShellCli
// Set pending intent to be launched when notification is clicked
Intent notificationIntent = TermuxActivity.newInstance(this);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
// Set notification text
@ -827,7 +827,7 @@ public final class TermuxService extends Service implements AppShell.AppShellCli
// Set Exit button action
Intent exitIntent = new Intent(this, TermuxService.class).setAction(TERMUX_SERVICE.ACTION_STOP_SERVICE);
builder.addAction(android.R.drawable.ic_delete, res.getString(R.string.notification_action_exit), PendingIntent.getService(this, 0, exitIntent, 0));
builder.addAction(android.R.drawable.ic_delete, res.getString(R.string.notification_action_exit), PendingIntent.getService(this, 0, exitIntent, PendingIntent.FLAG_IMMUTABLE));
// Set Wakelock button actions
@ -835,7 +835,7 @@ public final class TermuxService extends Service implements AppShell.AppShellCli
Intent toggleWakeLockIntent = new Intent(this, TermuxService.class).setAction(newWakeAction);
String actionTitle = res.getString(wakeLockHeld ? R.string.notification_action_wake_unlock : R.string.notification_action_wake_lock);
int actionIcon = wakeLockHeld ? android.R.drawable.ic_lock_idle_lock : android.R.drawable.ic_lock_lock;
builder.addAction(actionIcon, actionTitle, PendingIntent.getService(this, 0, toggleWakeLockIntent, 0));
builder.addAction(actionIcon, actionTitle, PendingIntent.getService(this, 0, toggleWakeLockIntent, PendingIntent.FLAG_IMMUTABLE));
return builder.build();

View File

@ -342,7 +342,7 @@ public class TermuxCrashUtils implements CrashHandler.CrashHandlerClient {
// Must ensure result code for PendingIntents and id for notification are unique otherwise will override previous
int nextNotificationId = TermuxNotificationUtils.getNextNotificationId(termuxPackageContext);
PendingIntent contentIntent = PendingIntent.getActivity(termuxPackageContext, nextNotificationId, result.contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent contentIntent = PendingIntent.getActivity(termuxPackageContext, nextNotificationId, result.contentIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
PendingIntent deleteIntent = null;
if (result.deleteIntent != null)