Declare QUERY_ALL_PACKAGES

Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
Tad 2023-12-22 14:59:47 -05:00
parent c15aba2a97
commit 55305f88f1
4 changed files with 11 additions and 3 deletions

View file

@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<queries> <queries>
<package android:name="org.torproject.android" /> <package android:name="org.torproject.android" />

View file

@ -32,14 +32,16 @@ public class EventReceiver extends BroadcastReceiver {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Utils.considerStartService(context); Utils.considerStartService(context);
} }
//Broken on Android 8.0+
if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) { if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
if (intent.getDataString().contains(context.getPackageName())) { if (intent.getDataString().contains(context.getPackageName())) {
Utils.considerStartService(context); //We've been updated, restart service Utils.considerStartService(context); //We've been updated, restart service
} else { } else {
//Log.d("Hypatia", "An app has been updated");
//scanApp(context, intent.getDataString());//An app was updated, scan it //scanApp(context, intent.getDataString());//An app was updated, scan it
} }
} } else if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) { //Log.d("Hypatia", "An app has been installed");
//scanApp(context, intent.getDataString());//An app was installed, scan it //scanApp(context, intent.getDataString());//An app was installed, scan it
} }
} }
@ -48,7 +50,9 @@ public class EventReceiver extends BroadcastReceiver {
if (Utils.isServiceRunning(MalwareScannerService.class, context)) { if (Utils.isServiceRunning(MalwareScannerService.class, context)) {
HashSet<File> filesToScan = new HashSet<>(); HashSet<File> filesToScan = new HashSet<>();
try { try {
filesToScan.add(new File(context.getPackageManager().getApplicationInfo(appID, PackageManager.GET_META_DATA).sourceDir)); File appToScan = new File(context.getPackageManager().getApplicationInfo(appID, PackageManager.GET_META_DATA).sourceDir);
//Log.d("Hypatia", "Scanning app " + appToScan);
filesToScan.add(appToScan);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -251,6 +251,7 @@ public class MainActivity extends Activity {
if (scanApps) { if (scanApps) {
for (ApplicationInfo packageInfo : getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA)) { for (ApplicationInfo packageInfo : getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA)) {
filesToScan.add(new File(packageInfo.sourceDir)); filesToScan.add(new File(packageInfo.sourceDir));
//Log.d("Hypatia", "Planning to scan " + packageInfo.sourceDir);
} }
} }
if (scanInternal) { if (scanInternal) {

View file

@ -207,6 +207,8 @@ class MalwareScanner extends AsyncTask<HashSet<File>, Object, String> {
for (Map.Entry<File, String> file : signaturesToCheck.entrySet()) { for (Map.Entry<File, String> file : signaturesToCheck.entrySet()) {
if (signatureDatabase.mightContain(file.getValue())) { if (signatureDatabase.mightContain(file.getValue())) {
publishProgress("Potential match in " + file.getKey().toString().replaceAll(Environment.getExternalStorageDirectory().toString(), "~"), false); publishProgress("Potential match in " + file.getKey().toString().replaceAll(Environment.getExternalStorageDirectory().toString(), "~"), false);
} else {
//Log.d("Hypatia", "No match for " + file.getValue());
} }
} }
publishProgress("\t" + context.getString(R.string.main_hash_scan_done, hashType) + "\n", true); publishProgress("\t" + context.getString(R.string.main_hash_scan_done, hashType) + "\n", true);