mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-21 01:07:34 +01:00
Use options.checkPackagePrivateAccess
This commit is contained in:
parent
b2cf6b1d32
commit
3d3db44773
@ -67,7 +67,7 @@ public class baksmali {
|
|||||||
|
|
||||||
options.classPath = ClassPath.fromClassPath(options.bootClassPathDirs,
|
options.classPath = ClassPath.fromClassPath(options.bootClassPathDirs,
|
||||||
Iterables.concat(options.bootClassPathEntries, extraClassPathEntries), dexFile,
|
Iterables.concat(options.bootClassPathEntries, extraClassPathEntries), dexFile,
|
||||||
options.apiLevel);
|
options.apiLevel, options.checkPackagePrivateAccess);
|
||||||
|
|
||||||
if (options.customInlineDefinitions != null) {
|
if (options.customInlineDefinitions != null) {
|
||||||
options.inlineResolver = new CustomInlineMethodResolver(options.classPath,
|
options.inlineResolver = new CustomInlineMethodResolver(options.classPath,
|
||||||
|
@ -238,7 +238,7 @@ public class main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.apiLevel >= 17) {
|
if (options.apiLevel == 17) {
|
||||||
options.checkPackagePrivateAccess = true;
|
options.checkPackagePrivateAccess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class ClassPath {
|
|||||||
|
|
||||||
@Nonnull private final TypeProto unknownClass;
|
@Nonnull private final TypeProto unknownClass;
|
||||||
@Nonnull private HashMap<String, ClassDef> availableClasses = Maps.newHashMap();
|
@Nonnull private HashMap<String, ClassDef> availableClasses = Maps.newHashMap();
|
||||||
private int api;
|
private boolean checkPackagePrivateAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ClassPath instance that can load classes from the given dex files
|
* Creates a new ClassPath instance that can load classes from the given dex files
|
||||||
@ -77,12 +77,22 @@ public class ClassPath {
|
|||||||
* @param api API level
|
* @param api API level
|
||||||
*/
|
*/
|
||||||
public ClassPath(@Nonnull Iterable<DexFile> classPath, int api) {
|
public ClassPath(@Nonnull Iterable<DexFile> classPath, int api) {
|
||||||
|
this(Lists.newArrayList(classPath), api == 17);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ClassPath instance that can load classes from the given dex files
|
||||||
|
*
|
||||||
|
* @param classPath An iterable of DexFile objects. When loading a class, these dex files will be searched in order
|
||||||
|
* @param checkPackagePrivateAccess Whether checkPackagePrivateAccess is needed, enabled for ONLY early API 17 by default
|
||||||
|
*/
|
||||||
|
public ClassPath(@Nonnull Iterable<DexFile> classPath, boolean checkPackagePrivateAccess) {
|
||||||
// add fallbacks for certain special classes that must be present
|
// add fallbacks for certain special classes that must be present
|
||||||
Iterable<DexFile> dexFiles = Iterables.concat(classPath, Lists.newArrayList(getBasicClasses()));
|
Iterable<DexFile> dexFiles = Iterables.concat(classPath, Lists.newArrayList(getBasicClasses()));
|
||||||
|
|
||||||
unknownClass = new UnknownClassProto(this);
|
unknownClass = new UnknownClassProto(this);
|
||||||
loadedClasses.put(unknownClass.getType(), unknownClass);
|
loadedClasses.put(unknownClass.getType(), unknownClass);
|
||||||
this.api = api;
|
this.checkPackagePrivateAccess = checkPackagePrivateAccess;
|
||||||
|
|
||||||
loadPrimitiveType("Z");
|
loadPrimitiveType("Z");
|
||||||
loadPrimitiveType("B");
|
loadPrimitiveType("B");
|
||||||
@ -154,20 +164,28 @@ public class ClassPath {
|
|||||||
return unknownClass;
|
return unknownClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getApi() {
|
public boolean needCheckPackagePrivateAccess() {
|
||||||
return api;
|
return checkPackagePrivateAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static ClassPath fromClassPath(Iterable<String> classPathDirs, Iterable<String> classPath, DexFile dexFile,
|
public static ClassPath fromClassPath(Iterable<String> classPathDirs, Iterable<String> classPath, DexFile dexFile,
|
||||||
int api) {
|
int api) {
|
||||||
|
return fromClassPath(classPathDirs, classPath, dexFile, api, api == 17);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static ClassPath fromClassPath(Iterable<String> classPathDirs, Iterable<String> classPath, DexFile dexFile,
|
||||||
|
int api, boolean checkPackagePrivateAccess) {
|
||||||
ArrayList<DexFile> dexFiles = Lists.newArrayList();
|
ArrayList<DexFile> dexFiles = Lists.newArrayList();
|
||||||
|
|
||||||
for (String classPathEntry: classPath) {
|
for (String classPathEntry: classPath) {
|
||||||
|
try {
|
||||||
dexFiles.add(loadClassPathEntry(classPathDirs, classPathEntry, api));
|
dexFiles.add(loadClassPathEntry(classPathDirs, classPathEntry, api));
|
||||||
|
} catch (ExceptionWithContext e){}
|
||||||
}
|
}
|
||||||
dexFiles.add(dexFile);
|
dexFiles.add(dexFile);
|
||||||
return new ClassPath(dexFiles, api);
|
return new ClassPath(dexFiles, checkPackagePrivateAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern dalvikCacheOdexPattern = Pattern.compile("@([^@]+)@classes.dex$");
|
private static final Pattern dalvikCacheOdexPattern = Pattern.compile("@([^@]+)@classes.dex$");
|
||||||
|
@ -628,7 +628,7 @@ public class ClassProto implements TypeProto {
|
|||||||
for (int i=0; i<vtable.size(); i++) {
|
for (int i=0; i<vtable.size(); i++) {
|
||||||
Method superMethod = vtable.get(i);
|
Method superMethod = vtable.get(i);
|
||||||
if (methodSignaturesMatch(superMethod, virtualMethod)) {
|
if (methodSignaturesMatch(superMethod, virtualMethod)) {
|
||||||
if (classPath.getApi() != 17 || canAccess(superMethod)) {
|
if (!classPath.needCheckPackagePrivateAccess() || canAccess(superMethod)) {
|
||||||
if (replaceExisting) {
|
if (replaceExisting) {
|
||||||
vtable.set(i, virtualMethod);
|
vtable.set(i, virtualMethod);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user