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


Java PackageParser.Activity方法代码示例

本文整理汇总了Java中android.content.pm.PackageParser.Activity方法的典型用法代码示例。如果您正苦于以下问题:Java PackageParser.Activity方法的具体用法?Java PackageParser.Activity怎么用?Java PackageParser.Activity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.PackageParser的用法示例。


在下文中一共展示了PackageParser.Activity方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLeanbackLaunchIntent

import android.content.pm.PackageParser; //导入方法依赖的package包/类
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;
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:18,代码来源:LoadedPlugin.java

示例2: activitySupportsIntent

import android.content.pm.PackageParser; //导入方法依赖的package包/类
@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;
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:17,代码来源:VPackageManagerService.java

示例3: queryReceivers

import android.content.pm.PackageParser; //导入方法依赖的package包/类
@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;
}
 
开发者ID:codehz,项目名称:container,代码行数:25,代码来源:VPackageManagerService.java

示例4: queryIntentForPackage

import android.content.pm.PackageParser; //导入方法依赖的package包/类
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);
}
 
开发者ID:codehz,项目名称:container,代码行数:24,代码来源:VPackageManagerService.java

示例5: addActivity

import android.content.pm.PackageParser; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:24,代码来源:VPackageManagerService.java

示例6: removeActivity

import android.content.pm.PackageParser; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:18,代码来源:VPackageManagerService.java

示例7: newResult

import android.content.pm.PackageParser; //导入方法依赖的package包/类
@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;
}
 
开发者ID:codehz,项目名称:container,代码行数:24,代码来源:VPackageManagerService.java

示例8: getLaunchIntent

import android.content.pm.PackageParser; //导入方法依赖的package包/类
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;
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:15,代码来源:LoadedPlugin.java

示例9: ActivityComponent

import android.content.pm.PackageParser; //导入方法依赖的package包/类
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;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:11,代码来源:VPackage.java

示例10: getActivityInfo

import android.content.pm.PackageParser; //导入方法依赖的package包/类
@Override
public ActivityInfo getActivityInfo(ComponentName component, int flags, int userId) {
	checkUserId(userId);
	synchronized (mPackages) {
		PackageParser.Activity a = mActivities.mActivities.get(component);
		if (a != null) {
			ActivityInfo activityInfo = PackageParserCompat.generateActivityInfo(a, flags);
			PackageParser.Package p = mPackages.get(activityInfo.packageName);
			AppSetting settings = (AppSetting) p.mExtras;
			ComponentFixer.fixComponentInfo(settings, activityInfo, userId);
			return activityInfo;
		}
	}
	return null;
}
 
开发者ID:codehz,项目名称:container,代码行数:16,代码来源:VPackageManagerService.java

示例11: getReceiverInfo

import android.content.pm.PackageParser; //导入方法依赖的package包/类
@Override
public ActivityInfo getReceiverInfo(ComponentName component, int flags, int userId) {
	checkUserId(userId);
	synchronized (mPackages) {
		PackageParser.Activity a = mReceivers.mActivities.get(component);
		if (a != null) {
			ActivityInfo receiverInfo = PackageParserCompat.generateActivityInfo(a, flags);
			PackageParser.Package p = mPackages.get(receiverInfo.packageName);
			AppSetting settings = (AppSetting) p.mExtras;
			ComponentFixer.fixComponentInfo(settings, receiverInfo, userId);
			return receiverInfo;
		}
	}
	return null;
}
 
开发者ID:codehz,项目名称:container,代码行数:16,代码来源:VPackageManagerService.java

示例12: LoadedPlugin

import android.content.pm.PackageParser; //导入方法依赖的package包/类
LoadedPlugin(PluginManager pluginManager, Context context, File apk) throws PackageParser.PackageParserException {
    this.mPluginManager = pluginManager;
    this.mHostContext = context;
    this.mLocation = apk.getAbsolutePath();
    this.mPackage = PackageParserCompat.parsePackage(context, apk, PackageParser.PARSE_MUST_BE_APK);
    this.mPackage.applicationInfo.metaData = this.mPackage.mAppMetaData;
    this.mPackageInfo = new PackageInfo();
    this.mPackageInfo.applicationInfo = this.mPackage.applicationInfo;
    this.mPackageInfo.applicationInfo.sourceDir = apk.getAbsolutePath();
    this.mPackageInfo.signatures = this.mPackage.mSignatures;
    this.mPackageInfo.packageName = this.mPackage.packageName;
    if (pluginManager.getLoadedPlugin(mPackageInfo.packageName) != null) {
        throw new RuntimeException("plugin has already been loaded : " + mPackageInfo.packageName);
    }
    this.mPackageInfo.versionCode = this.mPackage.mVersionCode;
    this.mPackageInfo.versionName = this.mPackage.mVersionName;
    this.mPackageInfo.permissions = new PermissionInfo[0];
    this.mPackageManager = new PluginPackageManager();
    this.mPluginContext = new PluginContext(this);
    this.mNativeLibDir = context.getDir(Constants.NATIVE_DIR, Context.MODE_PRIVATE);
    this.mResources = createResources(context, apk);
    this.mClassLoader = createClassLoader(context, apk, this.mNativeLibDir, context.getClassLoader());

    tryToCopyNativeLib(apk);

    // Cache instrumentations
    Map<ComponentName, InstrumentationInfo> instrumentations = new HashMap<ComponentName, InstrumentationInfo>();
    for (PackageParser.Instrumentation instrumentation : this.mPackage.instrumentation) {
        instrumentations.put(instrumentation.getComponentName(), instrumentation.info);
    }
    this.mInstrumentationInfos = Collections.unmodifiableMap(instrumentations);
    this.mPackageInfo.instrumentation = instrumentations.values().toArray(new InstrumentationInfo[instrumentations.size()]);

    // Cache activities
    Map<ComponentName, ActivityInfo> activityInfos = new HashMap<ComponentName, ActivityInfo>();
    for (PackageParser.Activity activity : this.mPackage.activities) {
        activityInfos.put(activity.getComponentName(), activity.info);
    }
    this.mActivityInfos = Collections.unmodifiableMap(activityInfos);
    this.mPackageInfo.activities = activityInfos.values().toArray(new ActivityInfo[activityInfos.size()]);

    // Cache services
    Map<ComponentName, ServiceInfo> serviceInfos = new HashMap<ComponentName, ServiceInfo>();
    for (PackageParser.Service service : this.mPackage.services) {
        serviceInfos.put(service.getComponentName(), service.info);
    }
    this.mServiceInfos = Collections.unmodifiableMap(serviceInfos);
    this.mPackageInfo.services = serviceInfos.values().toArray(new ServiceInfo[serviceInfos.size()]);

    // Cache providers
    Map<String, ProviderInfo> providers = new HashMap<String, ProviderInfo>();
    Map<ComponentName, ProviderInfo> providerInfos = new HashMap<ComponentName, ProviderInfo>();
    for (PackageParser.Provider provider : this.mPackage.providers) {
        providers.put(provider.info.authority, provider.info);
        providerInfos.put(provider.getComponentName(), provider.info);
    }
    this.mProviders = Collections.unmodifiableMap(providers);
    this.mProviderInfos = Collections.unmodifiableMap(providerInfos);
    this.mPackageInfo.providers = providerInfos.values().toArray(new ProviderInfo[providerInfos.size()]);

    // Register broadcast receivers dynamically
    Map<ComponentName, ActivityInfo> receivers = new HashMap<ComponentName, ActivityInfo>();
    for (PackageParser.Activity receiver : this.mPackage.receivers) {
        receivers.put(receiver.getComponentName(), receiver.info);

        try {
            BroadcastReceiver br = BroadcastReceiver.class.cast(getClassLoader().loadClass(receiver.getComponentName().getClassName()).newInstance());
            for (PackageParser.ActivityIntentInfo aii : receiver.intents) {
                this.mHostContext.registerReceiver(br, aii);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    this.mReceiverInfos = Collections.unmodifiableMap(receivers);
    this.mPackageInfo.receivers = receivers.values().toArray(new ActivityInfo[receivers.size()]);
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:78,代码来源:LoadedPlugin.java


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