-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
termux-app is not booted and not properly working in background on Android 10 (on Xiaomi Redmi 7A) #3870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
termux-app is not booted and not properly working in background on Android 10 (on Xiaomi Redmi 7A) #3870
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,7 +196,8 @@ | |
|
|
||
| <service | ||
| android:name=".app.TermuxService" | ||
| android:exported="false" /> | ||
| android:exported="true" | ||
| android:enabled="true" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Services are enabled by default. https://developer.android.com/guide/topics/manifest/service-element#enabled |
||
|
|
||
| <service | ||
| android:name=".app.RunCommandService" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |||
| import android.os.Build; | ||||
| import android.os.Bundle; | ||||
| import android.os.IBinder; | ||||
| import android.provider.Settings; | ||||
| import android.view.ContextMenu; | ||||
| import android.view.ContextMenu.ContextMenuInfo; | ||||
| import android.view.Gravity; | ||||
|
|
@@ -198,6 +199,20 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo | |||
| @Override | ||||
| public void onCreate(Bundle savedInstanceState) { | ||||
| Logger.logDebug(LOG_TAG, "onCreate"); | ||||
|
|
||||
| // For details see: | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TermuxService requests the permission if its required to start foreground terminal session from background. Permissions must not be requested unless needed.
|
||||
| // https://stackoverflow.com/a/19856267/1455694 | ||||
| // https://stackoverflow.com/a/63250729/1455694 | ||||
| // https://www.reddit.com/r/tasker/comments/d7whyj/android_10_and_auto_starting_apps/ | ||||
| // https://stackoverflow.com/q/64642362/1455694 | ||||
| Context context = getApplicationContext(); | ||||
| // Q is Android 10 | ||||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | ||||
| if (!Settings.canDrawOverlays(context)) { | ||||
| startActivity(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)); | ||||
| } | ||||
| } | ||||
|
|
||||
| mIsOnResumeAfterOnCreate = true; | ||||
|
|
||||
| if (savedInstanceState != null) | ||||
|
|
@@ -257,9 +272,17 @@ public void onCreate(Bundle savedInstanceState) { | |||
| FileReceiverActivity.updateFileReceiverActivityComponentsState(this); | ||||
|
|
||||
| try { | ||||
| Intent serviceIntent; | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one issue that has already been solved locally and fix will be available in next version. |
||||
| // Start the {@link TermuxService} and make it run regardless of who is bound to it | ||||
| Intent serviceIntent = new Intent(this, TermuxService.class); | ||||
| startService(serviceIntent); | ||||
| // O is Oreo, Android 8 | ||||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||||
| serviceIntent = new Intent(context, TermuxService.class); | ||||
| context.startForegroundService(serviceIntent); | ||||
| } | ||||
| else { | ||||
| serviceIntent = new Intent(this, TermuxService.class); | ||||
| startService(serviceIntent); | ||||
| } | ||||
|
|
||||
| // Attempt to bind to the service, this will call the {@link #onServiceConnected(ComponentName, IBinder)} | ||||
| // callback if it succeeds. | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabling export of a service, activity, receiver, provider allows other apps to call them without any permission. This will allow any random app to run commands in termux without user permission, and even with root if termux has root permissions, i.e you are creating a privilege escalation vulnerability.