Skip to content

Commit

Permalink
4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGLES3 authored Dec 21, 2023
1 parent 8c6e3ab commit cf3ecbb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "com.github.dan.NoStorageRestrict"
minSdk = 15
targetSdk = 32 // Target Android Sv2
versionCode = 2
versionName = "0.2.0"
versionCode = 4
versionName = "0.4.0"
}

buildFeatures {
Expand Down
Binary file added app/src/main.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
package com.github.dan.NoStorageRestrict;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class FolderRestrictionhook {
public void handleLoadPackage (XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {

public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
try {
XC_MethodHook.Unhook managedModeEnabled = XposedHelpers.findAndHookMethod(
"com.android.externalstorage.ExternalStorageProvider",
lpparam.classLoader,
"shouldBlockFromTree", String.class,
"shouldBlockDirectoryFromTree", String.class,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
} catch (NoSuchMethodError e) {
XposedBridge.log("Trying B hook");
try {
XC_MethodHook.Unhook managedModeEnabledB = XposedHelpers.findAndHookMethod(
"com.android.externalstorage.ExternalStorageProvider",
lpparam.classLoader,
"shouldBlockFromTree", String.class,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
} catch (NoSuchMethodError eB) {
XposedBridge.log("Both hooks failed");
eB.printStackTrace(); // Print the stack trace for debugging purposes
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
}

if (Constants.STORAGEMANAGER_NAME.equals(lpparam.packageName)) {
new FolderRestrictionhookA14().handleLoadPackage(lpparam);
}

if (Constants.STORAGEMANAGER_NAME.equals(lpparam.packageName))
new FolderRestrictionhook().handleLoadPackage(lpparam);
}

}
}

0 comments on commit cf3ecbb

Please sign in to comment.