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++;
     }
   }
 }
 private Signature[] readSignatures(String packageName) {
   List<String> fils = PluginDirHelper.getPluginSignatureFiles(mContext, packageName);
   List<Signature> signatures = new ArrayList<Signature>(fils.size());
   int i = 0;
   for (String file : fils) {
     try {
       byte[] data = Utils.readFromFile(new File(file));
       if (data != null) {
         Signature sin = new Signature(data);
         signatures.add(sin);
         Log.i(
             TAG, "Read %s signature of %s,md5=%s", packageName, i, Utils.md5(sin.toByteArray()));
       } else {
         Log.i(TAG, "Read %s signature of %s FAIL", packageName, i);
         return null;
       }
       i++;
     } catch (Exception e) {
       Log.i(TAG, "Read %s signature of %s FAIL", e, packageName, i);
       return null;
     }
   }
   return signatures.toArray(new Signature[signatures.size()]);
 }