Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b799d424 authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

rewrite OMS onStartCommand() part that load data from intent. add a check that intent isn't null

parent f7ba4bd8
Loading
Loading
Loading
Loading
+44 −43
Original line number Diff line number Diff line
@@ -229,28 +229,32 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
        Log.i(TAG, "onStartCommand()");

        CommonUtils.setServiceUnCaughtExceptionHandler(this);
        if(intent == null || intent.getExtras() == null){
            Log.w(TAG, "Intent or it's extras is null.");
            return super.onStartCommand(intent, flags, startId);
        }

        Bundle extras = intent.getExtras();
        Log.d(TAG, "OperationManagerService recieved "+(extras == null ? "null extras": extras.size()+" operations to perform") );

        if(extras != null) {
        //Load operation from intent
        this.mOperationsQueue = new ConcurrentLinkedDeque<>();
        for (String key : extras.keySet()) {

            Parcelable parcelableObject = extras.getParcelable(key);
            String parcelableClassName = parcelableObject.getClass().getSimpleName();
            if(key.equals("account")){
                    this.mAccount = (Account) parcelableObject;
                mAccount = (Account) parcelableObject;
            }
                else if (parcelableObject.getClass().getName().equals(DownloadFileOperation.class.getName())) {
            else if (parcelableClassName.equals(DownloadFileOperation.class.getSimpleName())) {
                DownloadFileOperation download = (DownloadFileOperation) parcelableObject;
                download.setContext(getApplicationContext());
                mOperationsQueue.add(download);
                } else if (parcelableObject.getClass().getName().equals(UploadFileOperation.class.getName())) {
            } else if (parcelableClassName.equals(UploadFileOperation.class.getSimpleName())) {
                UploadFileOperation upload = (UploadFileOperation) parcelableObject;
                upload.setContext(getApplicationContext());
                mOperationsQueue.add(upload);
                } else if (parcelableObject.getClass().getName().equals(RemoveFileOperation.class.getName())) {
            } else if (parcelableClassName.equals(RemoveFileOperation.class.getSimpleName())) {
                mOperationsQueue.add((RemoveFileOperation) parcelableObject);
            }
        }
@@ -279,9 +283,6 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
            Log.w(TAG, "No Client, Can't Work!");
            stopSelf();
        }
        }else{
            Log.w(TAG, "Intent's extras is null.");
        }
        return super.onStartCommand(intent, flags, startId);
    }