mirror of
https://github.com/MaintainTeam/Hypatia.git
synced 2025-02-28 21:38:21 +03:00
(DISABLED: Broken) Scan APKs on install/update
This commit is contained in:
parent
2f07219c02
commit
12570f4b2e
2 changed files with 29 additions and 3 deletions
|
@ -40,10 +40,10 @@
|
|||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
|
|
@ -4,6 +4,11 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
public class EventReceiver extends BroadcastReceiver {
|
||||
|
||||
|
@ -12,8 +17,15 @@ public class EventReceiver extends BroadcastReceiver {
|
|||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||
considerStartService(context);
|
||||
}
|
||||
if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED) && intent.getDataString().contains(context.getPackageName())) {
|
||||
considerStartService(context);
|
||||
if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
|
||||
if (intent.getDataString().contains(context.getPackageName())) {
|
||||
considerStartService(context); //We've been updated, restart service
|
||||
} else {
|
||||
//scanApp(context, intent.getDataString());//An app was updated, scan it
|
||||
}
|
||||
}
|
||||
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
|
||||
//scanApp(context, intent.getDataString());//An app was installed, scan it
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,4 +41,18 @@ public class EventReceiver extends BroadcastReceiver {
|
|||
}
|
||||
}
|
||||
|
||||
private static void scanApp(Context context, String appID) {
|
||||
if (Utils.isServiceRunning(MalwareScannerService.class, context)) {
|
||||
THashSet<File> filesToScan = new THashSet<>();
|
||||
try {
|
||||
filesToScan.add(new File(context.getPackageManager().getApplicationInfo(appID, PackageManager.GET_META_DATA).sourceDir));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (filesToScan.size() > 0) {
|
||||
new MalwareScanner(null, context, false).execute(filesToScan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue