Commit 372201e6 authored by narinder Rana's avatar narinder Rana
Browse files

assign and Manage value to flags

parent b08bf215
Pipeline #134261 failed with stage
in 6 seconds
......@@ -13,7 +13,10 @@ import android.app.job.JobService;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import foundation.e.drive.receivers.ConnectivityReceiver;
import foundation.e.drive.receivers.ScreenOffReceiver;
import foundation.e.drive.services.InitializerService;
import foundation.e.drive.services.ObserverService;
import foundation.e.drive.utils.CommonUtils;
......@@ -32,10 +35,18 @@ public class ScannerJob extends JobService {
filter.addAction(Intent.ACTION_SCREEN_OFF);
getApplicationContext().registerReceiver(ScreenOffReceiver.getInstance(), filter);
Intent observerServiceIntent = new Intent(this, ObserverService.class);
this.startService(observerServiceIntent);
jobFinished(params, false);
return true;
if(ConnectivityReceiver.isConnected(getApplicationContext())){
Intent observerServiceIntent = new Intent(this, ObserverService.class);
this.startService(observerServiceIntent);
jobFinished(params, false);
return true;
}
else {
InitializerService.fileObserverFlag=true;
return false;
}
}
/**
......
......@@ -22,7 +22,7 @@ public class ConnectivityReceiver
super();
}
public boolean isConnected(Context context) {
public static boolean isConnected(Context context) {
// String command = "ping -c 1 e.foundation";
// return (Runtime.getRuntime().exec(command).waitFor() == 0);
try {
......@@ -55,6 +55,7 @@ public class ConnectivityReceiver
if(InitializerService.schedulerFlag){
context.startService(observersServiceIntent);
}else if(InitializerService.fileObserverFlag) {
//
Bundle mBundle = new Bundle();
......@@ -63,6 +64,8 @@ public class ConnectivityReceiver
context.startService(observersServiceIntent);
}
InitializerService.schedulerFlag=false;
InitializerService.fileObserverFlag=false;
}
}
......
......@@ -20,6 +20,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import foundation.e.drive.receivers.ConnectivityReceiver;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.RecursiveFileObserver;
......@@ -62,28 +63,6 @@ public class FileObserverService extends Service {
if(event== FileObserver.CREATE || event==FileObserver.MODIFY || event== FileObserver.DELETE || event ==FileObserver.MOVED_TO){
Log.e("OnEvent", "...Event ..." + event+"...file ..." + file);
//getting null
//
// SyncedFileState syncedFileStates = DbHelper.loadSyncedFile(getApplicationContext(), file.getPath(), true);
//
// if(null==syncedFileStates){
// syncedFileStates = new SyncedFileState(-1, file.getName(), file.getPath(), file.getRemoteFolder() + localFile.getName(), "", 0, syncedFolder.getId(), syncedFolder.isMediaType());
//
// //Store it in DB
// int storedId = DbHelper.manageSyncedFileStateDB(newSyncedFileState, "INSERT", this);
// if(storedId > 0){
// newSyncedFileState.setId( storedId );
// Log.i(TAG, "Add upload operation for new file "+storedId);
// //create UploadOperation and add it into bundle
// UploadFileOperation uploadOperation = new UploadFileOperation(newSyncedFileState, syncedFolder.isScanRemote());
// this.operationsForIntent.put(storedId, uploadOperation);
// }else{
// Log.w(TAG, "The new file to synced cannot be store in DB. Ignore it");
// }
// }
// syncedFileStatesList.add(syncedFileStates);
if(!InitializerService.files.contains(file)){
Log.e(TAG, "adding new file into files list "+file.getName() +" .... "+file.getAbsolutePath());
InitializerService.files.add(file);
......@@ -96,16 +75,22 @@ public class FileObserverService extends Service {
//InitializerService.fileObserver.add(file);
//call to ObserverService >> getSyncedFileState >> HandleLocal File
try
{
if(observerFlag == -1){
new AsyncTaskRunner().execute("");
if(ConnectivityReceiver.isConnected(getApplicationContext())){
try
{
if(observerFlag == -1){
new AsyncTaskRunner().execute("");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
catch (Exception e)
{
e.printStackTrace();
else {
InitializerService.fileObserverFlag=true;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment