Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 20 16:28
    @xeffyr banned @sdrausty
Fredrik Fornwall
@fornwall
when you turn the screen off?
or do you mean when removing activity from recents list?
Twaik Yont
@twaik
When removing the activity from the recents list.
Fredrik Fornwall
@fornwall
aha, right. this change (termux/termux-app#1216) doesn't fix that, this is to avoid Doze mode (https://developer.android.com/training/monitoring-device-state/doze-standby ) putting termux processes to sleep when the app hasn't been used for some time
Fredrik Fornwall
@fornwall
another discussion point:
we have this PR, discussed a long time ago: termux/termux-app#1029, for making it possible to call termux (run scripts and commands) using a custom permission
Leonid Plyushch
@xeffyr
Nothing was changed from this time...
Regarding PR.
Fredrik Fornwall
@fornwall
right, I was thinking about combining that with a needed property to be set
so, for an external app to be able to call termux two things are needed:
  • it needs to declare that it uses this custom permission
  • the user needs to have enabled it in termux.properties (something like allow-external-apps=true or similar)
Leonid Plyushch
@xeffyr
If application declares that it uses termux execute permission, user will be prompted for allow or deny it.
Like with termux-setup-storage.
Fredrik Fornwall
@fornwall
and store a list of accepted and denied apps?
Leonid Plyushch
@xeffyr

Old applications still be able to bypass Android permission restrictions.

From https://github.com/termux/termux-app/pull/1029#issuecomment-466814059:

We can use something like

external-apps-can-execute=com.app1,com.app2
Twaik Yont
@twaik
@fornwall You should remember that in case of splitting into two packages you will need to ask user to install com.termux.core from Google Play. pm does not have dependencies mechanism. In this case you can propose user to use Termux as just an advanced terminal emulator or an advanced terminal emulator with package manager support
Leonid Plyushch
@xeffyr
to whitelist applications

You should remember that in case of splitting into two packages you will need to ask user to install com.termux.core from Google Play

This is what I don't like.

Twaik Yont
@twaik
com.termux.core will be central application and com.termux.term will be a plugin ;)
Or com.termux will be a core.
Fredrik Fornwall
@fornwall
agreed, it's bad to require two apps to be installed. but we can experiment if it's possible to fix this within AndroidManifest.xml, perhaps with android:multiprocess
Twaik Yont
@twaik
Also com.termux.term can download apk and ask user to install it, like some other apps do.
Fredrik Fornwall
@fornwall
and/or android:process. so that the background service runs in a separate process from the activity. that might fix the issue here :)
without requiring two apps to be installed
Twaik Yont
@twaik
I think this mechanism will be needed after Google close the way to execute/dlopen binaries not from /data/data/com.termux/libs/

and/or android:process. so that the background service runs in a separate process from the activity. that might fix the issue here :)

It has crushed.
https://gist.github.com/twaik/c3497649a841118325a5542e50a80ff5

Fredrik Fornwall
@fornwall
@twaik right, but it can perhaps be made to work with necessary changes :)
Twaik Yont
@twaik
Of cource I know it :) it was a joke.
Fredrik Fornwall
@fornwall

@xeffyr regarding using app lists as in "external-apps-can-execute=com.app1,com.app2", it feels a bit duplicated

with the protectionLevel="dangerous", android will make sure to ask the user before allowing an app to use the custom permission

Leonid Plyushch
@xeffyr
Yes.
We can go with just Android permission, though it may be automatically granted to applications compiled with old API levels.
Fredrik Fornwall
@fornwall
hm right, was it in android 6 that was introduced (the system asking about dangerous permissions)?
Leonid Plyushch
@xeffyr
Android 6.
Fredrik Fornwall
@fornwall
because we could just require android 6 for external app calling to work
Leonid Plyushch
@xeffyr
I think this will be nice and simplify implementation.
Fredrik Fornwall
@fornwall
👍
Twaik Yont
@twaik

we could just require android 6 for external app calling to work

I was going to propose saving allowed apps in SharedPreferences (it is pretty simple). But requiring android 6 is better.

Fredrik Fornwall
@fornwall
indeed, it's nice to be able to use the system handling of dangerous permissions for that, instead of rolling our own
hm, perhaps it's time to let git master of termux-app require android 6 (or 7), and create an android-5 branch there as well, just as we have for termux-packages
Leonid Plyushch
@xeffyr
How F-Droid will handle splitting android-5 branch ?
It just looks on repository tags.
Isn't it ?
Fredrik Fornwall
@fornwall
hm, perhaps f-droid doesn't have any handling of that (different variant of an app depending on android version)?
Fredrik Fornwall
@fornwall
let's discuss this (branching of android-5 in termux-app or not) more the coming days! anything else for this chat session?
Leonid Plyushch
@xeffyr
Nothing more from me today.
Fredrik Fornwall
@fornwall
thanks!
Twaik Yont
@twaik
About splitting TermuxService to different process: there is a chance that android kills all the processes with Termux's userId. We need to check if it is true.
Leonid Plyushch
@xeffyr
For me it doesn't kill Termux completely. Notification still remains.
Twaik Yont
@twaik
For me it kills all the processes, started from com.termux completely. Notification and sshd are gone after swiping out an activity. Termux:X11 stays alive. I think we should try splitting processes. I will test this solution on Termux:X11.
Twaik Yont
@twaik
I tried to create a service in separated process and it is also getting killed after activity destroyed by user.

        <service
            android:name=".LorieTestService"
            android:enabled="true"
            android:exported="true"
            android:process="com.termux.x11.separated"
            android:persistent="true" />
    ...
package com.termux.x11;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;

public class LorieTestService extends Service {
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
    @Override
    public void onCreate() {
        Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
        notificationIntent.putExtra("foo_bar_extra_key", "foo_bar_extra_value");
        notificationIntent.setAction(Long.toString(System.currentTimeMillis()));

        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        //For creating the Foreground Service
        int priority = Notification.PRIORITY_HIGH;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N)
            priority = NotificationManager.IMPORTANCE_HIGH;
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        String channelId = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? getNotificationChannel(notificationManager) : "";
        Notification notification = new NotificationCompat.Builder(this, channelId)
                .setContentTitle("Termux:X11 Test service")
                .setSmallIcon(R.drawable.ic_x11_icon)
                .setContentText("foreground service")
                .setContentIntent(pendingIntent)
                .setOngoing(true)
                .setPriority(priority)
                .setShowWhen(false)
                .setColor(0xFF607D8B)
                .build();
        startForeground(3, notification);
    }

    @RequiresApi(Build.VERSION_CODES.O)
    private String getNotificationChannel(NotificationManager notificationManager){
        String channelId = getResources().getString(R.string.app_name);
        String channelName = getResources().getString(R.string.app_name);
        NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
        channel.setImportance(NotificationManager.IMPORTANCE_NONE);
        channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
        notificationManager.createNotificationChannel(channel);
        return channelId;
    }
}
    ...
adb shell am startservice com.termux.x11/.LorieTestService