use of android.content.pm.ServiceInfo in project DroidPlugin by DroidPluginTeam.
the class ServcesManager method stopServiceToken.
public boolean stopServiceToken(ComponentName cn, IBinder token, int startId) throws Exception {
Service service = mTokenServices.get(token);
if (service != null) {
Integer lastId = mServiceTaskIds.get(token);
if (lastId == null) {
return false;
}
if (startId != lastId) {
return false;
}
Intent intent = new Intent();
intent.setComponent(cn);
ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
if (info != null) {
handleOnUnbindOne(intent);
handleOnDestroyOne(info);
return true;
}
}
return false;
}
use of android.content.pm.ServiceInfo in project DroidPlugin by DroidPluginTeam.
the class IntentMatcher method queryIntentServiceForPackage.
private static void queryIntentServiceForPackage(Context context, PluginPackageParser packageParser, Intent intent, int flags, List<ResolveInfo> outList) throws Exception {
List<ServiceInfo> serviceInfos = packageParser.getServices();
if (serviceInfos != null && serviceInfos.size() >= 0) {
for (ServiceInfo serviceInfo : serviceInfos) {
ComponentName className = new ComponentName(serviceInfo.packageName, serviceInfo.name);
List<IntentFilter> intentFilters = packageParser.getServiceIntentFilter(className);
if (intentFilters != null && intentFilters.size() > 0) {
for (IntentFilter intentFilter : intentFilters) {
int match = intentFilter.match(context.getContentResolver(), intent, true, "");
if (match >= 0) {
ServiceInfo flagServiceInfo = packageParser.getServiceInfo(new ComponentName(serviceInfo.packageName, serviceInfo.name), flags);
if ((flags & PackageManager.MATCH_DEFAULT_ONLY) != 0) {
if (intentFilter.hasCategory(Intent.CATEGORY_DEFAULT)) {
ResolveInfo resolveInfo = newResolveInfo(flagServiceInfo, intentFilter);
resolveInfo.match = match;
resolveInfo.isDefault = true;
outList.add(resolveInfo);
} else {
//只是匹配默认。这里也算匹配不上。
}
} else {
ResolveInfo resolveInfo = newResolveInfo(flagServiceInfo, intentFilter);
resolveInfo.match = match;
resolveInfo.isDefault = false;
outList.add(resolveInfo);
}
}
}
if (outList.size() <= 0) {
//没有在插件包中找到IntentFilter匹配的Service
}
} else {
//该插件包中没有具有IntentFilter的Service
}
}
} else {
//该插件apk包中没有Service
}
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by DirtyUnicorns.
the class MidiService method addPackageDeviceServers.
private void addPackageDeviceServers(String packageName) {
PackageInfo info;
try {
info = mPackageManager.getPackageInfo(packageName, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "handlePackageUpdate could not find package " + packageName, e);
return;
}
ServiceInfo[] services = info.services;
if (services == null)
return;
for (int i = 0; i < services.length; i++) {
addPackageDeviceServer(services[i]);
}
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by DirtyUnicorns.
the class MetaDataTest method testServiceWithData.
@SmallTest
public void testServiceWithData() throws Exception {
ComponentName cn = new ComponentName(mContext, LocalService.class);
ServiceInfo si = mContext.getPackageManager().getServiceInfo(cn, PackageManager.GET_META_DATA);
checkMetaData(cn, si);
si = mContext.getPackageManager().getServiceInfo(cn, 0);
assertNull("Meta data returned when not requested", si.metaData);
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by DirtyUnicorns.
the class MidiService method onUnlockUser.
private void onUnlockUser() {
mPackageMonitor.register(mContext, null, true);
Intent intent = new Intent(MidiDeviceService.SERVICE_INTERFACE);
List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent, PackageManager.GET_META_DATA);
if (resolveInfos != null) {
int count = resolveInfos.size();
for (int i = 0; i < count; i++) {
ServiceInfo serviceInfo = resolveInfos.get(i).serviceInfo;
if (serviceInfo != null) {
addPackageDeviceServer(serviceInfo);
}
}
}
PackageInfo info;
try {
info = mPackageManager.getPackageInfo(MidiManager.BLUETOOTH_MIDI_SERVICE_PACKAGE, 0);
} catch (PackageManager.NameNotFoundException e) {
info = null;
}
if (info != null && info.applicationInfo != null) {
mBluetoothServiceUid = info.applicationInfo.uid;
} else {
mBluetoothServiceUid = -1;
}
}
Aggregations