private void saveSignatures(PackageInfo pkgInfo) {
   if (pkgInfo != null && pkgInfo.signatures != null) {
     int i = 0;
     for (Signature signature : pkgInfo.signatures) {
       File file =
           new File(PluginDirHelper.getPluginSignatureFile(mContext, pkgInfo.packageName, i));
       try {
         Utils.writeToFile(file, signature.toByteArray());
         Log.i(
             TAG,
             "Save %s signature of %s,md5=%s",
             pkgInfo.packageName,
             i,
             Utils.md5(signature.toByteArray()));
       } catch (Exception e) {
         e.printStackTrace();
         Log.w(TAG, "Save signatures fail", e);
         file.delete();
         Utils.deleteDir(PluginDirHelper.getPluginSignatureDir(mContext, pkgInfo.packageName));
         break;
       }
       i++;
     }
   }
 }
  @Override
  public int deletePackage(String packageName, int flags) throws RemoteException {
    try {
      if (mPluginCache.containsKey(packageName)) {
        forceStopPackage(packageName);

        PluginPackageParser parser;
        synchronized (mPluginCache) {
          parser = mPluginCache.remove(packageName);
        }
        Utils.deleteDir(PluginDirHelper.makePluginBaseDir(mContext, packageName));
        mActivityManagerService.onPkgDeleted(mPluginCache, parser, packageName);
        mSignatureCache.remove(packageName);
        sendUninstalledBroadcast(packageName);
        return PackageManagerCompat.DELETE_SUCCEEDED;
      }
    } catch (Exception e) {
      handleException(e);
    }
    return PackageManagerCompat.DELETE_FAILED_INTERNAL_ERROR;
  }
  @Override
  public void clearApplicationUserData(String packageName, IPackageDataObserver observer)
      throws RemoteException {
    boolean success = false;
    try {
      if (TextUtils.isEmpty(packageName)) {
        return;
      }

      PluginPackageParser parser = mPluginCache.get(packageName);
      if (parser == null) {
        return;
      }
      ApplicationInfo applicationInfo = parser.getApplicationInfo(0);
      Utils.deleteDir(applicationInfo.dataDir);
      success = true;
    } catch (Exception e) {
      handleException(e);
    } finally {
      if (observer != null) {
        observer.onRemoveCompleted(packageName, success);
      }
    }
  }