android.content.pm.PackageParser#ActivityIntentInfo()源码实例Demo

下面列出了android.content.pm.PackageParser#ActivityIntentInfo() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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));
    }
}
 
@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;
}
 
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);
}
 
源代码4 项目: VirtualAPK   文件: LoadedPlugin.java
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;
}
 
源代码5 项目: container   文件: VPackageManagerService.java
@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;
}
 
源代码6 项目: container   文件: VPackageManagerService.java
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);
	}
}
 
源代码7 项目: container   文件: VPackageManagerService.java
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);
	}
}
 
@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;
}
 
@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)));
}
 
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);
	}
}
 
源代码11 项目: AndroidComponentPlugin   文件: ComponentResolver.java
@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;
}
 
源代码12 项目: VirtualAPK   文件: LoadedPlugin.java
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;
}
 
源代码13 项目: container   文件: VPackageManagerService.java
@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;
}
 
源代码14 项目: container   文件: VPackageManagerService.java
@Override
protected Object filterToLabel(PackageParser.ActivityIntentInfo filter) {
	return filter.activity;
}
 
源代码15 项目: AndroidComponentPlugin   文件: ComponentResolver.java
@Override
protected boolean isPackageForFilter(String packageName,
        PackageParser.ActivityIntentInfo info) {
    return packageName.equals(info.activity.owner.packageName);
}
 
源代码16 项目: container   文件: VPackageManagerService.java
@Override
protected boolean isFilterStopped(PackageParser.ActivityIntentInfo filter) {
	return false;
}
 
源代码17 项目: AndroidComponentPlugin   文件: ComponentResolver.java
@Override
protected Object filterToLabel(PackageParser.ActivityIntentInfo filter) {
    return filter.activity;
}
 
public ArrayList<PackageParser.ActivityIntentInfo> getFilters() {
    return mFilters;
}
 
源代码19 项目: container   文件: VPackageManagerService.java
@Override
protected boolean isPackageForFilter(String packageName, PackageParser.ActivityIntentInfo info) {
	return packageName.equals(info.activity.owner.packageName);
}
 
源代码20 项目: container   文件: VPackageManagerService.java
@Override
protected PackageParser.ActivityIntentInfo[] newArray(int size) {
	return new PackageParser.ActivityIntentInfo[size];
}