当前位置: 首页>>代码示例>>Java>>正文


Java DexFile.entries方法代码示例

本文整理汇总了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;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:19,代码来源:BundleReleaser.java

示例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;
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:18,代码来源:AndroidLauncher.java

示例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);
        }
    }
}
 
开发者ID:charslab,项目名称:Android-Hotpatch,代码行数:23,代码来源:Hotpatch.java

示例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;
}
 
开发者ID:Nordskog,项目名称:ClassHunter,代码行数:29,代码来源:PackageTree.java

示例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);
    }
}
 
开发者ID:aphexyuri,项目名称:dexter,代码行数:23,代码来源:Dexter.java

示例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;
}
 
开发者ID:Commit451,项目名称:ParcelCheck,代码行数:24,代码来源:ObjectHelper.java

示例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;
}
 
开发者ID:jaumecornado,项目名称:DroidNubeKit,代码行数:19,代码来源:DroidNubeKit.java

示例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;
}
 
开发者ID:yzbzz,项目名称:beautifullife,代码行数:18,代码来源:StudyFragment.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:23,代码来源:AndroidPrototypeFactorySetup.java

示例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;
}
 
开发者ID:mcruncher,项目名称:worshipsongs-android,代码行数:19,代码来源:ImportDatabaseLocator.java

示例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
    }
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:21,代码来源:DelegatingClassLoader.java

示例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);
			}
		}
	}
}
 
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:26,代码来源:AndroidComponentScanner.java

示例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;
}
 
开发者ID:JeremyHe-cn,项目名称:Mvp,代码行数:58,代码来源:ReflectUtils.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:i.java

示例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);
        }
    }
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:16,代码来源:SSJDescriptor.java


注:本文中的dalvik.system.DexFile.entries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。