Java Code Examples for android.content.pm.PackageInstaller#STATUS_SUCCESS

The following examples show how to use android.content.pm.PackageInstaller#STATUS_SUCCESS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RootlessSaiPiBroadcastReceiver.java    From SAI with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999);
    switch (status) {
        case PackageInstaller.STATUS_PENDING_USER_ACTION:
            Log.d(TAG, "Requesting user confirmation for installation");
            dispatchOnConfirmationPending(intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME));
            Intent confirmationIntent = intent.getParcelableExtra(Intent.EXTRA_INTENT);

            ConfirmationIntentWrapperActivity2.start(context, intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), confirmationIntent);
            break;
        case PackageInstaller.STATUS_SUCCESS:
            Log.d(TAG, "Installation succeed");
            dispatchOnInstallationSucceeded(intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME));
            break;
        default:
            Log.d(TAG, "Installation failed");
            dispatchOnInstallationFailed(intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), parseError(intent), getRawError(intent), null);
            break;
    }
}
 
Example 2
Source File: RootlessSAIPIService.java    From SAI with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999);
    switch (status) {
        case PackageInstaller.STATUS_PENDING_USER_ACTION:
            Log.d(TAG, "Requesting user confirmation for installation");
            sendStatusChangeBroadcast(intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), STATUS_CONFIRMATION_PENDING, intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME));
            Intent confirmationIntent = intent.getParcelableExtra(Intent.EXTRA_INTENT);

            ConfirmationIntentWrapperActivity.start(this, intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), confirmationIntent);
            break;
        case PackageInstaller.STATUS_SUCCESS:
            Log.d(TAG, "Installation succeed");
            sendStatusChangeBroadcast(intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), STATUS_SUCCESS, intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME));
            break;
        default:
            Log.d(TAG, "Installation failed");
            sendErrorBroadcast(intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1), getErrorString(status, intent.getStringExtra(PackageInstaller.EXTRA_OTHER_PACKAGE_NAME)));
            break;
    }
    stopSelf();
    return START_NOT_STICKY;
}
 
Example 3
Source File: DummyActivity.java    From Shelter with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    if (intent.getAction().equals(PACKAGEINSTALLER_CALLBACK)) {
        int status = intent.getExtras().getInt(PackageInstaller.EXTRA_STATUS);

        switch (status) {
            case PackageInstaller.STATUS_PENDING_USER_ACTION:
                startActivity((Intent) intent.getExtras().get(Intent.EXTRA_INTENT));
                break;
            case PackageInstaller.STATUS_SUCCESS:
                appInstallFinished(Activity.RESULT_OK);
                break;
            default:
                appInstallFinished(Activity.RESULT_CANCELED);
                break;
        }
    }
}
 
Example 4
Source File: APKInstallService.java    From splitapkinstall with Apache License 2.0 5 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999);
    switch (status) {
        case PackageInstaller.STATUS_PENDING_USER_ACTION:
            Log.d(TAG, "Requesting user confirmation for installation");
            Intent confirmationIntent = intent.getParcelableExtra(Intent.EXTRA_INTENT);
            confirmationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                startActivity(confirmationIntent);
            } catch (Exception e) {
            }
            break;
        case PackageInstaller.STATUS_SUCCESS:
            Log.d(TAG, "Installation succeed");
            break;
        default:
            Log.d(TAG, "Installation failed");
            break;
    }
    stopSelf();
    return START_NOT_STICKY;
}
 
Example 5
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int uninstallSystemUpdates() {
    final PrintWriter pw = getOutPrintWriter();
    List<String> failedUninstalls = new LinkedList<>();
    try {
        final ParceledListSlice<ApplicationInfo> packages =
                mInterface.getInstalledApplications(
                        PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM);
        final IPackageInstaller installer = mInterface.getPackageInstaller();
        List<ApplicationInfo> list = packages.getList();
        for (ApplicationInfo info : list) {
            if (info.isUpdatedSystemApp()) {
                pw.println("Uninstalling updates to " + info.packageName + "...");
                final LocalIntentReceiver receiver = new LocalIntentReceiver();
                installer.uninstall(new VersionedPackage(info.packageName,
                                info.versionCode), null /*callerPackageName*/, 0 /* flags */,
                        receiver.getIntentSender(), 0);

                final Intent result = receiver.getResult();
                final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
                        PackageInstaller.STATUS_FAILURE);
                if (status != PackageInstaller.STATUS_SUCCESS) {
                    failedUninstalls.add(info.packageName);
                }
            }
        }
    } catch (RemoteException e) {
        pw.println("Failure ["
                + e.getClass().getName() + " - "
                + e.getMessage() + "]");
        return 0;
    }
    if (!failedUninstalls.isEmpty()) {
        pw.println("Failure [Couldn't uninstall packages: "
                + TextUtils.join(", ", failedUninstalls)
                + "]");
        return 0;
    }
    pw.println("Success");
    return 1;
}
 
Example 6
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int runInstall() throws RemoteException {
    final PrintWriter pw = getOutPrintWriter();
    final InstallParams params = makeInstallParams();
    final String inPath = getNextArg();

    setParamsSize(params, inPath);
    final int sessionId = doCreateSession(params.sessionParams,
            params.installerPackageName, params.userId);
    boolean abandonSession = true;
    try {
        if (inPath == null && params.sessionParams.sizeBytes == -1) {
            pw.println("Error: must either specify a package size or an APK file");
            return 1;
        }
        if (doWriteSplit(sessionId, inPath, params.sessionParams.sizeBytes, "base.apk",
                false /*logSuccess*/) != PackageInstaller.STATUS_SUCCESS) {
            return 1;
        }
        if (doCommitSession(sessionId, false /*logSuccess*/)
                != PackageInstaller.STATUS_SUCCESS) {
            return 1;
        }
        abandonSession = false;
        pw.println("Success");
        return 0;
    } finally {
        if (abandonSession) {
            try {
                doAbandonSession(sessionId, false /*logSuccess*/);
            } catch (Exception ignore) {
            }
        }
    }
}
 
Example 7
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int runRemoveSplit(String packageName, String splitName) throws RemoteException {
    final PrintWriter pw = getOutPrintWriter();
    final SessionParams sessionParams = new SessionParams(SessionParams.MODE_INHERIT_EXISTING);
    sessionParams.installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
    sessionParams.appPackageName = packageName;
    final int sessionId =
            doCreateSession(sessionParams, null /*installerPackageName*/, UserHandle.USER_ALL);
    boolean abandonSession = true;
    try {
        if (doRemoveSplit(sessionId, splitName, false /*logSuccess*/)
                != PackageInstaller.STATUS_SUCCESS) {
            return 1;
        }
        if (doCommitSession(sessionId, false /*logSuccess*/)
                != PackageInstaller.STATUS_SUCCESS) {
            return 1;
        }
        abandonSession = false;
        pw.println("Success");
        return 0;
    } finally {
        if (abandonSession) {
            try {
                doAbandonSession(sessionId, false /*logSuccess*/);
            } catch (Exception ignore) {
            }
        }
    }
}
 
Example 8
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int doCommitSession(int sessionId, boolean logSuccess) throws RemoteException {
    final PrintWriter pw = getOutPrintWriter();
    PackageInstaller.Session session = null;
    try {
        session = new PackageInstaller.Session(
                mInterface.getPackageInstaller().openSession(sessionId));

        // Sanity check that all .dm files match an apk.
        // (The installer does not support standalone .dm files and will not process them.)
        try {
            DexMetadataHelper.validateDexPaths(session.getNames());
        } catch (IllegalStateException | IOException e) {
            pw.println("Warning [Could not validate the dex paths: " + e.getMessage() + "]");
        }

        final LocalIntentReceiver receiver = new LocalIntentReceiver();
        session.commit(receiver.getIntentSender());

        final Intent result = receiver.getResult();
        final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
                PackageInstaller.STATUS_FAILURE);
        if (status == PackageInstaller.STATUS_SUCCESS) {
            if (logSuccess) {
                pw.println("Success");
            }
        } else {
            pw.println("Failure ["
                    + result.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) + "]");
        }
        return status;
    } finally {
        IoUtils.closeQuietly(session);
    }
}
 
Example 9
Source File: InstallResultReceiver.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override
public void onReceive(Context context, Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras != null && INSTALL_SESSION_API_COMPLETE_ACTION.equals(intent.getAction())) {
    int status = extras.getInt(PackageInstaller.EXTRA_STATUS);
    String message = extras.getString(PackageInstaller.EXTRA_STATUS_MESSAGE);
    String packageName = extras.getString(PackageInstaller.EXTRA_PACKAGE_NAME);
    switch (status) {
      case PackageInstaller.STATUS_PENDING_USER_ACTION:
        packageInstallerResultCallback.onPendingUserAction(extras);
        break;
      case PackageInstaller.STATUS_SUCCESS:
        packageInstallerResultCallback.onInstallationResult(
            new InstallStatus(InstallStatus.Status.SUCCESS, "Install succeeded", packageName));
        break;
      case PackageInstaller.STATUS_FAILURE:
      case PackageInstaller.STATUS_FAILURE_BLOCKED:
      case PackageInstaller.STATUS_FAILURE_CONFLICT:
      case PackageInstaller.STATUS_FAILURE_INCOMPATIBLE:
      case PackageInstaller.STATUS_FAILURE_INVALID:
      case PackageInstaller.STATUS_FAILURE_STORAGE:
        packageInstallerResultCallback.onInstallationResult(
            new InstallStatus(InstallStatus.Status.FAIL,
                "Install failed " + status + ", " + message, packageName));
        break;
      case PackageInstaller.STATUS_FAILURE_ABORTED:
        packageInstallerResultCallback.onInstallationResult(
            new InstallStatus(InstallStatus.Status.CANCELED,
                "Install failed " + status + ", " + message, packageName));
      default:
        packageInstallerResultCallback.onInstallationResult(
            new InstallStatus(InstallStatus.Status.UNKNOWN_ERROR,
                "Unrecognized status received from installer", packageName));
    }
  }
}
 
Example 10
Source File: EnableCosuActivity.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (!PackageInstallationUtils.ACTION_INSTALL_COMPLETE.equals(intent.getAction())) {
        return;
    }

    int result = intent.getIntExtra(PackageInstaller.EXTRA_STATUS,
            PackageInstaller.STATUS_FAILURE);
    String packageName = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME);
    if (CosuUtils.DEBUG) Log.d(CosuUtils.TAG, "PackageInstallerCallback: result=" + result
            + " packageName=" + packageName);
    switch (result) {
        case PackageInstaller.STATUS_PENDING_USER_ACTION: {
            // this should not happen in M, but will happen in L and L-MR1
            startActivity((Intent) intent.getParcelableExtra(Intent.EXTRA_INTENT));
        } break;
        case PackageInstaller.STATUS_SUCCESS: {
            mHandler.sendMessage(mHandler.obtainMessage(CosuUtils.MSG_INSTALL_COMPLETE,
                    packageName));
        } break;
        default: {
            Log.e(CosuUtils.TAG, "Install failed.");
            finishWithFailure();
            return;
        }
    }
}
 
Example 11
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private int runUninstall() throws RemoteException {
    final PrintWriter pw = getOutPrintWriter();
    int flags = 0;
    int userId = UserHandle.USER_ALL;
    long versionCode = PackageManager.VERSION_CODE_HIGHEST;

    String opt;
    while ((opt = getNextOption()) != null) {
        switch (opt) {
            case "-k":
                flags |= PackageManager.DELETE_KEEP_DATA;
                break;
            case "--user":
                userId = UserHandle.parseUserArg(getNextArgRequired());
                break;
            case "--versionCode":
                versionCode = Long.parseLong(getNextArgRequired());
                break;
            default:
                pw.println("Error: Unknown option: " + opt);
                return 1;
        }
    }

    final String packageName = getNextArg();
    if (packageName == null) {
        pw.println("Error: package name not specified");
        return 1;
    }

    // if a split is specified, just remove it and not the whole package
    final String splitName = getNextArg();
    if (splitName != null) {
        return runRemoveSplit(packageName, splitName);
    }

    userId = translateUserId(userId, true /*allowAll*/, "runUninstall");
    if (userId == UserHandle.USER_ALL) {
        userId = UserHandle.USER_SYSTEM;
        flags |= PackageManager.DELETE_ALL_USERS;
    } else {
        final PackageInfo info = mInterface.getPackageInfo(packageName,
                PackageManager.MATCH_STATIC_SHARED_LIBRARIES, userId);
        if (info == null) {
            pw.println("Failure [not installed for " + userId + "]");
            return 1;
        }
        final boolean isSystem =
                (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
        // If we are being asked to delete a system app for just one
        // user set flag so it disables rather than reverting to system
        // version of the app.
        if (isSystem) {
            flags |= PackageManager.DELETE_SYSTEM_APP;
        }
    }

    final LocalIntentReceiver receiver = new LocalIntentReceiver();
    mInterface.getPackageInstaller().uninstall(new VersionedPackage(packageName,
            versionCode), null /*callerPackageName*/, flags,
            receiver.getIntentSender(), userId);

    final Intent result = receiver.getResult();
    final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
            PackageInstaller.STATUS_FAILURE);
    if (status == PackageInstaller.STATUS_SUCCESS) {
        pw.println("Success");
        return 0;
    } else {
        pw.println("Failure ["
                + result.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) + "]");
        return 1;
    }
}
 
Example 12
Source File: InstallActivity.java    From XAPKInstaller with Apache License 2.0 4 votes vote down vote up
@TargetApi(21)
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Bundle extras = intent.getExtras();
    if (PACKAGE_INSTALLED_ACTION.equals(intent.getAction())) {
        int status = -100;
        String message = "";
        if (extras != null) {
            status = extras.getInt(PackageInstaller.EXTRA_STATUS);
            message = extras.getString(PackageInstaller.EXTRA_STATUS_MESSAGE);
        }
        switch (status) {
            case PackageInstaller.STATUS_PENDING_USER_ACTION:
                // This test app isn't privileged, so the user has to confirm the install.
                Intent confirmIntent = (Intent) extras.get(Intent.EXTRA_INTENT);
                startActivity(confirmIntent);
                break;
            case PackageInstaller.STATUS_SUCCESS:
                Toast.makeText(this, "安装成功!", Toast.LENGTH_SHORT).show();
                finish();
                break;
            case PackageInstaller.STATUS_FAILURE:
            case PackageInstaller.STATUS_FAILURE_ABORTED:
            case PackageInstaller.STATUS_FAILURE_BLOCKED:
            case PackageInstaller.STATUS_FAILURE_CONFLICT:
            case PackageInstaller.STATUS_FAILURE_INCOMPATIBLE:
            case PackageInstaller.STATUS_FAILURE_INVALID:
            case PackageInstaller.STATUS_FAILURE_STORAGE:
                Toast.makeText(this, "安装失败,请重试",
                        Toast.LENGTH_SHORT).show();
                finish();
                Log.d(TAG, "Install failed! " + status + ", " + message);
                break;
            default:
                Toast.makeText(this, "安装失败,解压文件可能已丢失或损坏,请重试",
                        Toast.LENGTH_SHORT).show();
                finish();
                Log.d(TAG, "Unrecognized status received from installer: " + status);
        }
    }
}
 
Example 13
Source File: InstallPackagesFinishedReceiver.java    From FreezeYou with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

    if (intent == null)
        return;

    int installStatus = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -1);
    String pkgName = intent.getStringExtra("pkgName");
    String name = intent.getStringExtra("name");

    Notification.Builder builder = Build.VERSION.SDK_INT >= 26 ?
            new Notification.Builder(context, "InstallPackages") :
            new Notification.Builder(context);

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    String message = null;
    if (installStatus != PackageInstaller.STATUS_SUCCESS) {
        message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
        if (message == null || "".equals(message)) {
            message = context.getString(R.string.unknown);
        }
        message = String.format(context.getString(R.string.reason_colon), message);
    }

    if (intent.getBooleanExtra("install", true)) {
        String apkFilePath = intent.getStringExtra("apkFilePath");

        // Delete Temp File
        InstallPackagesUtils.deleteTempFile(context, apkFilePath, false);

        if (installStatus == PackageInstaller.STATUS_SUCCESS) {
            InstallPackagesUtils
                    .notifyFinishNotification(
                            context, notificationManager, builder,
                            true,
                            pkgName,
                            String.format(context.getString(R.string.app_installFinished), name),
                            null,
                            true);

            if (PreferenceManager.getDefaultSharedPreferences(context)
                    .getBoolean("tryDelApkAfterInstalled", false))
                InstallPackagesUtils.deleteTempFile(context, apkFilePath, true);

        } else {
            InstallPackagesUtils
                    .notifyFinishNotification(
                            context, notificationManager, builder,
                            true,
                            pkgName,
                            String.format(context.getString(R.string.app_installFailed), name),
                            message,
                            false);
        }
    } else {
        if (installStatus == PackageInstaller.STATUS_SUCCESS) {
            InstallPackagesUtils
                    .notifyFinishNotification(
                            context, notificationManager, builder,
                            true,
                            pkgName,
                            String.format(context.getString(R.string.app_uninstallFinished), name),
                            null,
                            true);
        } else {
            InstallPackagesUtils
                    .notifyFinishNotification(
                            context, notificationManager, builder,
                            true,
                            pkgName,
                            String.format(context.getString(R.string.app_uninstallFailed), name),
                            message,
                            false);
        }
    }

}
 
Example 14
Source File: PackageHelper.java    From container with GNU General Public License v3.0 4 votes vote down vote up
/** {@hide} */
public static int installStatusToPublicStatus(int status) {
    switch (status) {
        case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
        case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
        case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
        case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
        case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
        case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
        case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
        case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
        case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
        case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
        case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
        case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
        case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
        case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
        case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
        case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
        case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
        case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
        default: return PackageInstaller.STATUS_FAILURE;
    }
}