示例#1
0
  private boolean deletePackage(String pkg, int unInstallFlags) {
    PackageDeleteObserver obs = new PackageDeleteObserver();
    try {
      mPm.deletePackage(pkg, obs, unInstallFlags);

      synchronized (obs) {
        while (!obs.finished) {
          try {
            obs.wait();
          } catch (InterruptedException e) {
          }
        }
      }
    } catch (RemoteException e) {
      System.err.println(e.toString());
      System.err.println(PM_NOT_RUNNING_ERR);
    }
    return obs.result;
  }
  /**
   * uninstall the Third lock app
   *
   * @param packageName the package name of lock
   * @return the result of delete app
   */
  private static int unInstallSilence(String packageName, Context context) {
    if (TextUtils.isEmpty(packageName)) {
      return 0;
    }
    PackageManager pm = context.getPackageManager();

    PackageDeleteObserver pdo = new PackageDeleteObserver();
    ACA.PackageManager.deletePackage(pm, packageName, pdo, 0);
    synchronized (pdo) {
      while (!pdo.finished) {
        try {
          pdo.wait();
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
      return pdo.result;
      //            if (pdo.result == ACA.PackageManager.DELETE_SUCCEEDED) {
      //                return 1;
      //            }
    }
  }