Commit fe90bc08 authored by narinder Rana's avatar narinder Rana
Browse files

improve bundle value

parent e23d7aa6
Pipeline #132638 failed with stage
in 8 seconds
......@@ -137,10 +137,17 @@ public class FileObserverService extends Service {
// Log.e("onPostExecute", "...ObserverService Intent..." );
// Do something after 20s = 20000ms
Intent observersServiceIntent = new Intent(getApplicationContext(), foundation.e.drive.services.ObserverService.class);
observersServiceIntent.putExtra("isFileObserverService", true);
observersServiceIntent.putExtra("fileObserverObject", new foundation.e.drive.models.FileObserver(files, syncedFileStatesList));
startService(observersServiceIntent);
try {
Log.e("TAG", "=========================================");
Log.e("TAG", "File Observer to Observer services.....");
Intent observersServiceIntent = new Intent(getApplicationContext(), foundation.e.drive.services.ObserverService.class);
observersServiceIntent.putExtra("isFileObserverService", true);
observersServiceIntent.putExtra("fileObserverObject", CommonUtils.convertToBytes(new foundation.e.drive.models.FileObserver(files, syncedFileStatesList)));
startService(observersServiceIntent);
}catch (Exception exception){
exception.printStackTrace();
}
observerFlag=-1;
}
......
......@@ -15,6 +15,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Parcelable;
......@@ -69,7 +70,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
private int initialFolderCounter;
private Account mAccount;
private HashMap<Integer, Parcelable> operationsForIntent;
private Boolean isFileObserverService;
private Boolean isFileObserverService=false;
private foundation.e.drive.models.FileObserver fileObserverObject;
/* Lifecycle Methods */
......@@ -85,8 +86,12 @@ public class ObserverService extends Service implements OnRemoteOperationListene
Log.i(TAG, "onStartCommand("+startId+")");
try {
isFileObserverService = (Boolean)intent.getExtras().get("isFileObserverService");
fileObserverObject = (foundation.e.drive.models.FileObserver)intent.getExtras().get("fileObserverObject");
Bundle bundle = intent.getExtras();
if(null!=bundle){
isFileObserverService = bundle.getBoolean("isFileObserverService");
fileObserverObject = (foundation.e.drive.models.FileObserver)CommonUtils.convertFromBytes(bundle.getByteArray("fileObserverObject"));
}
}catch (Exception ex){
ex.printStackTrace();
......@@ -546,7 +551,8 @@ public class ObserverService extends Service implements OnRemoteOperationListene
* Prepare the list of files and SyncedFileState for synchronisation
*/
private void scanLocalFiles(){
Log.i( TAG, "scanLocalFiles()" );
Log.e( TAG, "========================================================" );
Log.e( TAG, "scanLocalFiles()" );
List<File> fileList = new ArrayList<>();
List<Long> folderIdList= new ArrayList<>();
boolean contentToSyncFound = false;
......@@ -654,7 +660,8 @@ public class ObserverService extends Service implements OnRemoteOperationListene
* @param syncedFileStates List of SyncedFileState to scan
*/
private void handleLocalFiles(List<File> localFileList, List<SyncedFileState> syncedFileStates ){
Log.i(TAG, "handleLocalFiles()");
Log.e( TAG, "========================================================" );
Log.e(TAG, "handleLocalFiles()");
Log.d(TAG, "Loop through local file list");
Log.v(TAG, "format: filePath, exist, lastModified) :");
......
......@@ -300,7 +300,7 @@ public abstract class CommonUtils {
/*
this function convert object to bytes
*/
private byte[] convertToBytes(Object object) throws IOException {
public static byte[] convertToBytes(Object object) throws IOException {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos)) {
out.writeObject(object);
......@@ -311,7 +311,7 @@ public abstract class CommonUtils {
/*
this function convert bytes to Object
*/
private Object convertFromBytes(byte[] bytes) throws IOException, ClassNotFoundException {
public static Object convertFromBytes(byte[] bytes) throws IOException, ClassNotFoundException {
try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream in = new ObjectInputStream(bis)) {
return in.readObject();
......
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