Sync installed app database with package manager on PACKAGE_CHANGED for shared libraries

This commit is contained in:
Oliver Scott 2021-04-27 11:27:14 -04:00 committed by Uldiniad
parent 471d2b86c7
commit e677d815d4

View File

@ -3,10 +3,12 @@ package org.fdroid.fdroid.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import org.fdroid.fdroid.data.InstalledAppProviderService;
import org.fdroid.fdroid.installer.PrivilegedInstaller;
/**
* Receive {@link Intent#ACTION_PACKAGE_ADDED} and {@link Intent#ACTION_PACKAGE_REMOVED}
@ -32,6 +34,15 @@ public class PackageManagerReceiver extends BroadcastReceiver {
} else {
InstalledAppProviderService.delete(context, intent.getData());
}
} else if (Intent.ACTION_PACKAGE_CHANGED.equals(action) && Build.VERSION.SDK_INT >= 29 &&
PrivilegedInstaller.isExtensionInstalledCorrectly(context) ==
PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES) {
String[] allowList = new String[]{"org.chromium.chrome"};
for (String allowed : allowList) {
if (allowed.equals(intent.getData().getSchemeSpecificPart())) {
InstalledAppProviderService.compareToPackageManager(context);
}
}
} else {
Log.i(TAG, "unsupported action: " + action + " " + intent);
}