Java Code Examples for android.content.pm.PackageParser#ActivityIntentInfo

The following examples show how to use android.content.pm.PackageParser#ActivityIntentInfo . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentResolver.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@GuardedBy("mLock")
private void addActivitiesLocked(PackageParser.Package pkg,
        List<PackageParser.ActivityIntentInfo> newIntents, boolean chatty) {
    final int activitiesSize = pkg.activities.size();
    StringBuilder r = null;
    for (int i = 0; i < activitiesSize; i++) {
        PackageParser.Activity a = pkg.activities.get(i);
        a.info.processName =
                fixProcessName(pkg.applicationInfo.processName, a.info.processName);
        mActivities.addActivity(a, "activity", newIntents);
        if (DEBUG_PACKAGE_SCANNING && chatty) {
            if (r == null) {
                r = new StringBuilder(256);
            } else {
                r.append(' ');
            }
            r.append(a.info.name);
        }
    }
    if (DEBUG_PACKAGE_SCANNING && chatty) {
        Log.d(TAG, "  Activities: " + (r == null ? "<NONE>" : r));
    }
}
 
Example 2
Source File: ComponentResolver.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean isFilterStopped(PackageParser.ActivityIntentInfo filter, int userId) {
    if (!sUserManager.exists(userId)) return true;
    PackageParser.Package p = filter.activity.owner;
    if (p != null) {
        PackageSetting ps = (PackageSetting) p.mExtras;
        if (ps != null) {
            // System apps are never considered stopped for purposes of
            // filtering, because there may be no way for the user to
            // actually re-launch them.
            return (ps.pkgFlags & ApplicationInfo.FLAG_SYSTEM) == 0
                    && ps.getStopped(userId);
        }
    }
    return false;
}
 
Example 3
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 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 4
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 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 5
Source File: ActivityIntentResolver.java    From koala--Android-Plugin-Runtime- with Apache License 2.0 6 votes vote down vote up
public List 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;
	int N = packageActivities.size();
	ArrayList<ArrayList<PackageParser.ActivityIntentInfo>> listCut = new ArrayList<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) {
			listCut.add(intentFilters);
		}
	}
	return super.queryIntentFromList(intent, resolvedType, defaultOnly,
			listCut);
}
 
Example 6
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 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 7
Source File: LoadedPlugin.java    From VirtualAPK with Apache License 2.0 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 8
Source File: ActivityIntentResolver.java    From koala--Android-Plugin-Runtime- with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean allowFilterResult(
		PackageParser.ActivityIntentInfo filter, List<PackageParser.Activity> dest) {
	for (int i = dest.size() - 1; i >= 0; i--) {
		PackageParser.Activity destAi = dest.get(i);
		if (destAi == filter.activity) {
			return false;
		}
	}
	return true;
}
 
Example 9
Source File: ActivityIntentResolver.java    From koala--Android-Plugin-Runtime- with Apache License 2.0 5 votes vote down vote up
@Override
protected void dumpFilter(PrintWriter out, String prefix,
		PackageParser.ActivityIntentInfo filter) {
	out.print(prefix);
	out.print(Integer.toHexString(System.identityHashCode(filter.activity)));
	out.print(' ');
	out.print(filter.activity.getComponentName());
	out.print(" filter ");
	out.println(Integer.toHexString(System.identityHashCode(filter)));
}
 
Example 10
Source File: ActivityIntentResolver.java    From koala--Android-Plugin-Runtime- with Apache License 2.0 5 votes vote down vote up
public final void removeActivity(PackageParser.Activity a) {
	mActivities.remove(a.getComponentName());
	int NI = a.intents.size();
	for (int j = 0; j < NI; j++) {
		PackageParser.ActivityIntentInfo intent = a.intents.get(j);
		removeFilter(intent);
	}
}
 
Example 11
Source File: ComponentResolver.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean allowFilterResult(
        PackageParser.ActivityIntentInfo filter, List<ResolveInfo> dest) {
    ActivityInfo filterAi = filter.activity.info;
    for (int i = dest.size() - 1; i >= 0; --i) {
        ActivityInfo destAi = dest.get(i).activityInfo;
        if (destAi.name == filterAi.name && destAi.packageName == filterAi.packageName) {
            return false;
        }
    }
    return true;
}
 
Example 12
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean allowFilterResult(PackageParser.ActivityIntentInfo filter, List<ResolveInfo> dest) {
	ActivityInfo filterAi = filter.activity.info;
	for (int i = dest.size() - 1; i >= 0; i--) {
		ActivityInfo destAi = dest.get(i).activityInfo;
		if (destAi.name == filterAi.name && destAi.packageName == filterAi.packageName) {
			return false;
		}
	}
	return true;
}
 
Example 13
Source File: LoadedPlugin.java    From VirtualAPK with Apache License 2.0 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 14
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected PackageParser.ActivityIntentInfo[] newArray(int size) {
	return new PackageParser.ActivityIntentInfo[size];
}
 
Example 15
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected Object filterToLabel(PackageParser.ActivityIntentInfo filter) {
	return filter.activity;
}
 
Example 16
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean isPackageForFilter(String packageName, PackageParser.ActivityIntentInfo info) {
	return packageName.equals(info.activity.owner.packageName);
}
 
Example 17
Source File: IntentFilterVerificationState.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public ArrayList<PackageParser.ActivityIntentInfo> getFilters() {
    return mFilters;
}
 
Example 18
Source File: ComponentResolver.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
protected Object filterToLabel(PackageParser.ActivityIntentInfo filter) {
    return filter.activity;
}
 
Example 19
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean isFilterStopped(PackageParser.ActivityIntentInfo filter) {
	return false;
}
 
Example 20
Source File: ComponentResolver.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean isPackageForFilter(String packageName,
        PackageParser.ActivityIntentInfo info) {
    return packageName.equals(info.activity.owner.packageName);
}