private void fallbackToSystemPackageInstaller(final String reason, final @Nullable Exception e) {
		final Intent intent = new Intent(getIntent()).setPackage(null).setComponent(null);
		Analytics.$().event("installer_fallback").with(LOCATION, intent.getDataString()).with(ITEM_CATEGORY, reason).with(CONTENT, e != null ? e.toString() : null).send();
		for (final String category : Optional.ofNullable(intent.getCategories()).orElse(Collections.emptySet())) intent.removeCategory(category);

		if (SDK_INT >= O && ! Users.isOwner() && SCHEME_PACKAGE.equals(intent.getScheme())) {	// Scheme "package" is no go in managed profile since Android O.
			final String pkg = requireNonNull(intent.getData()).getSchemeSpecificPart();
			ApplicationInfo info = Apps.of(this).getAppInfo(pkg);
			if (info == null) info = intent.getParcelableExtra(InstallerExtras.EXTRA_APP_INFO);
			if (info != null) {
				intent.setData(Uri.fromFile(new File(info.publicSourceDir)));
 				if (info.splitPublicSourceDirs != null && info.splitPublicSourceDirs.length > 0)
					Toast.makeText(getApplicationContext(), R.string.toast_split_apk_clone_fallback_warning, Toast.LENGTH_LONG).show();
			}
		}

		AppInstallerUtils.ensureSystemPackageEnabledAndUnfrozen(this, intent);

		final List<ResolveInfo> candidates = getPackageManager().queryIntentActivities(intent,
				PackageManager.MATCH_DEFAULT_ONLY | PackageManager.MATCH_SYSTEM_ONLY);
		for (final ResolveInfo candidate : candidates) {
			final ActivityInfo activity = candidate.activityInfo;
			if ((activity.applicationInfo.flags & FLAG_SYSTEM) == 0) continue;
			final ComponentName component = new ComponentName(activity.packageName, activity.name);
			intent.setComponent(component).setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
			Log.i(TAG, "Redirect to system package installer: " + component.flattenToShortString());

			final StrictMode.VmPolicy vm_policy = StrictMode.getVmPolicy();
			StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().build());		// Workaround to suppress FileUriExposedException.
			try {
				final Intent uas_settings; final PackageManager pm = getPackageManager();
				if (SDK_INT >= O && ! pm.canRequestPackageInstalls() && (uas_settings = new Intent(ACTION_MANAGE_UNKNOWN_APP_SOURCES,
						Uri.fromParts(SCHEME_PACKAGE, getPackageName(), null))).resolveActivity(pm) != null)
					startActivities(new Intent[] { intent, uas_settings });
				else startActivity(intent);
			} catch (final SecurityException security_exception) {		// UID {UID} does not have permission to {uri}
				fallbackToSystemPackageInstaller("uri_permission", security_exception);
				return;
			} finally {
				StrictMode.setVmPolicy(vm_policy);
			}
			finish();	// No need to setResult() if default installer is started, since FLAG_ACTIVITY_FORWARD_RESULT is used.
			return;
		}
		Log.e(TAG, "Default system package installer is missing");
		setResult(RESULT_CANCELED);
		finish();
	}
@param base_pkg the base package name for split APK installation, or null for full installation.
installer/src/main/java/com/oasisfeng/island/installer/AppInstallerActivity.java