Skip to content
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

Fix start on boot on android 8.1 #1041

Merged
merged 1 commit into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@

<service
android:name=".ExecService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:enabled="true"
android:exported="false" />
</application>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ru/meefik/linuxdeploy/EnvUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static void execService(Context c, String cmd, String args) {
Intent service = new Intent(c, ExecService.class);
service.putExtra("cmd", cmd);
service.putExtra("args", args);
c.startService(service);
ExecService.enqueueWork(c, service);
}

/**
Expand Down
28 changes: 11 additions & 17 deletions app/src/main/java/ru/meefik/linuxdeploy/ExecService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.v4.app.JobIntentService;

public class ExecService extends Service {
public class ExecService extends JobIntentService {

Context mContext;
public static final int JOB_ID = 1;

@Override
public void onCreate() {
super.onCreate();
mContext = getBaseContext();
}

@Override
public IBinder onBind(Intent arg0) {
return null;
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, ExecService.class, JOB_ID, work);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
protected void onHandleWork(@NonNull Intent intent) {
if (intent != null) {
final String cmd = intent.getStringExtra("cmd");
final String args = intent.getStringExtra("args");
Expand All @@ -30,20 +25,19 @@ public int onStartCommand(Intent intent, int flags, int startId) {
public void run() {
switch (cmd) {
case "telnetd":
EnvUtils.telnetd(mContext, args);
EnvUtils.telnetd(getBaseContext(), args);
break;
case "httpd":
EnvUtils.httpd(mContext, args);
EnvUtils.httpd(getBaseContext(), args);
break;
default:
PrefStore.showNotification(mContext, null);
EnvUtils.cli(mContext, cmd, args);
PrefStore.showNotification(getBaseContext(), null);
EnvUtils.cli(getBaseContext(), cmd, args);
}
}
});
thread.start();
}
return super.onStartCommand(intent, flags, startId);
}

}