Skip to content

Commit

Permalink
Fix foreground service
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftrot committed Mar 7, 2023
1 parent 1710eb3 commit 490a30a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion term/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_TYPE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_TYPE_DATA_SYNC"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission
Expand Down
20 changes: 10 additions & 10 deletions term/src/main/java/jackpal/androidterm/RemoteInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
import androidx.preference.PreferenceManager;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

import jackpal.androidterm.emulatorview.TermSession;
import jackpal.androidterm.emulatorview.compat.ClipboardManagerCompat;
import jackpal.androidterm.emulatorview.compat.ClipboardManagerCompatFactory;
import jackpal.androidterm.util.SessionList;
Expand Down Expand Up @@ -426,6 +428,7 @@ public static String quoteForBash(String s) {
}

protected String openNewWindow(String iInitialCommand) {
TermService service = getTermService();
Term.restoreSyncFileObserver(this);

String initialCommand = getInitialCommand();
Expand All @@ -438,8 +441,13 @@ protected String openNewWindow(String iInitialCommand) {
}

try {
mInitialCommand = initialCommand;
TermSession session = Term.createTermSession(this, mSettings, initialCommand);

session.setFinishCallback(service);
service.getSessions().add(session);

String handle = UUID.randomUUID().toString();
((GenericTermSession) session).setHandle(handle);

Intent intent = new Intent(PRIVACT_OPEN_NEW_WINDOW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
Expand All @@ -449,19 +457,11 @@ protected String openNewWindow(String iInitialCommand) {
startActivity(intent);

return handle;
} catch (Exception e) {
} catch (IOException e) {
return null;
}
}

static private String mInitialCommand = null;
static public String getInitialCommand(String initialCommand) {
if (mInitialCommand == null) return initialCommand;
initialCommand = mInitialCommand;
mInitialCommand = null;
return initialCommand;
}

private boolean mReplace = false;

private String getInitialCommand() {
Expand Down
1 change: 0 additions & 1 deletion term/src/main/java/jackpal/androidterm/Term.java
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,6 @@ private TermSession createTermSession() throws IOException {
private String getInitialCommand() {
String cmd = mSettings.getInitialCommand();
cmd = mTermService.getInitialCommand(cmd, (mFirst && mTermService.getSessions().size() == 0));
cmd = RemoteInterface.getInitialCommand(cmd);
boolean doInstall = TermVimInstaller.doInstallVim;
if (FLAVOR_TERMINAL) {
doInstall = !TermVimInstaller.getTermInstallStatus(this);
Expand Down

0 comments on commit 490a30a

Please sign in to comment.