コード例 #1
0
ファイル: ApkUtils.java プロジェクト: Kcwind/root-tools
  /**
   * getApkFileStatus
   *
   * @param newinfo
   * @return status with the new application info<br>
   *     return 0: installed with same signature<br>
   *     return 1: installed with different signature<br>
   *     return 2: no need update<br>
   *     return 3: not installed<br>
   *     return 4: error
   */
  public static int getApkFileStatus(Context context, DataappInfo newinfo) {
    try {
      String packageName = newinfo.info.packageName;
      ApplicationInfo installedInfo = null;
      try {
        installedInfo = context.getPackageManager().getApplicationInfo(packageName, 0);
      } catch (NameNotFoundException e) {

      }
      if (installedInfo == null) {
        return 3;
      }
      int newVer = DeviceUtils.getAppVersionCode(context, newinfo.localPath);
      int oldVer = DeviceUtils.getAppVersionCode(context, installedInfo);
      if (newVer <= oldVer) {
        return 2;
      }
      boolean compare =
          SignatureUtils.compareSignature(newinfo.localPath, installedInfo.publicSourceDir);
      // int compare = GlobalInstance.pm.checkSignatures(newinfo.info.uid, installedInfo.uid);
      return (compare ? 0 : 1);
    } catch (Exception e) {
      return 4;
    }
  }
コード例 #2
0
  private void showSystemFitable() {

    fitable = DeviceUtils.getFitable();
    if (fitable < 1) {
      fitable = 1;
    }
    if (fitable > 9) {
      fitable = 9;
    }
    switch (fitable) {
      case 1:
        imgFitable.setBackgroundResource(R.drawable.c1);
        break;
      case 2:
        imgFitable.setBackgroundResource(R.drawable.c2);
        break;
      case 3:
        imgFitable.setBackgroundResource(R.drawable.c3);
        break;
      case 4:
        imgFitable.setBackgroundResource(R.drawable.c4);
        break;
      case 5:
        imgFitable.setBackgroundResource(R.drawable.c5);
        break;
      case 6:
        imgFitable.setBackgroundResource(R.drawable.c6);
        break;
      case 7:
        imgFitable.setBackgroundResource(R.drawable.c7);
        break;
      case 8:
        imgFitable.setBackgroundResource(R.drawable.c8);
        break;
      case 9:
        imgFitable.setBackgroundResource(R.drawable.c9);
        break;
    }
  }
コード例 #3
0
 private void showAppVersion() {
   tvAppVersion.setText(DeviceUtils.getAppVersionName(this));
 }