Java 类android.content.pm.ServiceInfo 实例源码

项目:letv    文件:ServcesManager.java   
private void handleOnStartOne(Intent intent, int flags, int startIds) throws Exception {
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = (Service) this.mNameService.get(info.name);
        if (service != null) {
            intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
            Object token = findTokenByService(service);
            Integer integer = (Integer) this.mServiceTaskIds.get(token);
            if (integer == null) {
                integer = Integer.valueOf(-1);
            }
            int startId = integer.intValue() + 1;
            this.mServiceTaskIds.put(token, Integer.valueOf(startId));
            int res = service.onStartCommand(intent, flags, startId);
            QueuedWorkCompat.waitToFinish();
        }
    }
}
项目:DroidPlugin    文件:RunningProcesList.java   
void addServiceInfo(int pid, int uid, ServiceInfo stubInfo, ServiceInfo targetInfo) {
    ProcessItem item = items.get(pid);
    if (TextUtils.isEmpty(targetInfo.processName)) {
        targetInfo.processName = targetInfo.packageName;
    }
    if (item == null) {
        item = new ProcessItem();
        item.pid = pid;
        item.uid = uid;

        items.put(pid, item);
    }
    item.stubProcessName = stubInfo.processName;
    if (!item.pkgs.contains(targetInfo.packageName)) {
        item.pkgs.add(targetInfo.packageName);
    }
    item.targetProcessName = targetInfo.processName;
    item.addServiceInfo(stubInfo.name, targetInfo);
}
项目:lineagex86    文件:SoundSettings.java   
private String getSuppressorCaption(ComponentName suppressor) {
    final PackageManager pm = mContext.getPackageManager();
    try {
        final ServiceInfo info = pm.getServiceInfo(suppressor, 0);
        if (info != null) {
            final CharSequence seq = info.loadLabel(pm);
            if (seq != null) {
                final String str = seq.toString().trim();
                if (str.length() > 0) {
                    return str;
                }
            }
        }
    } catch (Throwable e) {
        Log.w(TAG, "Error loading suppressor caption", e);
    }
    return suppressor.getPackageName();
}
项目:TPlayer    文件:VPackageManagerService.java   
@Override
protected ResolveInfo newResult(VPackage.ServiceIntentInfo filter, int match, int userId) {
    final VPackage.ServiceComponent service = filter.service;
    PackageSetting ps = (PackageSetting) service.owner.mExtras;
    ServiceInfo si = PackageParserEx.generateServiceInfo(service, mFlags, ps.readUserState(userId), userId);
    if (si == null) {
        return null;
    }
    final ResolveInfo res = new ResolveInfo();
    res.serviceInfo = si;
    if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
        res.filter = filter.filter;
    }
    res.priority = filter.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;
}
项目:container    文件:VPackageManagerService.java   
@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;
}
项目:DroidPlugin    文件:RunningProcesList.java   
private void addServiceInfo(String stubServiceName, ServiceInfo info) {
    if (!targetServiceInfos.containsKey(info.name)) {
        targetServiceInfos.put(info.name, info);

        if (!pkgs.contains(info.packageName)) {
            pkgs.add(info.packageName);
        }

        //stub map to activity info
        Set<ServiceInfo> list = serviceInfosMap.get(stubServiceName);
        if (list == null) {
            list = new TreeSet<ServiceInfo>(sComponentInfoComparator);
            list.add(info);
            serviceInfosMap.put(stubServiceName, list);
        } else {
            list.add(info);
        }
    }
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:RecognitionServiceManager.java   
public static Pair<String, String> getLabel(Context context, String comboAsString) {
    String recognizer = "[?]";
    String language = "[?]";
    String[] splits = TextUtils.split(comboAsString, SEPARATOR);
    if (splits.length > 0) {
        PackageManager pm = context.getPackageManager();
        ComponentName recognizerComponentName = ComponentName.unflattenFromString(splits[0]);
        if (recognizerComponentName != null) {
            try {
                ServiceInfo si = pm.getServiceInfo(recognizerComponentName, 0);
                recognizer = si.loadLabel(pm).toString();
            } catch (PackageManager.NameNotFoundException e) {
                // ignored
            }
        }
    }
    if (splits.length > 1) {
        language = makeLangLabel(splits[1]);
    }
    return new Pair<>(recognizer, language);
}
项目:TPlayer    文件:MethodProxies.java   
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    IInterface appThread = (IInterface) args[0];
    Intent service = (Intent) args[1];
    String resolvedType = (String) args[2];
    if (service.getComponent() != null
            && getHostPkg().equals(service.getComponent().getPackageName())) {
        // for server process
        return method.invoke(who, args);
    }
    int userId = VUserHandle.myUserId();
    if (service.getBooleanExtra("_VA_|_from_inner_", false)) {
        userId = service.getIntExtra("_VA_|_user_id_", userId);
        service = service.getParcelableExtra("_VA_|_intent_");
    } else {
        if (isServerProcess()) {
            userId = service.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL);
        }
    }
    service.setDataAndType(service.getData(), resolvedType);
    ServiceInfo serviceInfo = VirtualCore.get().resolveServiceInfo(service, VUserHandle.myUserId());
    if (serviceInfo != null) {
        return VActivityManager.get().startService(appThread, service, resolvedType, userId);
    }
    return method.invoke(who, args);
}
项目:DroidPlugin    文件:ServcesManager.java   
private void handleOnTaskRemovedOne(Intent intent) throws Exception {
    if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
        ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
        if (info != null) {
            Service service = mNameService.get(info.name);
            if (service != null) {
                ClassLoader classLoader = getClassLoader(info.applicationInfo);
                intent.setExtrasClassLoader(classLoader);
                service.onTaskRemoved(intent);
                QueuedWorkCompat.waitToFinish();
            }
            QueuedWorkCompat.waitToFinish();
        }
    }
}
项目:letv    文件:ApkManager.java   
public ServiceInfo getServiceInfo(ComponentName className, int flags) throws NameNotFoundException, RemoteException {
    ServiceInfo serviceInfo = null;
    if (className != null) {
        try {
            if (!(this.mApkManager == null || className == null)) {
                serviceInfo = this.mApkManager.getServiceInfo(className, flags);
            }
        } catch (RemoteException e) {
            JLog.log("wuxinrong", "获取svervice信息 失败 e=" + e.getMessage());
            throw e;
        } catch (Exception e2) {
            JLog.log("wuxinrong", "获取svervice信息 失败 e=" + e2.getMessage());
        }
    }
    return serviceInfo;
}
项目:letv    文件:ServcesManager.java   
private void handleOnTaskRemovedOne(Intent intent) throws Exception {
    if (VERSION.SDK_INT >= 14) {
        ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
        if (info != null) {
            Service service = (Service) this.mNameService.get(info.name);
            if (service != null) {
                intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
                service.onTaskRemoved(intent);
                QueuedWorkCompat.waitToFinish();
            }
            QueuedWorkCompat.waitToFinish();
        }
    }
}
项目:letv    文件:ServcesManager.java   
private IBinder handleOnBindOne(Intent intent) throws Exception {
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = (Service) this.mNameService.get(info.name);
        if (service != null) {
            intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
            return service.onBind(intent);
        }
    }
    return null;
}
项目:TPlayer    文件:VPackageManagerService.java   
@Override
public ServiceInfo getServiceInfo(ComponentName component, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    synchronized (mPackages) {
        VPackage p = mPackages.get(component.getPackageName());
        if (p != null) {
            PackageSetting ps = (PackageSetting) p.mExtras;
            VPackage.ServiceComponent s = mServices.mServices.get(component);
            if (s != null) {
                ServiceInfo serviceInfo = PackageParserEx.generateServiceInfo(s, flags, ps.readUserState(userId), userId);
                ComponentFixer.fixComponentInfo(ps, serviceInfo, userId);
                return serviceInfo;
            }
        }
    }
    return null;
}
项目:letv    文件:ServcesManager.java   
private boolean handleOnUnbindOne(Intent intent) throws Exception {
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info == null) {
        return false;
    }
    Service service = (Service) this.mNameService.get(info.name);
    if (service == null) {
        return false;
    }
    intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
    return service.onUnbind(intent);
}
项目:letv    文件:ServcesManager.java   
public boolean stopServiceToken(ComponentName cn, IBinder token, int startId) throws Exception {
    if (((Service) this.mTokenServices.get(token)) == null) {
        return false;
    }
    Integer lastId = (Integer) this.mServiceTaskIds.get(token);
    if (lastId == null || startId != lastId.intValue()) {
        return false;
    }
    Intent intent = new Intent();
    intent.setComponent(cn);
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info == null) {
        return false;
    }
    handleOnUnbindOne(intent);
    handleOnDestroyOne(info);
    return true;
}
项目:letv    文件:a.java   
public static List<ComponentName> t(Context context) {
    z.b();
    List<ComponentName> arrayList = new ArrayList();
    PackageManager packageManager = context.getPackageManager();
    Intent intent = new Intent();
    intent.setAction(z[98]);
    List queryIntentServices = packageManager.queryIntentServices(intent, 0);
    if (queryIntentServices == null || queryIntentServices.size() == 0) {
        return null;
    }
    for (int i = 0; i < queryIntentServices.size(); i++) {
        ServiceInfo serviceInfo = ((ResolveInfo) queryIntentServices.get(i)).serviceInfo;
        String str = serviceInfo.name;
        String str2 = serviceInfo.packageName;
        if (serviceInfo.exported && serviceInfo.enabled && !e.c.equals(str2)) {
            new StringBuilder(z[97]).append(str2).append("/").append(str).append("}");
            z.b();
            arrayList.add(new ComponentName(str2, str));
        }
    }
    return arrayList;
}
项目:VirtualAPK    文件:ActivityManagerProxy.java   
private Intent wrapperTargetIntent(Intent target, ServiceInfo serviceInfo, Bundle extras, int command) {
    // fill in service with ComponentName
    target.setComponent(new ComponentName(serviceInfo.packageName, serviceInfo.name));
    String pluginLocation = mPluginManager.getLoadedPlugin(target.getComponent()).getLocation();

    // start delegate service to run plugin service inside
    boolean local = PluginUtil.isLocalService(serviceInfo);
    Class<? extends Service> delegate = local ? LocalService.class : RemoteService.class;
    Intent intent = new Intent();
    intent.setClass(mPluginManager.getHostContext(), delegate);
    intent.putExtra(RemoteService.EXTRA_TARGET, target);
    intent.putExtra(RemoteService.EXTRA_COMMAND, command);
    intent.putExtra(RemoteService.EXTRA_PLUGIN_LOCATION, pluginLocation);
    if (extras != null) {
        intent.putExtras(extras);
    }

    return intent;
}
项目:TPlayer    文件:VActivityManagerService.java   
@Override
public IBinder peekService(Intent service, String resolvedType, int userId) {
    synchronized (this) {
        ServiceInfo serviceInfo = resolveServiceInfo(service, userId);
        if (serviceInfo == null) {
            return null;
        }
        ServiceRecord r = findRecordLocked(userId, serviceInfo);
        if (r != null) {
            ServiceRecord.IntentBindRecord boundRecord = r.peekBinding(service);
            if (boundRecord != null) {
                return boundRecord.binder;
            }
        }
        return null;
    }
}
项目:VirtualHook    文件:MethodProxies.java   
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    IInterface caller = (IInterface) args[0];
    IBinder token = (IBinder) args[1];
    Intent service = (Intent) args[2];
    String resolvedType = (String) args[3];
    IServiceConnection conn = (IServiceConnection) args[4];
    int flags = (int) args[5];
    int userId = VUserHandle.myUserId();
    if (isServerProcess()) {
        userId = service.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL);
    }
    if (userId == VUserHandle.USER_NULL) {
        return method.invoke(who, args);
    }
    ServiceInfo serviceInfo = VirtualCore.get().resolveServiceInfo(service, userId);
    if (serviceInfo != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            service.setComponent(new ComponentName(serviceInfo.packageName, serviceInfo.name));
        }
        conn = ServiceConnectionDelegate.getDelegate(conn);
        return VActivityManager.get().bindService(caller.asBinder(), token, service, resolvedType,
                conn, flags, userId);
    }
    return method.invoke(who, args);
}
项目:VirtualHook    文件:MethodProxies.java   
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    IInterface appThread = (IInterface) args[0];
    Intent service = (Intent) args[1];
    String resolvedType = (String) args[2];
    if (service.getComponent() != null
            && getHostPkg().equals(service.getComponent().getPackageName())) {
        // for server process
        return method.invoke(who, args);
    }
    int userId = VUserHandle.myUserId();
    if (service.getBooleanExtra("_VA_|_from_inner_", false)) {
        service = service.getParcelableExtra("_VA_|_intent_");
        userId = service.getIntExtra("_VA_|_user_id_", userId);
    } else {
        if (isServerProcess()) {
            userId = service.getIntExtra("_VA_|_user_id_", VUserHandle.USER_NULL);
        }
    }
    service.setDataAndType(service.getData(), resolvedType);
    ServiceInfo serviceInfo = VirtualCore.get().resolveServiceInfo(service, VUserHandle.myUserId());
    if (serviceInfo != null) {
        return VActivityManager.get().startService(appThread, service, resolvedType, userId);
    }
    return method.invoke(who, args);
}
项目:TPlayer    文件:VPackageManagerService.java   
@Override
public List<ResolveInfo> queryIntentServices(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    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, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mServices.queryIntentForPackage(intent, resolvedType, flags, pkg.services, userId);
        }
        return Collections.emptyList();
    }
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:RecognitionServiceManager.java   
/**
 * @return list of currently installed RecognitionService component names flattened to short strings
 */
public List<String> getServices(PackageManager pm) {
    List<String> services = new ArrayList<>();
    int flags = 0;
    //int flags = PackageManager.GET_META_DATA;
    List<ResolveInfo> infos = pm.queryIntentServices(
            new Intent(RecognitionService.SERVICE_INTERFACE), flags);

    for (ResolveInfo ri : infos) {
        ServiceInfo si = ri.serviceInfo;
        if (si == null) {
            Log.i("serviceInfo == null");
            continue;
        }
        String pkg = si.packageName;
        String cls = si.name;
        // TODO: process si.metaData
        String component = (new ComponentName(pkg, cls)).flattenToShortString();
        if (!mCombosExcluded.contains(component)) {
            services.add(component);
        }
    }
    return services;
}
项目:VirtualHook    文件:VPackageManagerService.java   
@Override
protected ResolveInfo newResult(VPackage.ServiceIntentInfo filter, int match, int userId) {
    final VPackage.ServiceComponent service = filter.service;
    PackageSetting ps = (PackageSetting) service.owner.mExtras;
    ServiceInfo si = PackageParserEx.generateServiceInfo(service, mFlags, ps.readUserState(userId), userId);
    if (si == null) {
        return null;
    }
    final ResolveInfo res = new ResolveInfo();
    res.serviceInfo = si;
    if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
        res.filter = filter.filter;
    }
    res.priority = filter.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;
}
项目:DroidIPC    文件:RemoteCommandSender.java   
public static void sendCommand(Context context,ResolveInfo resolveInfo,int cmd) {

    ServiceInfo serviceInfo = resolveInfo.serviceInfo;
    String sender = serviceInfo.packageName;
    Intent intent = new Intent();
    intent.setAction(serviceInfo.packageName+"._SERVICE_");
    intent.setPackage(sender);
    Bundle binderBunder = new Bundle();
    binderBunder.putBinder(ServiceContext.EXTRA_BUNDLE_BINDER, ServiceManagerThread.getDefault());
    binderBunder.putString(ServiceContext.EXTRA_BUNDLE_PACKAGE_NAME, sender);

    intent.putExtra(ServiceContext.EXTRA_BUNDLE, binderBunder);
    intent.putExtra(ServiceContext.EXTRA_COMMAND, cmd);

    LogControler.print(Level.INFO, "[RemoteCommandSender] "+sender+" sendCommand start service pkg name = "+serviceInfo.packageName+", class name = " + serviceInfo.name);

    ComponentName componentName = context.startService(intent);

    LogControler.print(Level.INFO, "[RemoteCommandSender] "+sender+" sendCommand start service result = " + componentName);
}
项目:springreplugin    文件:ComponentList.java   
/**
 * 根据 Intent 匹配 Service
 * <p>
 * 遍历 plugin 插件中,所有保存的 Service 的 IntentFilter 数据,进行匹配,
 * 返回第一个符合条件的 ServiceInfo 对象.
 *
 * @param context Context
 * @param intent  调用方传来的 Intent
 * @return 匹配到的 ServiceInfo
 */
public Pair<ServiceInfo, String> getServiceAndPluginByIntent(Context context, Intent intent) {
    String action = intent.getAction();
    if (!TextUtils.isEmpty(action)) {
        Set<String> plugins = ManifestParser.INS.getPluginsByActionWhenStartService(action);
        if (plugins != null) {

            for (String plugin : plugins) {
                // 获取 plugin 插件中,所有的 Service 和 IntentFilter 的对应关系
                Map<String, List<IntentFilter>> filters = ManifestParser.INS.getServiceFilterMap(plugin);
                // 找到 plugin 插件中,IntentFilter 匹配成功的 Service
                String service = IntentMatcherHelper.doMatchIntent(context, intent, filters);
                ServiceInfo info = PluginFactory.queryServiceInfo(plugin, service);
                if (info != null) {
                    return new Pair<>(info, plugin);
                }
            }
        }
    }
    return null;
}
项目:springreplugin    文件:PluginServiceClient.java   
/**
 * 启动 Service 时,从 Intent 中获取 ComponentName
 */
private static ComponentName getServiceComponentFromIntent(Context context, Intent intent) {
    ClassLoader cl = context.getClassLoader();
    String plugin = PluginFactory.fetchPluginName(cl);

    /* Intent 中已指定 ComponentName */
    if (intent.getComponent() != null) {
        // 根据 Context 所带的插件信息,来填充 Intent 的 ComponentName 对象。具体见方法说明
        return PluginClientHelper.getComponentNameByContext(context, intent.getComponent());

    } else {
        /* Intent 中已指定 Action,根据 action 解析出 ServiceInfo */
        if (!TextUtils.isEmpty(intent.getAction())) {
            ComponentList componentList = PluginFactory.queryPluginComponentList(plugin);
            if (componentList != null) {
                // 返回 ServiceInfo 和 Service 所在的插件
                Pair<ServiceInfo, String> pair = componentList.getServiceAndPluginByIntent(context, intent);
                if (pair != null) {
                    return new ComponentName(pair.second, pair.first.name);
                }
            }
        } else {
            if (LOG) {
                LogDebug.d(PLUGIN_TAG, "PSS.startService(): No Component and no Action");
            }
        }
    }
    return null;
}
项目:DroidPlugin    文件:ServcesManager.java   
private IBinder handleOnBindOne(Intent intent) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            return service.onBind(intent);
        }
    }
    return null;
}
项目:springreplugin    文件:ServiceRecord.java   
ServiceRecord(ComponentName cn, Intent.FilterComparison fi, ServiceInfo si) {
    name = cn;
    plugin = cn.getPackageName();
    className = cn.getClassName();
    shortName = name.flattenToShortString();
    intent = fi;
    serviceInfo = si;
}
项目:DroidPlugin    文件:IActivityManagerHookHandle.java   
@Override
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {
    //API 2.3, 15, 16
/* public int stopService(IApplicationThread caller, Intent service,
    String resolvedType) throws RemoteException;*/

    //API 17, 18, 19, 21
/* public int stopService(IApplicationThread caller, Intent service,
    String resolvedType, int userId) throws RemoteException;*/
    int index = 1;
    if (args != null && args.length > index && args[index] instanceof Intent) {
        Intent intent = (Intent) args[index];
        ServiceInfo info = resolveService(intent);
        if (info != null && isPackagePlugin(info.packageName)) {
            int re = ServcesManager.getDefault().stopService(mHostContext, intent);
            setFakedResult(re);
            return true;
        }
    }
    return super.beforeInvoke(receiver, method, args);
}
项目:DroidPlugin    文件:IntentMatcher.java   
private static ResolveInfo newResolveInfo(ServiceInfo serviceInfo, IntentFilter intentFilter) {
        ResolveInfo resolveInfo = new ResolveInfo();
        resolveInfo.serviceInfo = serviceInfo;
        resolveInfo.filter = intentFilter;
        resolveInfo.resolvePackageName = serviceInfo.packageName;
        resolveInfo.labelRes = serviceInfo.labelRes;
        resolveInfo.icon = serviceInfo.icon;
        resolveInfo.specificIndex = 1;
//        if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
//          默认就是false,不用再设置了。
//        resolveInfo.system = false;
//        }
        resolveInfo.priority = intentFilter.getPriority();
        resolveInfo.preferredOrder = 0;
        return resolveInfo;
    }
项目:lineagex86    文件:ServiceListing.java   
public static ServiceInfo findService(Context context, Config config, final ComponentName cn) {
    final ServiceListing listing = new ServiceListing(context, config);
    final List<ServiceInfo> services = listing.reload();
    for (ServiceInfo service : services) {
        final ComponentName serviceCN = new ComponentName(service.packageName, service.name);
        if (serviceCN.equals(cn)) {
            return service;
        }
    }
    return null;
}
项目:lineagex86    文件:ServiceListing.java   
private static int getServices(Config c, List<ServiceInfo> list, PackageManager pm) {
    int services = 0;
    if (list != null) {
        list.clear();
    }
    final int user = ActivityManager.getCurrentUser();

    List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser(
            new Intent(c.intentAction),
            PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
            user);

    for (int i = 0, count = installedServices.size(); i < count; i++) {
        ResolveInfo resolveInfo = installedServices.get(i);
        ServiceInfo info = resolveInfo.serviceInfo;

        if (!c.permission.equals(info.permission)) {
            Slog.w(c.tag, "Skipping " + c.noun + " service "
                    + info.packageName + "/" + info.name
                    + ": it does not require the permission "
                    + c.permission);
            continue;
        }
        if (list != null) {
            list.add(info);
        }
        services++;
    }
    return services;
}
项目:lineagex86    文件:ServiceListing.java   
public List<ServiceInfo> reload() {
    loadEnabledServices();
    getServices(mConfig, mServices, mContext.getPackageManager());
    for (Callback callback : mCallbacks) {
        callback.onServicesReloaded(mServices);
    }
    return mServices;
}
项目:DroidPlugin    文件:ServiceStubMap.java   
void addToMap(ServiceInfo stubInfo, ServiceInfo pluginInfo) {
    MyServiceInfo stub = new MyServiceInfo(stubInfo);
    MyServiceInfo plugin = new MyServiceInfo(pluginInfo);
    List<MyServiceInfo> list =  mServiceStubMap.get(stub);
    if (list == null) {
        list = new ArrayList<MyServiceInfo>(1);
        mServiceStubMap.put(stub, list);
    }
    list.add(plugin);
}
项目:RLibrary    文件:MetaUtil.java   
public static String getServiceMetaData(Context context, String serviceClass, String key) {
    String value = "";
    try {
        ComponentName componentName = new ComponentName(context.getPackageName(), serviceClass);
        ServiceInfo serviceInfo = context.getPackageManager()
                .getServiceInfo(componentName, PackageManager.GET_META_DATA);
        value = serviceInfo.metaData.getString(key);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return value;
}
项目:GitHub    文件:TinkerServiceInternals.java   
private static String getServiceProcessName(Context context, Class<? extends Service> serviceClass) {
    PackageManager packageManager = context.getPackageManager();

    ComponentName component = new ComponentName(context, serviceClass);
    ServiceInfo serviceInfo;
    try {
        serviceInfo = packageManager.getServiceInfo(component, 0);
    } catch (Throwable ignored) {
        // Service is disabled.
        return null;
    }

    return serviceInfo.processName;
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:RecognitionServiceManager.java   
public static String getServiceLabel(Context context, ComponentName recognizerComponentName) {
    String recognizer = "[?]";
    PackageManager pm = context.getPackageManager();
    if (recognizerComponentName != null) {
        try {
            ServiceInfo si = pm.getServiceInfo(recognizerComponentName, 0);
            recognizer = si.loadLabel(pm).toString();
        } catch (PackageManager.NameNotFoundException e) {
            // ignored
        }
    }
    return recognizer;
}
项目:MiPushFramework    文件:CheckSupportUtils.java   
/**
 * Check this package has MiPushService
 * @see XMPushService
 * @param info Package Info
 * @return has push service
 */
private boolean hasMiPushService (PackageInfo info) {
    if (info.services == null)
        return false;
    for (ServiceInfo serviceInfo : info.services) {
        Log4a.d(TAG, "Service name -> " + serviceInfo.name);
        if (XMPushService.class.getName().equals(serviceInfo.name)) {
            return true;
        }
    }
    return false;
}
项目:container    文件:VActivityManagerService.java   
private static ServiceInfo resolveServiceInfo(Intent service, int userId) {
    if (service != null) {
        ServiceInfo serviceInfo = VirtualCore.get().resolveServiceInfo(service, userId);
        if (serviceInfo != null) {
            return serviceInfo;
        }
    }
    return null;
}
项目:DroidPlugin    文件:IActivityManagerHookHandle.java   
private static ServiceInfo selectProxyService(Intent intent) {
    try {
        if (intent != null) {
            ServiceInfo proxyInfo = PluginManager.getInstance().selectStubServiceInfo(intent);
            if (proxyInfo != null) {
                return proxyInfo;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}