-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
219 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
library/src/main/java/org/lsposed/hiddenapibypass/CoreOjClassLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.lsposed.hiddenapibypass; | ||
|
||
import android.os.Build; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
import java.lang.invoke.MethodHandle; | ||
import java.lang.reflect.Executable; | ||
|
||
import dalvik.system.PathClassLoader; | ||
|
||
@RequiresApi(Build.VERSION_CODES.P) | ||
final class CoreOjClassLoader extends PathClassLoader { | ||
private static String getCoreOjPath() { | ||
String bootClassPath = System.getProperty("java.boot.class.path", ""); | ||
assert bootClassPath != null; | ||
return bootClassPath.split(":", 2)[0]; | ||
} | ||
|
||
CoreOjClassLoader() { | ||
super(getCoreOjPath(), null); | ||
} | ||
|
||
@Override | ||
public Class<?> loadClass(String name) throws ClassNotFoundException { | ||
if (Object.class.getName().equals(name)) { | ||
return Object.class; | ||
} | ||
try { | ||
return findClass(name); | ||
} catch (ClassNotFoundException ignored) { | ||
// no class file in jar before art moved to apex. | ||
} | ||
if (Executable.class.getName().equals(name)) { | ||
return Helper.Executable.class; | ||
} else if (MethodHandle.class.getName().equals(name)) { | ||
return Helper.MethodHandle.class; | ||
} else if (Class.class.getName().equals(name)) { | ||
return Helper.Class.class; | ||
} | ||
return super.loadClass(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.