diff --git a/app/src/main/java/com/termux/app/TermuxService.java b/app/src/main/java/com/termux/app/TermuxService.java
index d79f8e5c37..fe0b9a5b61 100644
--- a/app/src/main/java/com/termux/app/TermuxService.java
+++ b/app/src/main/java/com/termux/app/TermuxService.java
@@ -640,8 +640,13 @@ private void startTermuxActivity() {
// For android >= 10, apps require Display over other apps permission to start foreground activities
// from background (services). If it is not granted, then TermuxSessions that are started will
// show in Termux notification but will not run until user manually clicks the notification.
- if (PermissionUtils.validateDisplayOverOtherAppsPermissionForPostAndroid10(this)) {
+ if (PermissionUtils.validateDisplayOverOtherAppsPermissionForPostAndroid10(this, true)) {
TermuxActivity.startTermuxActivity(this);
+ } else {
+ TermuxAppSharedPreferences preferences = TermuxAppSharedPreferences.build(this);
+ if (preferences == null) return;
+ if (preferences.arePluginErrorNotificationsEnabled())
+ Logger.showToast(this, this.getString(R.string.error_display_over_other_apps_permission_not_granted), true);
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c226924c9a..5f396302d8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -91,6 +91,11 @@
+
+ &TERMUX_APP_NAME; requires \"Display over other apps\" permission to start terminal sessions from background on Android >= 10. Grants it from Settings -> Apps -> &TERMUX_APP_NAME; -> Advanced
+
+
+
Invalid intent action to RunCommandService: `%1$s`
Mandatory extra missing to RunCommandService: \"%1$s\"
diff --git a/termux-shared/src/main/java/com/termux/shared/packages/PermissionUtils.java b/termux-shared/src/main/java/com/termux/shared/packages/PermissionUtils.java
index ddd36b7a7d..6311ed2419 100644
--- a/termux-shared/src/main/java/com/termux/shared/packages/PermissionUtils.java
+++ b/termux-shared/src/main/java/com/termux/shared/packages/PermissionUtils.java
@@ -13,9 +13,7 @@
import androidx.core.content.ContextCompat;
import com.termux.shared.R;
-import com.termux.shared.termux.TermuxConstants;
import com.termux.shared.logger.Logger;
-import com.termux.shared.settings.preferences.TermuxAppSharedPreferences;
import java.util.Arrays;
@@ -81,20 +79,16 @@ public static void requestDisplayOverOtherAppsPermission(Activity context, int r
context.startActivityForResult(intent, requestCode);
}
- public static boolean validateDisplayOverOtherAppsPermissionForPostAndroid10(Context context) {
+ public static boolean validateDisplayOverOtherAppsPermissionForPostAndroid10(Context context, boolean logResults) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return true;
if (!PermissionUtils.checkDisplayOverOtherAppsPermission(context)) {
- Logger.logWarn(LOG_TAG, TermuxConstants.TERMUX_APP_NAME + " App does not have Display over other apps (SYSTEM_ALERT_WINDOW) permission");
-
- TermuxAppSharedPreferences preferences = TermuxAppSharedPreferences.build(context);
- if (preferences == null) return false;
-
- if (preferences.arePluginErrorNotificationsEnabled())
- Logger.showToast(context, context.getString(R.string.error_display_over_other_apps_permission_not_granted), true);
+ if (logResults)
+ Logger.logWarn(LOG_TAG, context.getPackageName() + " does not have Display over other apps (SYSTEM_ALERT_WINDOW) permission");
return false;
} else {
- Logger.logDebug(LOG_TAG, TermuxConstants.TERMUX_APP_NAME + " App already has Display over other apps (SYSTEM_ALERT_WINDOW) permission");
+ if (logResults)
+ Logger.logDebug(LOG_TAG, context.getPackageName() + " already has Display over other apps (SYSTEM_ALERT_WINDOW) permission");
return true;
}
}
diff --git a/termux-shared/src/main/res/values/strings.xml b/termux-shared/src/main/res/values/strings.xml
index 21a8504635..b6efd5c502 100644
--- a/termux-shared/src/main/res/values/strings.xml
+++ b/termux-shared/src/main/res/values/strings.xml
@@ -25,7 +25,6 @@
Please grant permissions on next screen
- &TERMUX_APP_NAME; requires \"Display over other apps\" permission to start terminal sessions from background on Android >= 10. Grants it from Settings -> Apps -> &TERMUX_APP_NAME; -> Advanced