mirror of
https://github.com/MaintainTeam/Hypatia.git
synced 2025-02-28 21:38:21 +03:00
Move each FileObserver onto its own thread
This commit is contained in:
parent
abf4baf16d
commit
73be65ec2c
2 changed files with 13 additions and 6 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -24,7 +24,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.os.IBinder;
|
|||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
@ -29,7 +30,10 @@ public class MalwareScannerService extends Service {
|
|||
|
||||
@Override
|
||||
public final int onStartCommand(Intent intent, int flags, int startId) {
|
||||
threadPoolExecutor = Utils.getThreadPoolExecutor();
|
||||
malwareMonitors.clear();
|
||||
addMalwareMonitor(Environment.getExternalStorageDirectory().toString());
|
||||
|
||||
threadPoolExecutor = (ThreadPoolExecutor) Executors.newScheduledThreadPool(Utils.getMaxThreads() + malwareMonitors.size());
|
||||
threadPoolExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -37,10 +41,13 @@ public class MalwareScannerService extends Service {
|
|||
}
|
||||
});
|
||||
|
||||
malwareMonitors.clear();
|
||||
addMalwareMonitor(Environment.getExternalStorageDirectory().toString());
|
||||
for (RecursiveFileObserver malwareMonitor : malwareMonitors) {
|
||||
malwareMonitor.startWatching();
|
||||
for (final RecursiveFileObserver malwareMonitor : malwareMonitors) {
|
||||
threadPoolExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
malwareMonitor.startWatching();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
|
Loading…
Add table
Reference in a new issue