mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-20 16:57: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,
|
||||
Iterables.concat(options.bootClassPathEntries, extraClassPathEntries), dexFile,
|
||||
options.apiLevel);
|
||||
options.apiLevel, options.checkPackagePrivateAccess);
|
||||
|
||||
if (options.customInlineDefinitions != null) {
|
||||
options.inlineResolver = new CustomInlineMethodResolver(options.classPath,
|
||||
|
@ -238,7 +238,7 @@ public class main {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.apiLevel >= 17) {
|
||||
if (options.apiLevel == 17) {
|
||||
options.checkPackagePrivateAccess = true;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class ClassPath {
|
||||
|
||||
@Nonnull private final TypeProto unknownClass;
|
||||
@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
|
||||
@ -77,12 +77,22 @@ public class ClassPath {
|
||||
* @param api API level
|
||||
*/
|
||||
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
|
||||
Iterable<DexFile> dexFiles = Iterables.concat(classPath, Lists.newArrayList(getBasicClasses()));
|
||||
|
||||
unknownClass = new UnknownClassProto(this);
|
||||
loadedClasses.put(unknownClass.getType(), unknownClass);
|
||||
this.api = api;
|
||||
this.checkPackagePrivateAccess = checkPackagePrivateAccess;
|
||||
|
||||
loadPrimitiveType("Z");
|
||||
loadPrimitiveType("B");
|
||||
@ -154,20 +164,28 @@ public class ClassPath {
|
||||
return unknownClass;
|
||||
}
|
||||
|
||||
public int getApi() {
|
||||
return api;
|
||||
public boolean needCheckPackagePrivateAccess() {
|
||||
return checkPackagePrivateAccess;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ClassPath fromClassPath(Iterable<String> classPathDirs, Iterable<String> classPath, DexFile dexFile,
|
||||
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();
|
||||
|
||||
for (String classPathEntry: classPath) {
|
||||
dexFiles.add(loadClassPathEntry(classPathDirs, classPathEntry, api));
|
||||
try {
|
||||
dexFiles.add(loadClassPathEntry(classPathDirs, classPathEntry, api));
|
||||
} catch (ExceptionWithContext e){}
|
||||
}
|
||||
dexFiles.add(dexFile);
|
||||
return new ClassPath(dexFiles, api);
|
||||
return new ClassPath(dexFiles, checkPackagePrivateAccess);
|
||||
}
|
||||
|
||||
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++) {
|
||||
Method superMethod = vtable.get(i);
|
||||
if (methodSignaturesMatch(superMethod, virtualMethod)) {
|
||||
if (classPath.getApi() != 17 || canAccess(superMethod)) {
|
||||
if (!classPath.needCheckPackagePrivateAccess() || canAccess(superMethod)) {
|
||||
if (replaceExisting) {
|
||||
vtable.set(i, virtualMethod);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user