Changed: Update `TERMUX_APP__AM_SOCKET_SERVER_ENABLED` environment variable value if `termux-am-socket` server state changes

This commit is contained in:
agnostic-apollo 2022-06-11 19:50:08 +05:00
parent afc06cfd0a
commit ebdab0e59c
2 changed files with 9 additions and 0 deletions

View File

@ -92,6 +92,7 @@ public class TermuxAmSocketServer {
// exported in shell sessions and tasks and if state is changed, then env of older shells will
// retain invalid value. User should force stop the app to update state after changing prop.
TERMUX_APP_AM_SOCKET_SERVER_ENABLED = enabled;
TermuxAppShellEnvironment.updateTermuxAppAMSocketServerEnabled(context);
}
/**

View File

@ -161,4 +161,12 @@ public class TermuxAppShellEnvironment {
}
}
/** Update {@link #ENV_TERMUX_APP__AM_SOCKET_SERVER_ENABLED} value in {@code environment}. */
public synchronized static void updateTermuxAppAMSocketServerEnabled(@NonNull Context currentPackageContext) {
if (termuxAppEnvironment == null) return;
termuxAppEnvironment.remove(ENV_TERMUX_APP__AM_SOCKET_SERVER_ENABLED);
ShellEnvironmentUtils.putToEnvIfSet(termuxAppEnvironment, ENV_TERMUX_APP__AM_SOCKET_SERVER_ENABLED,
TermuxAmSocketServer.getTermuxAppAMSocketServerEnabled(currentPackageContext));
}
}