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

1.6.5 #34

Merged
merged 3 commits into from
Sep 21, 2023
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
4 changes: 2 additions & 2 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId 'com.dergoogler.mmrl'
minSdk 26
targetSdk 33
versionName '1.6.4'
versionCode 164
versionName '1.6.5'
versionCode 165
externalNativeBuild {
cmake {
cppFlags "-llog"
Expand Down
4 changes: 2 additions & 2 deletions Android/app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 163,
"versionName": "1.6.3",
"versionCode": 165,
"versionName": "1.6.5",
"outputFile": "app-release.apk"
}
],
Expand Down
5 changes: 4 additions & 1 deletion Android/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ add_library(native-log-lib SHARED
log.cpp)

add_library(native-properties-lib SHARED
properties.cpp)
properties.cpp)

add_library(native-shell-lib SHARED
shell.cpp)
136 changes: 136 additions & 0 deletions Android/app/src/main/cpp/shell.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#include <sys/prctl.h>
#include <cstdint>
#include <cstring>
#include <cstdio>
#include <unistd.h>
#include <malloc.h>
#include <fcntl.h>
#include <jni.h>

bool path_detection(char **paths) {
int len = sizeof(paths) / sizeof(paths[0]);

bool bRet = false;
for (int i = 0; i < len; i++) {
if (open(paths[i], O_RDONLY) >= 0) {
bRet = true;
break;
}
if (0 == access(paths[i], R_OK)) {
bRet = true;
break;
}
}

return bRet;
}

bool mount_detection(char **searchable_mounts) {
int len = sizeof(searchable_mounts) / sizeof(searchable_mounts[0]);

bool bRet = false;

FILE *fp = fopen("/proc/self/mounts", "r");
if (fp == nullptr) {
return false;
}

fseek(fp, 0L, SEEK_END);
long size = ftell(fp);
/* For some reason size comes as zero */
if (size == 0)
size = 20000; /*This will differ for different devices */
char *buffer = (char *) calloc(size, sizeof(char));
if (buffer == nullptr) {
return false;
}

size_t read = fread(buffer, 1, size, fp);
int count = 0;
for (int i = 0; i < len; i++) {
char *rem = strstr(buffer, searchable_mounts[i]);
if (rem != nullptr) {
count++;
break;
}
}
if (count > 0)
bRet = true;

exit:

free(buffer);
fclose(fp);

return bRet;
}

extern "C"
JNIEXPORT jboolean JNICALL
Java_com_dergoogler_core_NativeShell_isMagiskSU(JNIEnv *env, jclass clazz) {
static char *mounts[] = {
"magisk",
"core/mirror",
"core/img"
};
static char *paths[] = {
"/system/bin/magisk",
"/data/adb/magisk.db",
"/data/adb/magisk/busybox",
"/data/adb/magisk/magisk64",
"/data/adb/magisk/magiskboot",
"/data/adb/magisk/magiskinit",
"/data/adb/magisk/magiskpolicy"
};

bool bRet = false;
do {
bRet = path_detection(paths);
if (bRet)
break;
bRet = mount_detection(mounts);
if (bRet)
break;
} while (false);

if (bRet) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}

extern "C"
JNIEXPORT jboolean JNICALL
Java_com_dergoogler_core_NativeShell_isKernelSU(JNIEnv *env, jclass clazz) {
static char *mounts[] = {
"KSU",
"ksu",
"KERNELSU",
"kernelsu"
};
static char *paths[] = {
// syslink
"/data/adb/ksud",
"/data/adb/ksu/modules.img",
"/data/adb/ksu/bin/busybox",
"/data/adb/ksu/bin/ksud",
"/data/adb/ksu/bin/resetprop"
};

bool bRet = false;
do {
bRet = path_detection(paths);
if (bRet)
break;
bRet = mount_detection(mounts);
if (bRet)
break;
} while (false);

if (bRet) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
9 changes: 9 additions & 0 deletions Android/app/src/main/java/com/dergoogler/core/NativeOS.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,13 @@ public void setNavigationBarColor(String color) {
e.printStackTrace();
}
}

@JavascriptInterface
public void shareText(String title, String body) {
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
intent.putExtra(android.content.Intent.EXTRA_TEXT, body);
ctx.startActivity(Intent.createChooser(intent, title));
}
}
12 changes: 11 additions & 1 deletion Android/app/src/main/java/com/dergoogler/core/NativeShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.webkit.JavascriptInterface;
import android.webkit.WebView;

import com.topjohnwu.superuser.CallbackList;
import com.topjohnwu.superuser.Shell;
import com.topjohnwu.superuser.ShellUtils;

Expand All @@ -19,6 +18,10 @@ public NativeShell(WebView wv) {
this.wv = wv;
}

static {
System.loadLibrary("native-shell-lib");
}

@JavascriptInterface
public void exec(String command) {
Shell.cmd(command).exec();
Expand Down Expand Up @@ -50,6 +53,13 @@ public boolean isSuAvailable() {
}
}

@JavascriptInterface
public static native boolean isMagiskSU();

@JavascriptInterface
public static native boolean isKernelSU();


@JavascriptInterface
public boolean isAppGrantedRoot() {
return Shell.cmd("if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " +
Expand Down
4 changes: 2 additions & 2 deletions Website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"description": "",
"config": {
"application_id": "com.dergoogler.mmrl",
"version_name": "1.6.4",
"version_code": 164
"version_name": "1.6.5",
"version_code": 165
},
"main": "index.tsx",
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion Website/src/activitys/ConfigureActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const ConfigureActivity = () => {
const { context, extra } = useActivity<Extra>();

const config: string = React.useMemo(() => {
const file = new SuFile(`${settings.mod_tree}/${extra.moduleid}/system/usr/share/mmrl/config/${extra.moduleid}.js`);
const file = new SuFile(`${settings.mod_tree}/${extra.moduleid}/system/usr/share/mmrl/config/${extra.moduleid}.mdx`);

if (file.exist()) {
return file.read();
Expand Down
8 changes: 4 additions & 4 deletions Website/src/activitys/MainApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const MainApplication = () => {
const filteredModules = (modules: Module[], search: string) =>
modules.filter(
(module) =>
module.prop_url.id.toLowerCase().includes(search.toLowerCase()) ||
module.prop_url.name.toLowerCase().includes(search.toLowerCase()) ||
module.prop_url.author.toLowerCase().includes(search.toLowerCase()) ||
module.prop_url.description.toLowerCase().includes(search.toLowerCase())
module.props.id.toLowerCase().includes(search.toLowerCase()) ||
module.props.name.toLowerCase().includes(search.toLowerCase()) ||
module.props.author.toLowerCase().includes(search.toLowerCase()) ||
module.props.description.toLowerCase().includes(search.toLowerCase())
);

const renderTabs = (): TabbarRenderTab[] => {
Expand Down
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.isMagisk}
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.isMagisk}
disabled={!Shell.isKernelSU()}
initialValue={settings.mod_boot}
onSuccess={(value) => {
if (value) {
Expand Down
6 changes: 3 additions & 3 deletions Website/src/activitys/RepoActivity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ const RepoActivity = () => {
{
name: "Magisk Modules Alternative Repository",
module_count: 100,
link: "https://raw.githubusercontent.com/Magisk-Modules-Alt-Repo/json/main/modules.json",
link: "https://api.mmrl.dergoogler.com/mmar.json",
},
{
name: "Googlers Magisk Repo",
module_count: 3,
link: "https://raw.githubusercontent.com/Googlers-Repo/googlers-repo.github.io/master/modules.json",
link: "https://api.mmrl.dergoogler.com/gmr.json",
},
{
name: "Magisk Modules Repo (Official)",
module_count: 108,
link: "https://raw.githubusercontent.com/Magisk-Modules-Repo/submission/modules/modules.json",
link: "https://api.mmrl.dergoogler.com/mmr.json",
},
];

Expand Down
Loading