Skip to content

Commit

Permalink
Little other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Sep 21, 2023
1 parent 209994d commit 1a75d9b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 13 deletions.
46 changes: 44 additions & 2 deletions Website/src/activitys/ModuleTreeConf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,48 @@ function ModuleTreeConf() {
I am not responsible for anything that may happen to your phone by changing these informations. You do it at your own risk and
take the responsibility upon yourself and you are not to blame us or MMRL and its respected developers
</Alert>
<List
subheader={<ListSubheader sx={(theme) => ({ bgcolor: theme.palette.background.default })}>Command line interfaces</ListSubheader>}
>
<DialogEditTextListItem
inputLabel="Path"
type="text"
title="Installation cli"
disabled={!Shell.isMagiskSU()}
initialValue={settings.mod_msu_cli}
onSuccess={(value) => {
if (value) {
setSettings("mod_msu_cli", value);
}
}}
>
<StyledListItemText primary="Magisk install cli" secondary={settings.mod_msu_cli} />
</DialogEditTextListItem>
<DialogEditTextListItem
inputLabel="Path"
type="text"
title="Installation cli"
disabled={!Shell.isKernelSU()}
initialValue={settings.mod_ksu_cli}
onSuccess={(value) => {
if (value) {
setSettings("mod_ksu_cli", value);
}
}}
>
<StyledListItemText
primary={
<Box sx={{ display: "flex", alignItems: "center", justifyItems: "center" }}>
<KernelSULogo sx={{ mr: 1 }} width="1rem" height="1rem" />
KernelSU install cli
</Box>
}
secondary={settings.mod_ksu_cli}
/>
</DialogEditTextListItem>
</List>

<Divider />
<List subheader={<ListSubheader sx={(theme) => ({ bgcolor: theme.palette.background.default })}>Default paths</ListSubheader>}>
<DialogEditTextListItem
inputLabel="Path"
Expand Down Expand Up @@ -246,7 +288,7 @@ function ModuleTreeConf() {
}
type="text"
title="Mounted service location"
disabled={Shell.isMagiskSU()}
disabled={!Shell.isKernelSU()}
initialValue={settings.mod_mounted}
onSuccess={(value) => {
if (value) {
Expand Down Expand Up @@ -287,7 +329,7 @@ function ModuleTreeConf() {
}
type="text"
title="Boot complete service location"
disabled={Shell.isMagiskSU()}
disabled={!Shell.isKernelSU()}
initialValue={settings.mod_boot}
onSuccess={(value) => {
if (value) {
Expand Down
14 changes: 13 additions & 1 deletion Website/src/activitys/TerminalActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Ansi from "ansi-to-react";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import React from "react";
import { Shell } from "@Native/Shell";
import { useSettings } from "@Hooks/useSettings";

function useOnceCall(effect: React.EffectCallback, deps?: React.DependencyList | undefined) {
const isCalledRef = React.useRef(false);
Expand All @@ -21,6 +22,7 @@ function useOnceCall(effect: React.EffectCallback, deps?: React.DependencyList |

const TerminalActivity = () => {
const { context, extra } = useActivity<any>();
const { settings } = useSettings();
const [active, setActive] = React.useState<bool>(true);

const [lines, setLines] = React.useState<string[]>([]);
Expand All @@ -47,6 +49,16 @@ const TerminalActivity = () => {
}
};

const installCli = (path: string) => {
if (Shell.isMagiskSU()) {
return settings.mod_msu_cli.replace(/{path}/i, path);
} else if (Shell.isKernelSU()) {
return settings.mod_ksu_cli.replace(/{path}/i, path);
} else {
throw new Error("Unable to determine installation string");
}
};

const install = () => {
const { exploreInstall, path } = extra;

Expand Down Expand Up @@ -75,7 +87,7 @@ const TerminalActivity = () => {
} else {
// @ts-ignore
Terminal.exec(
Shell.installModuleString(path),
installCli(path),
(r) => {
addLine(r);
},
Expand Down
8 changes: 8 additions & 0 deletions Website/src/hooks/useSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export interface StorageDeclaration {
repos: StoredRepo[];
shade_value: number;

// cli
mod_msu_cli: string;
mod_ksu_cli: string;

// default paths
mod_tree: string;
mod_prop: string;
Expand Down Expand Up @@ -193,6 +197,10 @@ export const INITIAL_SETTINGS: StorageDeclaration = {
repos: [],
shade_value: -80,

//cli
mod_msu_cli: '/system/bin/magisk --install-module "{path}"',
mod_ksu_cli: '/data/adb/ksu/bin/ksud module install "{path}"',

// default paths
mod_tree: "/data/adb/modules",
mod_prop: "module.prop",
Expand Down
10 changes: 0 additions & 10 deletions Website/src/native/Shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,6 @@ class ShellClass extends Native<NativeShell> {
return false;
}
}

public installModuleString(path: string): string {
if (this.isMagiskSU()) {
return `/system/bin/magisk --install-module "${path}"`;
} else if (this.isKernelSU()) {
return `/data/adb/ksu/ksud module install "${path}"`;
} else {
throw new Error("Unable to determine installation string");
}
}
}

export const Shell: ShellClass = new ShellClass();

0 comments on commit 1a75d9b

Please sign in to comment.