本文整理汇总了Java中dalvik.system.DexFile.entries方法的典型用法代码示例。如果您正苦于以下问题:Java DexFile.entries方法的具体用法?Java DexFile.entries怎么用?Java DexFile.entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dalvik.system.DexFile
的用法示例。
在下文中一共展示了DexFile.entries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkDexValid
import dalvik.system.DexFile; //导入方法依赖的package包/类
public boolean checkDexValid(DexFile odexFile) throws IOException {
if (DexReleaser.isArt()) {
String applicationName = KernalConstants.RAW_APPLICATION_NAME;
try {
Enumeration<String> enumeration = odexFile.entries();
while (enumeration.hasMoreElements()) {
if (enumeration.nextElement().replace("/", ".").equals(applicationName)) {
return true;
}
}
return false;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
return true;
}
示例2: getClasses
import dalvik.system.DexFile; //导入方法依赖的package包/类
@Override
public Set<Class<?>> getClasses(String packageName) {
Set<Class<?>> classes = new HashSet<Class<?>>();
try {
DexFile dex = new DexFile(getContext().getApplicationInfo().sourceDir);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Enumeration<String> entries = dex.entries();
while (entries.hasMoreElements()) {
String entry = entries.nextElement();
if (entry.toLowerCase().startsWith(packageName.toLowerCase()))
classes.add(classLoader.loadClass(entry));
}
} catch (Exception e) {
Gdx.app.error("Errorororor", e.toString());
}
return classes;
}
示例3: loadClasses
import dalvik.system.DexFile; //导入方法依赖的package包/类
public void loadClasses() throws IOException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException {
DexFile dexFile = DexFile.loadDex(this.jarpath, File.createTempFile("opt", "dex", this.context.getCacheDir()).getPath(),
0);
String className = "";
for(Enumeration<String> classNames = dexFile.entries(); classNames.hasMoreElements();
className = classNames.nextElement()) {
if(!className.isEmpty()) {
//Remove partial classes <class>$1..
if(className.contains("$"))
className = className.substring(0, className.indexOf("$"));
this.loadClass(className);
}
}
}
示例4: addDexFile
import dalvik.system.DexFile; //导入方法依赖的package包/类
/**
* Multi-dex is a thing. Does that literally mean multiple dex files? apks?
* I have no idea, but if so you can add more here.
* @param path The path to a dex file (usually an apk)
*/
public void addDexFile(String path)
{
mResolver = new NestedResolver();
try
{
DexFile df = new DexFile(path);
for (Enumeration<String> iter = df.entries(); iter.hasMoreElements(); )
{
addClass(iter.nextElement());
}
}
catch (Exception ex)
{
Log.e(TAG, "Failed to load or parse dex file. This is fatal.");
ex.printStackTrace();
}
mResolver.resolve(this);
mResolver = null;
}
示例5: describeDexContents
import dalvik.system.DexFile; //导入方法依赖的package包/类
public void describeDexContents() {
if(!initialized) {
Log.w(TAG, "Dexter not initialized");
return;
}
Log.d(TAG, "Describing dex file " + getDexInternalStoragePath().getPath() + ", " + getDexInternalStoragePath().getAbsolutePath());
try {
DexFile dx = DexFile.loadDex(
getDexInternalStoragePath().getAbsolutePath(),
File.createTempFile("opt", "dex", mContext.getCacheDir()).getPath(),
0);
for(Enumeration<String> classNames = dx.entries(); classNames.hasMoreElements();) {
String className = classNames.nextElement();
Log.d(TAG, "class in dex: " + className);
}
}
catch (IOException e) {
Log.w(TAG, "Error opening " + getDexInternalStoragePath().getAbsolutePath(), e);
}
}
示例6: getClassesOfPackage
import dalvik.system.DexFile; //导入方法依赖的package包/类
/**
* Gets all of the classes within a package
* @param context the context
* @param packageName the package name to fetch classes from
* @return an list of named classes within package
*/
public static ArrayList<String> getClassesOfPackage(Context context, String packageName) {
ArrayList<String> classes = new ArrayList<>();
try {
String packageCodePath = context.getPackageCodePath();
DexFile df = new DexFile(packageCodePath);
for (Enumeration<String> iter = df.entries(); iter.hasMoreElements(); ) {
String className = iter.nextElement();
if (className.contains(packageName)) {
classes.add(className.substring(className.lastIndexOf(".") + 1, className.length()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
return classes;
}
示例7: getClasspathClasses
import dalvik.system.DexFile; //导入方法依赖的package包/类
private Set<Class<?>> getClasspathClasses() throws IOException, ClassNotFoundException {
Set<Class<?>> classes = new HashSet<Class<?>>();
DexFile dex = new DexFile(getContext().getApplicationInfo().sourceDir);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Enumeration<String> entries = dex.entries();
while (entries.hasMoreElements()) {
String entry = entries.nextElement();
if (entry.toLowerCase().startsWith(getContext().getPackageName().toLowerCase())) {
Class<?> clazz = classLoader.loadClass(entry);
if(clazz.isAnnotationPresent(RecordType.class)) {
modelClasses.add(clazz);
}
classes.add(clazz);
}
}
return classes;
}
示例8: getClasses
import dalvik.system.DexFile; //导入方法依赖的package包/类
private List getClasses(Context mContext, String packageName) {
ArrayList classes = new ArrayList<>();
try {
String packageCodePath = mContext.getPackageCodePath();
DexFile df = new DexFile(packageCodePath);
String regExp = "^" + packageName + ".\\w+$";
for (Enumeration<String> iter = df.entries(); iter.hasMoreElements(); ) {
String className = iter.nextElement();
if (className.matches(regExp)) {
classes.add(className);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return classes;
}
示例9: getClasses
import dalvik.system.DexFile; //导入方法依赖的package包/类
/**
* Scans all classes accessible from the context class loader which belong to the given package and subpackages.
*/
private static List<String> getClasses(Context c)
throws IOException {
ArrayList<String> classNames = new ArrayList<>();
String zpath = c.getApplicationInfo().sourceDir;
if (zpath == null) {
zpath = "/data/app/org.commcare.android.apk";
}
DexFile df = new DexFile(new File(zpath));
for (Enumeration<String> en = df.entries(); en.hasMoreElements(); ) {
String cn = en.nextElement();
loadClass(cn, classNames);
}
return classNames;
}
示例10: findAllClasses
import dalvik.system.DexFile; //导入方法依赖的package包/类
private Set<Class> findAllClasses(Context context, String packageName)
{
Set<Class> classes = new HashSet<Class>();
try {
DexFile dex = new DexFile(context.getPackageCodePath());
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Enumeration<String> entries = dex.entries();
while (entries.hasMoreElements()) {
String entry = entries.nextElement();
if (entry.toLowerCase().startsWith(packageName.toLowerCase())) {
classes.add(classLoader.loadClass(entry));
}
}
} catch (Exception ex) {
Log.e(ImportDatabaseLocator.this.getClass().getSimpleName(), "Error occurred while finding classes" + ex);
}
return classes;
}
示例11: resetDelegate
import dalvik.system.DexFile; //导入方法依赖的package包/类
/**
* Clear the existing delegate and return the new one, populated with the given dex files
*
* @param dexJars the .dex.jar files which will be managed by our delegate
*/
void resetDelegate(List<File> dexJars) {
mDelegate = new PathClassLoader("", "", this);
mManagedClassesToDexFile.clear();
for (File dexJar : dexJars) {
try {
DexFile dexFile = new DexFile(dexJar);
final Enumeration<String> entries = dexFile.entries();
while (entries.hasMoreElements()) {
mManagedClassesToDexFile.put(entries.nextElement(), dexFile);
}
} catch (IOException e) {
// Pass for now
}
}
}
示例12: scan
import dalvik.system.DexFile; //导入方法依赖的package包/类
@Override
public void scan(String[] packageNames) throws IOException {
if (applicationContext == null) {
throw new NullPointerException(
AndroidComponentScanner.class.getSimpleName()
+ ".APPLICATION_CONTEXT needs to be set before initialising "
+ DependencyInjection.class.getSimpleName());
}
DexFile dex = new DexFile(
applicationContext.getApplicationInfo().sourceDir);
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
Enumeration<String> entries = dex.entries();
while (entries.hasMoreElements()) {
String className = entries.nextElement();
if (classNameContainsPackage(packageNames, className)) {
try {
checkClassForAnnotations(classLoader.loadClass(className));
} catch (Exception e) {
Log.wtf(TAG, e);
}
}
}
}
示例13: loadClassList
import dalvik.system.DexFile; //导入方法依赖的package包/类
/**
* 获取所有类
* @param context 上下文
* @param pkgName 指定要获取类所在的包名
* @param baseClass 指定要获取类所实现的基类
*/
public static List<Class> loadClassList(@NonNull Context context, String pkgName, @Nullable Class baseClass) {
List<Class> classList = new ArrayList<>();
Context appContext = context.getApplicationContext();
ClassLoader classLoader = appContext.getClassLoader();
String entry = "";
try {
Field pathListField = findField(classLoader, "pathList");
Object dexPathList = pathListField.get(classLoader);
Field dexElementsField = findField(dexPathList, "dexElements");
Object[] dexElements = (Object[]) dexElementsField.get(dexPathList);
for (Object dexElement : dexElements) {
Field dexFileField = findField(dexElement, "dexFile");
DexFile dexFile = (DexFile) dexFileField.get(dexElement);
Enumeration<String> entries = dexFile.entries();
while (entries.hasMoreElements()) {
entry = entries.nextElement();
if (entry.startsWith("com.android") || entry.startsWith("android")) {
// 忽略 android 包名下的类
continue;
} else if (entry.contains("$")) {
// 忽略内部类
continue;
}
if (entry.contains(pkgName)) {
Class<?> clazz = dexFile.loadClass(entry, classLoader);
if (clazz == null || clazz.isInterface()) {
// 忽略接口
continue;
}
if (baseClass != null) {
if (baseClass.isAssignableFrom(clazz)) {
classList.add(clazz);
}
} else {
classList.add(clazz);
}
}
}
}
} catch (Exception | Error e) {
Log.e(TAG, "reflect fail. class = " + entry + " Exception: " + e.getMessage());
}
return classList;
}
示例14: a
import dalvik.system.DexFile; //导入方法依赖的package包/类
private ArrayList<Platform> a(PackageInfo packageInfo, Context context) {
ArrayList<Platform> arrayList = new ArrayList();
try {
DexFile dexFile = new DexFile(packageInfo.applicationInfo.sourceDir);
Enumeration entries = dexFile.entries();
dexFile.close();
} catch (Throwable th) {
Ln.e(th);
return null;
}
while (entries != null && entries.hasMoreElements()) {
String str = (String) entries.nextElement();
if (str.startsWith("cn.sharesdk") && !str.contains("$")) {
try {
Class cls = Class.forName(str);
if (!(cls == null || !Platform.class.isAssignableFrom(cls) || CustomPlatform.class.isAssignableFrom(cls))) {
Constructor constructor = cls.getConstructor(new Class[]{Context.class});
constructor.setAccessible(true);
arrayList.add((Platform) constructor.newInstance(new Object[]{context}));
}
} catch (Throwable th2) {
Ln.e(th2);
}
}
}
return arrayList;
}
示例15: scanDex
import dalvik.system.DexFile; //导入方法依赖的package包/类
/**
* @param dexFile DexFile
*/
private void scanDex(DexFile dexFile)
{
Enumeration<String> classNames = dexFile.entries();
while (classNames.hasMoreElements())
{
String className = classNames.nextElement();
if (className.startsWith("hcm.ssj.") && !className.contains("$"))
{
hsClassNames.add(className);
}
}
}