private ServiceInfo<AuthenticatorDescription> parseServiceInfo(ResolveInfo service)
     throws XmlPullParserException, IOException {
   android.content.pm.ServiceInfo si = service.serviceInfo;
   ComponentName componentName = new ComponentName(si.packageName, si.name);
   PackageManager pm = this.mContext.getPackageManager();
   XmlResourceParser parser = null;
   try {
     parser = si.loadXmlMetaData(pm, this.mMetaDataName);
     if (parser == null) {
       throw new XmlPullParserException("No " + this.mMetaDataName + " meta-data");
     }
     AttributeSet attrs = Xml.asAttributeSet(parser);
     int type;
     do {
       type = parser.next();
       if (type == 1) {
         break;
       }
     } while (type != 2);
     if (this.mAttributesName.equals(parser.getName())) {
       ServiceInfo<AuthenticatorDescription> serviceInfo;
       AuthenticatorDescription v =
           parseServiceAttributes(
               pm.getResourcesForApplication(si.applicationInfo), si.packageName, attrs);
       if (v == null) {
         serviceInfo = null;
         if (parser != null) {
           parser.close();
         }
       } else {
         serviceInfo = new ServiceInfo(v, componentName, service.serviceInfo.applicationInfo.uid);
         if (parser != null) {
           parser.close();
         }
       }
       return serviceInfo;
     }
     throw new XmlPullParserException(
         "Meta-data does not start with " + this.mAttributesName + " tag");
   } catch (NameNotFoundException e) {
     throw new XmlPullParserException("Unable to load resources for pacakge " + si.packageName);
   } catch (Throwable th) {
     if (parser != null) {
       parser.close();
     }
   }
 }
 public final void scheduleCreateService(
     IBinder token, ServiceInfo info, CompatibilityInfo compatInfo) throws RemoteException {
   Parcel data = Parcel.obtain();
   data.writeInterfaceToken(IApplicationThread.descriptor);
   data.writeStrongBinder(token);
   info.writeToParcel(data, 0);
   compatInfo.writeToParcel(data, 0);
   mRemote.transact(SCHEDULE_CREATE_SERVICE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
   data.recycle();
 }
Esempio n. 3
0
  @Override
  public ServiceInfo getServiceInfo(ComponentName className, int flags)
      throws NameNotFoundException {
    String packageName = className.getPackageName();
    AndroidManifest androidManifest = androidManifests.get(packageName);
    String serviceName = className.getClassName();
    ServiceData serviceData = androidManifest.getServiceData(serviceName);
    if (serviceData == null) {
      throw new NameNotFoundException();
    }

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.packageName = packageName;
    serviceInfo.name = serviceName;
    serviceInfo.applicationInfo = getApplicationInfo(packageName, flags);
    serviceInfo.permission = serviceData.getPermission();
    if ((flags & GET_META_DATA) != 0) {
      serviceInfo.metaData = metaDataToBundle(serviceData.getMetaData().getValueMap());
    }
    return serviceInfo;
  }
Esempio n. 4
0
  private static void showPluginInfo(PluginPackageParser pluginPackageParser) {

    PluginInfo pluginInfo = new PluginInfo();
    pluginInfo.pkgParser = pluginPackageParser;

    PackageInfo packageInfo = null;

    try {
      packageInfo =
          pluginPackageParser.getPackageInfo(
              PackageManager.GET_ACTIVITIES
                  | PackageManager.GET_SERVICES
                  | PackageManager.GET_PROVIDERS
                  | PackageManager.GET_RECEIVERS
                  | PackageManager.GET_META_DATA);
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (packageInfo != null) {
      pluginInfo.packageName = packageInfo.packageName;

      // test
      Log.d(TAG, "\n## packageInfo.packageInfo.applicationInfo: ");
      packageInfo.applicationInfo.dump(new LogPrinter(Log.DEBUG, TAG), "");
      Log.d(TAG, "\n\n");

      if (packageInfo.activities != null) {
        Log.d(TAG, "\n## packageInfo.activities: ");
        int i = 0;
        for (ActivityInfo activityInfo : packageInfo.activities) {
          Log.d(TAG, "packageInfo.activitie No." + ++i);
          activityInfo.dump(new LogPrinter(Log.DEBUG, TAG), "");
          Log.d(TAG, "\n");
        }
      }

      if (packageInfo.services != null) {
        Log.d(TAG, "\n## packageInfo.services: ");
        int i = 0;
        for (ServiceInfo serviceInfo : packageInfo.services) {
          Log.d(TAG, "packageInfo.service No." + ++i);
          serviceInfo.dump(new LogPrinter(Log.DEBUG, TAG), "");
          Log.d(TAG, "\n");
        }
      }

      if (packageInfo.receivers != null) {
        Log.d(TAG, "\n## packageInfo.receivers: ");
        int i = 0;
        for (ActivityInfo receiverInfo : packageInfo.receivers) {
          Log.d(TAG, "packageInfo.receiver No." + ++i);
          receiverInfo.dump(new LogPrinter(Log.DEBUG, TAG), "");
          Log.d(TAG, "\n");
        }
      }

      if (packageInfo.providers != null) {
        Log.d(TAG, "\n## packageInfo.providers: ");
        int i = 0;
        for (ProviderInfo providerInfo : packageInfo.providers) {
          Log.d(TAG, "packageInfo.provider No." + ++i);
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            providerInfo.dump(new LogPrinter(Log.DEBUG, TAG), "");
          } else {
            Log.d(TAG, " " + providerInfo);
          }
          Log.d(TAG, "\n");
        }
      }
    }
  }