예제 #1
0
  private Resources getResources(PackageItemInfo pii) {
    Resources res = mResourceCache.get(pii.packageName);
    if (res != null) return res;

    try {
      ApplicationInfo ai = mPm.getApplicationInfo(pii.packageName, 0, 0);
      AssetManager am = new AssetManager();
      am.addAssetPath(ai.publicSourceDir);
      res = new Resources(am, null, null);
      mResourceCache.put(pii.packageName, res);
      return res;
    } catch (RemoteException e) {
      System.err.println(e.toString());
      System.err.println(PM_NOT_RUNNING_ERR);
      return null;
    }
  }
 public String getSavedNetworkSummary() {
   if (mConfig != null) {
     PackageManager pm = mContext.getPackageManager();
     String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
     int userId = UserHandle.getUserId(mConfig.creatorUid);
     ApplicationInfo appInfo = null;
     if (mConfig.creatorName != null && mConfig.creatorName.equals(systemName)) {
       appInfo = mContext.getApplicationInfo();
     } else {
       try {
         IPackageManager ipm = AppGlobals.getPackageManager();
         appInfo = ipm.getApplicationInfo(mConfig.creatorName, 0 /* flags */, userId);
       } catch (RemoteException rex) {
       }
     }
     if (appInfo != null
         && !appInfo.packageName.equals(mContext.getString(R.string.settings_package))
         && !appInfo.packageName.equals(mContext.getString(R.string.certinstaller_package))) {
       return mContext.getString(R.string.saved_network, appInfo.loadLabel(pm));
     }
   }
   return "";
 }