Java Code Examples for android.content.pm.PackageParser

The following are top voted examples for showing how to use android.content.pm.PackageParser. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: VirtualAPK   File: LoadedPlugin.java   View source code 6 votes vote down vote up
public Intent getLeanbackLaunchIntent() {
    ContentResolver resolver = this.mPluginContext.getContentResolver();
    Intent launcher = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);

    for (PackageParser.Activity activity : this.mPackage.activities) {
        for (PackageParser.ActivityIntentInfo intentInfo : activity.intents) {
            if (intentInfo.match(resolver, launcher, false, TAG) > 0) {
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.setComponent(activity.getComponentName());
                intent.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
                return intent;
            }
        }
    }

    return null;
}
 
Example 2
Project: VirtualHook   File: PackageParserCompat.java   View source code 6 votes vote down vote up
public static Package parsePackage(PackageParser parser, File packageFile, int flags) throws Throwable {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    } else {
        return mirror.android.content.pm.PackageParser.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    }
}
 
Example 3
Project: VirtualHook   File: PackageParserCompat.java   View source code 6 votes vote down vote up
public static PackageInfo generatePackageInfo(Package p, int flags, long firstInstallTime, long lastUpdateTime) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                null, sUserState);
    } else if (API_LEVEL >= LOLLIPOP) {
        if (PackageParserLollipop22.generatePackageInfo != null) {
            return PackageParserLollipop22.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                    null, sUserState);
        } else {
            return PackageParserLollipop.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                    null, sUserState);
        }
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                null, sUserState);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                null);
    } else {
        return mirror.android.content.pm.PackageParser.generatePackageInfo.call(p, GIDS, flags, firstInstallTime,
                lastUpdateTime);
    }
}
 
Example 4
Project: VirtualHook   File: PackageParserCompat.java   View source code 6 votes vote down vote up
public static void collectCertificates(PackageParser parser, Package p, int flags) throws Throwable {
    if (API_LEVEL >= N) {
        PackageParserNougat.collectCertificates.callWithException(p, flags);
    } else if (API_LEVEL >= M) {
        PackageParserMarshmallow.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        PackageParserLollipop22.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= LOLLIPOP) {
        PackageParserLollipop.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        PackageParserJellyBean17.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= JELLY_BEAN) {
        PackageParserJellyBean.collectCertificates.callWithException(parser, p, flags);
    } else {
        mirror.android.content.pm.PackageParser.collectCertificates.call(parser, p, flags);
    }
}
 
Example 5
Project: TPlayer   File: PackageParserCompat.java   View source code 6 votes vote down vote up
public static Package parsePackage(PackageParser parser, File packageFile, int flags) throws Throwable {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    } else {
        return mirror.android.content.pm.PackageParser.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    }
}
 
Example 6
Project: TPlayer   File: PackageParserCompat.java   View source code 6 votes vote down vote up
public static void collectCertificates(PackageParser parser, Package p, int flags) throws Throwable {
    if (API_LEVEL >= N) {
        PackageParserNougat.collectCertificates.callWithException(p, flags);
    } else if (API_LEVEL >= M) {
        PackageParserMarshmallow.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        PackageParserLollipop22.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= LOLLIPOP) {
        PackageParserLollipop.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        PackageParserJellyBean17.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= JELLY_BEAN) {
        PackageParserJellyBean.collectCertificates.callWithException(parser, p, flags);
    } else {
        mirror.android.content.pm.PackageParser.collectCertificates.call(parser, p, flags);
    }
}
 
Example 7
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
protected ResolveInfo newResult(PackageParser.ServiceIntentInfo filter, int match) {
	final PackageParser.Service service = filter.service;
	ServiceInfo si = PackageParserCompat.generateServiceInfo(service, mFlags);
	if (si == null) {
		return null;
	}
	final ResolveInfo res = new ResolveInfo();
	res.serviceInfo = si;
	if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
		res.filter = filter;
	}
	res.priority = filter.getPriority();
	res.preferredOrder = service.owner.mPreferredOrder;
	res.match = match;
	res.isDefault = filter.hasDefault;
	res.labelRes = filter.labelRes;
	res.nonLocalizedLabel = filter.nonLocalizedLabel;
	res.icon = filter.icon;
	return res;
}
 
Example 8
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public PackageInfo getPackageInfo(String packageName, int flags, int userId) {
	synchronized (mPackages) {
		PackageParser.Package pkg = mPackages.get(packageName);
		if (pkg != null) {
			AppSetting setting = (AppSetting) pkg.mExtras;
			if ((flags & PackageManager.GET_SIGNATURES) != 0 && pkg.mSignatures == null) {
				if (pkg.mAppMetaData != null && pkg.mAppMetaData.containsKey(Constants.FEATURE_FAKE_SIGNATURE)) {
					String sig = pkg.mAppMetaData.getString("fake-signature");
					if (sig != null) {
						pkg.mSignatures = new Signature[] {new Signature(sig)};
					}
				} else {
					PackageParserCompat.collectCertificates(setting.parser, pkg, PackageParser.PARSE_IS_SYSTEM);
				}
			}
			PackageInfo packageInfo = PackageParserCompat.generatePackageInfo(pkg, flags,
					getFirstInstallTime(pkg), getLastInstallTime(pkg));
			if (packageInfo != null) {
				ComponentFixer.fixApplicationInfo(setting, packageInfo.applicationInfo, userId);
				return packageInfo;
			}
		}
	}
	return null;
}
 
Example 9
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public boolean activitySupportsIntent(ComponentName component, Intent intent, String resolvedType) {
	synchronized (mPackages) {
		PackageParser.Activity a = mActivities.mActivities.get(component);
		if (a == null) {
			return false;
		}
		for (int i = 0; i < a.intents.size(); i++) {
			if (a.intents.get(i).match(intent.getAction(), resolvedType, intent.getScheme(), intent.getData(),
					intent.getCategories(), TAG) >= 0) {
				return true;
			}
		}
		return false;
	}
}
 
Example 10
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
	checkUserId(userId);
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		final ActivityInfo ai = getActivityInfo(comp, flags, userId);
		if (ai != null) {
			final ResolveInfo ri = new ResolveInfo();
			ri.activityInfo = ai;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		final String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mActivities.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities);
		}
		return new ArrayList<ResolveInfo>();
	}
}
 
Example 11
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public List<ResolveInfo> queryIntentReceivers(Intent intent, String resolvedType, int flags, int userId) {
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		ActivityInfo ai = getReceiverInfo(comp, flags, userId);
		if (ai != null) {
			ResolveInfo ri = new ResolveInfo();
			ri.activityInfo = ai;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mReceivers.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mReceivers.queryIntentForPackage(intent, resolvedType, flags, pkg.receivers);
		}
		return null;
	}
}
 
Example 12
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public List<ReceiverInfo> queryReceivers(String processName, int uid, int flags) {
	int userId = VUserHandle.getUserId(uid);
	checkUserId(userId);
	ArrayList<ReceiverInfo> finalList = new ArrayList<>(3);
	synchronized (mPackages) {
		for (PackageParser.Activity a : mReceivers.mActivities.values()) {
			if (a.info.processName.equals(processName)) {
				ActivityInfo receiverInfo = PackageParserCompat.generateActivityInfo(a, flags);
				if (receiverInfo != null) {
					AppSetting settings = (AppSetting) mPackages.get(receiverInfo.packageName).mExtras;
					ComponentFixer.fixComponentInfo(settings, receiverInfo, userId);
					ComponentName component = ComponentUtils.toComponentName(receiverInfo);
					IntentFilter[] filters = null;
					if (a.intents != null) {
						filters = a.intents.toArray(new IntentFilter[a.intents.size()]);
					}
					finalList.add(new ReceiverInfo(component, filters, receiverInfo.permission));
				}
			}
		}
	}
	return finalList;
}
 
Example 13
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public List<ResolveInfo> queryIntentServices(Intent intent, String resolvedType, int flags, int userId) {
	checkUserId(userId);
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		final ServiceInfo si = getServiceInfo(comp, flags, userId);
		if (si != null) {
			final ResolveInfo ri = new ResolveInfo();
			ri.serviceInfo = si;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mServices.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mServices.queryIntentForPackage(intent, resolvedType, flags, pkg.services);
		}
		return null;
	}
}
 
Example 14
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public List<ResolveInfo> queryIntentContentProviders(Intent intent, String resolvedType, int flags, int userId) {
	checkUserId(userId);
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		final ProviderInfo pi = getProviderInfo(comp, flags, userId);
		if (pi != null) {
			final ResolveInfo ri = new ResolveInfo();
			ri.providerInfo = pi;
			list.add(ri);
		}
		return list;
	}
	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mProviders.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers);
		}
		return null;
	}
}
 
Example 15
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public VParceledListSlice<ProviderInfo> queryContentProviders(String processName, int vuid, int flags) {
	int userId = VUserHandle.getUserId(vuid);
	checkUserId(userId);
	ArrayList<ProviderInfo> finalList = new ArrayList<>(3);
	// reader
	synchronized (mPackages) {
		for (PackageParser.Provider p : mProvidersByComponent.values()) {
			AppSetting setting = (AppSetting) p.owner.mExtras;
			if (processName == null || setting.appId == VUserHandle.getAppId(vuid) && p.info.processName.equals(processName)) {
				ProviderInfo providerInfo = PackageParserCompat.generateProviderInfo(p, flags);
				ComponentFixer.fixApplicationInfo(setting, providerInfo.applicationInfo, userId);
				finalList.add(providerInfo);
			}
		}
	}
	if (!finalList.isEmpty()) {
		Collections.sort(finalList, mProviderInitOrderSorter);
	}
	return new VParceledListSlice<>(finalList);
}
 
Example 16
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
public List<String> querySharedPackages(String packageName) {
	synchronized (mPackages) {
		PackageParser.Package p = mPackages.get(packageName);
		if (p == null || p.mSharedUserId == null) {
			// noinspection unchecked
			return Collections.EMPTY_LIST;
		}
		ArrayList<String> list = new ArrayList<>();
		for (PackageParser.Package one : mPackages.values()) {
			if (TextUtils.equals(one.mSharedUserId, p.mSharedUserId)) {
				list.add(one.packageName);
			}
		}
		return list;
	}
}
 
Example 17
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType, int flags,
		ArrayList<PackageParser.Activity> packageActivities) {
	if (packageActivities == null) {
		return null;
	}
	mFlags = flags;
	final boolean defaultOnly = (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0;
	final int N = packageActivities.size();
	ArrayList<PackageParser.ActivityIntentInfo[]> listCut = new ArrayList<PackageParser.ActivityIntentInfo[]>(
			N);

	ArrayList<PackageParser.ActivityIntentInfo> intentFilters;
	for (int i = 0; i < N; ++i) {
		intentFilters = packageActivities.get(i).intents;
		if (intentFilters != null && intentFilters.size() > 0) {
			PackageParser.ActivityIntentInfo[] array = new PackageParser.ActivityIntentInfo[intentFilters
					.size()];
			intentFilters.toArray(array);
			listCut.add(array);
		}
	}
	return super.queryIntentFromList(intent, resolvedType, defaultOnly, listCut);
}
 
Example 18
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
public final void addActivity(PackageParser.Activity a, String type) {
	final boolean systemApp = isSystemApp(a.info.applicationInfo);
	mActivities.put(a.getComponentName(), a);
	if (DEBUG_SHOW_INFO)
		Log.v(TAG, "  " + type + " "
				+ (a.info.nonLocalizedLabel != null ? a.info.nonLocalizedLabel : a.info.name) + ":");
	if (DEBUG_SHOW_INFO)
		Log.v(TAG, "    Class=" + a.info.name);
	final int NI = a.intents.size();
	for (int j = 0; j < NI; j++) {
		PackageParser.ActivityIntentInfo intent = a.intents.get(j);
		if (!systemApp && intent.getPriority() > 0 && "activity".equals(type)) {
			intent.setPriority(0);
			Log.w(TAG, "Package " + a.info.applicationInfo.packageName + " has activity " + a.className
					+ " with priority > 0, forcing to 0");
		}
		if (DEBUG_SHOW_INFO) {
			Log.v(TAG, "    IntentFilter:");
			intent.dump(new LogPrinter(Log.VERBOSE, TAG), "      ");
		}
		addFilter(intent);
	}
}
 
Example 19
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
public final void removeActivity(PackageParser.Activity a, String type) {
	mActivities.remove(a.getComponentName());
	if (DEBUG_SHOW_INFO) {
		Log.v(TAG, "  " + type + " "
				+ (a.info.nonLocalizedLabel != null ? a.info.nonLocalizedLabel : a.info.name) + ":");
		Log.v(TAG, "    Class=" + a.info.name);
	}
	final int NI = a.intents.size();
	for (int j = 0; j < NI; j++) {
		PackageParser.ActivityIntentInfo intent = a.intents.get(j);
		if (DEBUG_SHOW_INFO) {
			Log.v(TAG, "    IntentFilter:");
			intent.dump(new LogPrinter(Log.VERBOSE, TAG), "      ");
		}
		removeFilter(intent);
	}
}
 
Example 20
Project: container   File: VPackageManagerService.java   View source code 6 votes vote down vote up
@Override
protected ResolveInfo newResult(PackageParser.ActivityIntentInfo info, int match) {
	final PackageParser.Activity activity = info.activity;
	ActivityInfo ai = PackageParserCompat.generateActivityInfo(activity, mFlags);
	if (ai == null) {
		return null;
	}
	final ResolveInfo res = new ResolveInfo();
	res.activityInfo = ai;
	if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
		res.filter = info;
	}
	res.priority = info.getPriority();
	res.preferredOrder = activity.owner.mPreferredOrder;
	// System.out.println("Result: " + res.activityInfo.className +
	// " = " + res.priority);
	res.match = match;
	res.isDefault = info.hasDefault;
	res.labelRes = info.labelRes;
	res.nonLocalizedLabel = info.nonLocalizedLabel;
	res.icon = info.icon;
	return res;
}
 
Example 21
Project: VirtualAPK   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static final PackageParser.Package parsePackage(final Context context, final File apk, final int flags) throws PackageParser.PackageParserException {
    if (Build.VERSION.SDK_INT >= 24) {
        return PackageParserV24.parsePackage(context, apk, flags);
    } else if (Build.VERSION.SDK_INT >= 21) {
        return PackageParserLollipop.parsePackage(context, apk, flags);
    } else {
        return PackageParserLegacy.parsePackage(context, apk, flags);
    }
}
 
Example 22
Project: VirtualAPK   File: PackageParserCompat.java   View source code 5 votes vote down vote up
static final PackageParser.Package parsePackage(Context context, File apk, int flags) throws PackageParser.PackageParserException {
    PackageParser parser = new PackageParser();
    PackageParser.Package pkg = parser.parsePackage(apk, flags);
    ReflectUtil.invokeNoException(PackageParser.class, null, "collectCertificates",
            new Class[]{PackageParser.Package.class, int.class}, pkg, flags);
    return pkg;
}
 
Example 23
Project: VirtualAPK   File: PackageParserCompat.java   View source code 5 votes vote down vote up
static final PackageParser.Package parsePackage(final Context context, final File apk, final int flags) throws PackageParser.PackageParserException {
    PackageParser parser = new PackageParser();
    PackageParser.Package pkg = parser.parsePackage(apk, flags);
    try {
        parser.collectCertificates(pkg, flags);
    } catch (Throwable e) {
        // ignored
    }
    return pkg;
}
 
Example 24
Project: VirtualAPK   File: PackageParserCompat.java   View source code 5 votes vote down vote up
static final PackageParser.Package parsePackage(Context context, File apk, int flags) {
    PackageParser parser = new PackageParser(apk.getAbsolutePath());
    PackageParser.Package pkg = parser.parsePackage(apk, apk.getAbsolutePath(), context.getResources().getDisplayMetrics(), flags);
    ReflectUtil.invokeNoException(PackageParser.class, parser, "collectCertificates",
            new Class[]{PackageParser.Package.class, int.class}, pkg, flags);
    return pkg;
}
 
Example 25
Project: container   File: VAppManagerService.java   View source code 5 votes vote down vote up
public AppSetting findAppInfo(String pkg) {
    synchronized (PackageCache.class) {
        if (pkg != null) {
            PackageParser.Package p = PackageCache.get(pkg);
            if (p != null) {
                return (AppSetting) p.mExtras;
            }
        }
        return null;
    }
}
 
Example 26
Project: VirtualAPK   File: LoadedPlugin.java   View source code 5 votes vote down vote up
public Intent getLaunchIntent() {
    ContentResolver resolver = this.mPluginContext.getContentResolver();
    Intent launcher = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);

    for (PackageParser.Activity activity : this.mPackage.activities) {
        for (PackageParser.ActivityIntentInfo intentInfo : activity.intents) {
            if (intentInfo.match(resolver, launcher, false, TAG) > 0) {
                return Intent.makeMainActivity(activity.getComponentName());
            }
        }
    }

    return null;
}
 
Example 27
Project: VirtualAPK   File: LoadedPlugin.java   View source code 5 votes vote down vote up
private boolean match(PackageParser.Component component, ComponentName target) {
    ComponentName source = component.getComponentName();
    if (source == target) return true;
    if (source != null && target != null
            && source.getClassName().equals(target.getClassName())
            && (source.getPackageName().equals(target.getPackageName())
            || mHostContext.getPackageName().equals(target.getPackageName()))) {
        return true;
    }
    return false;
}
 
Example 28
Project: VirtualHook   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static PackageParser createParser(File packageFile) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.ctor.newInstance();
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.ctor.newInstance();
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.ctor.newInstance();
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.ctor.newInstance(packageFile.getAbsolutePath());
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.ctor.newInstance(packageFile.getAbsolutePath());
    } else {
        return mirror.android.content.pm.PackageParser.ctor.newInstance(packageFile.getAbsolutePath());
    }
}
 
Example 29
Project: VirtualHook   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static ServiceInfo generateServiceInfo(Service service, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateServiceInfo.call(service, flags, false, 1, myUserId);
    } else {
        return mirror.android.content.pm.PackageParser.generateServiceInfo.call(service, flags);
    }
}
 
Example 30
Project: VirtualHook   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static ApplicationInfo generateApplicationInfo(Package p, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateApplicationInfo.call(p, flags, false, 1);
    } else {
        return mirror.android.content.pm.PackageParser.generateApplicationInfo.call(p, flags);
    }
}
 
Example 31
Project: VirtualHook   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static ActivityInfo generateActivityInfo(Activity activity, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateActivityInfo.call(activity, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateActivityInfo.call(activity, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateActivityInfo.call(activity, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateActivityInfo.call(activity, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateActivityInfo.call(activity, flags, false, 1, myUserId);
    } else {
        return mirror.android.content.pm.PackageParser.generateActivityInfo.call(activity, flags);
    }
}
 
Example 32
Project: VirtualHook   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static ProviderInfo generateProviderInfo(Provider provider, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateProviderInfo.call(provider, flags, false, 1, myUserId);
    } else {
        return mirror.android.content.pm.PackageParser.generateProviderInfo.call(provider, flags);
    }
}
 
Example 33
Project: container   File: ProviderIntentResolver.java   View source code 5 votes vote down vote up
public final void removeProvider(PackageParser.Provider p) {
	mProviders.remove(p.getComponentName());
	final int NI = p.intents.size();
	int j;
	for (j = 0; j < NI; j++) {
		PackageParser.ProviderIntentInfo intent = p.intents.get(j);
		removeFilter(intent);
	}
}
 
Example 34
Project: VirtualHook   File: VPackage.java   View source code 5 votes vote down vote up
public IntentInfo(PackageParser.IntentInfo info) {
    this.filter = info;
    this.hasDefault = info.hasDefault;
    this.labelRes = info.labelRes;
    if (info.nonLocalizedLabel != null) {
        this.nonLocalizedLabel = info.nonLocalizedLabel.toString();
    }
    this.icon = info.icon;
    this.logo = info.logo;
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
        this.banner = info.banner;
    }

}
 
Example 35
Project: VirtualHook   File: VPackage.java   View source code 5 votes vote down vote up
public ActivityComponent(PackageParser.Activity activity) {
    super(activity);
    if (activity.intents != null) {
        this.intents = new ArrayList<>(activity.intents.size());
        for (Object o : activity.intents) {
            intents.add(new ActivityIntentInfo((PackageParser.IntentInfo) o));
        }
    }
    info = activity.info;
}
 
Example 36
Project: VirtualHook   File: VPackage.java   View source code 5 votes vote down vote up
public ServiceComponent(PackageParser.Service service) {
    super(service);
    if (service.intents != null) {
        this.intents = new ArrayList<>(service.intents.size());
        for (Object o : service.intents) {
            intents.add(new ServiceIntentInfo((PackageParser.IntentInfo) o));
        }
    }
    this.info = service.info;
}
 
Example 37
Project: VirtualHook   File: VPackage.java   View source code 5 votes vote down vote up
public ProviderComponent(PackageParser.Provider provider) {
    super(provider);
    if (provider.intents != null) {
        this.intents = new ArrayList<>(provider.intents.size());
        for (Object o : provider.intents) {
            intents.add(new ProviderIntentInfo((PackageParser.IntentInfo) o));
        }
    }
    this.info = provider.info;
}
 
Example 38
Project: TPlayer   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static PackageParser createParser(File packageFile) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.ctor.newInstance();
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.ctor.newInstance();
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.ctor.newInstance();
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.ctor.newInstance(packageFile.getAbsolutePath());
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.ctor.newInstance(packageFile.getAbsolutePath());
    } else {
        return mirror.android.content.pm.PackageParser.ctor.newInstance(packageFile.getAbsolutePath());
    }
}
 
Example 39
Project: TPlayer   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static ServiceInfo generateServiceInfo(Service service, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateServiceInfo.call(service, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateServiceInfo.call(service, flags, false, 1, myUserId);
    } else {
        return mirror.android.content.pm.PackageParser.generateServiceInfo.call(service, flags);
    }
}
 
Example 40
Project: TPlayer   File: PackageParserCompat.java   View source code 5 votes vote down vote up
public static ApplicationInfo generateApplicationInfo(Package p, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateApplicationInfo.call(p, flags, sUserState);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateApplicationInfo.call(p, flags, false, 1);
    } else {
        return mirror.android.content.pm.PackageParser.generateApplicationInfo.call(p, flags);
    }
}