Skip to content

Commit

Permalink
UPDATE: Minor tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
oasisfeng committed Oct 12, 2023
1 parent 88c9dd4 commit bd22f4f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ private boolean prepare() {
}
}

//noinspection deprecation
if (caller.equals(getPackageName()) || requireNonNull(PreferenceManager.getDefaultSharedPreferences(this)
.getStringSet(PREF_KEY_DIRECT_INSTALL_ALLOWED_CALLERS, Collections.emptySet())).contains(caller)) {
performInstall(data, null); // Whitelisted caller to perform installation without confirmation
Expand All @@ -234,6 +235,7 @@ private boolean prepare() {
}

private void addAlwaysAllowedCallerPackage(final String pkg) {
//noinspection deprecation
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final Set<String> pkgs = new HashSet<>(requireNonNull(preferences.getStringSet(PREF_KEY_DIRECT_INSTALL_ALLOWED_CALLERS, Collections.emptySet())));
pkgs.add(pkg);
Expand All @@ -260,7 +262,7 @@ private void performInstall(final Uri uri, final @Nullable String base_pkg) {
if (info.splitPublicSourceDirs != null)
for (int i = 0, num_splits = info.splitPublicSourceDirs.length; i < num_splits; i ++) {
final String split = info.splitPublicSourceDirs[i];
input_streams.put(SDK_INT >= O ? info.splitNames[i] : "split" + i, new FileInputStream(split));
input_streams.put(SDK_INT >= O && info.splitNames != null ? info.splitNames[i] : "split" + i, new FileInputStream(split));
}
} else input_streams.put(stream_name, requireNonNull(getContentResolver().openInputStream(uri)));
} catch(final IOException | RuntimeException e) { // SecurityException may be thrown by ContentResolver.openInputStream().
Expand Down Expand Up @@ -325,7 +327,7 @@ private void fallbackToSystemPackageInstaller(final String reason, final @Nullab
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)
if (info.splitPublicSourceDirs != null && info.splitPublicSourceDirs.length > 0)
Toast.makeText(getApplicationContext(), R.string.toast_split_apk_clone_fallback_warning, LENGTH_LONG).show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class IslandAppClones(val activity: FragmentActivity, val vm: AndroidViewModel,
val fragment = ModelBottomSheetFragment()
val alp = IslandAppListProvider.getInstance(context)
val dialog = AppClonesBottomSheet(targets, icons, { user -> alp.isInstalled(pkg, user) }) { target, mode ->
// The normal follow-up procedure goes here
makeAppAvailable(target, mode)
fragment.dismiss() }

Expand Down Expand Up @@ -131,7 +132,9 @@ class IslandAppClones(val activity: FragmentActivity, val vm: AndroidViewModel,
} else if (target != null && target.isInstalled && !target.enabled) { // Disabled app may be shown as "removed"
launchSystemAppSettings(target)
Toast.makeText(activity, R.string.toast_enable_disabled_system_app, Toast.LENGTH_SHORT).show()
} else vm.interactive(context) { cloneApp(app, profile, mode) }
} else vm.interactive(context) {
cloneApp(app, profile, mode)
}
}

private suspend fun cloneApp(source: IslandAppInfo, target: UserHandle, mode: @AppCloneMode Int) {
Expand Down
2 changes: 1 addition & 1 deletion shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
}

// Enable lint checking in all build variants.
libraryVariants.all { variant ->
libraryVariants.configureEach { variant ->
variant.outputs.each { output ->
def lintTask = tasks["lint${variant.name.capitalize()}"]
output.assemble.dependsOn lintTask
Expand Down

0 comments on commit bd22f4f

Please sign in to comment.