1 /* ownCloud Android client application
2 * Copyright (C) 2012-2014 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package com
.owncloud
.android
.services
;
20 import java
.io
.IOException
;
21 import java
.util
.Iterator
;
22 import java
.util
.concurrent
.ConcurrentHashMap
;
23 import java
.util
.concurrent
.ConcurrentLinkedQueue
;
24 import java
.util
.concurrent
.ConcurrentMap
;
26 import com
.owncloud
.android
.MainApp
;
27 import com
.owncloud
.android
.R
;
28 import com
.owncloud
.android
.datamodel
.FileDataStorageManager
;
29 import com
.owncloud
.android
.lib
.common
.OwnCloudClient
;
30 import com
.owncloud
.android
.lib
.common
.OwnCloudCredentials
;
31 import com
.owncloud
.android
.lib
.common
.OwnCloudCredentialsFactory
;
32 import com
.owncloud
.android
.lib
.common
.accounts
.AccountUtils
.AccountNotFoundException
;
33 import com
.owncloud
.android
.lib
.common
.operations
.OnRemoteOperationListener
;
34 import com
.owncloud
.android
.lib
.common
.operations
.RemoteOperation
;
35 import com
.owncloud
.android
.lib
.common
.operations
.RemoteOperationResult
;
36 import com
.owncloud
.android
.lib
.resources
.files
.ExistenceCheckRemoteOperation
;
37 import com
.owncloud
.android
.lib
.resources
.shares
.ShareType
;
38 import com
.owncloud
.android
.lib
.resources
.users
.GetRemoteUserNameOperation
;
39 import com
.owncloud
.android
.operations
.common
.SyncOperation
;
40 import com
.owncloud
.android
.operations
.CreateFolderOperation
;
41 import com
.owncloud
.android
.operations
.CreateShareOperation
;
42 import com
.owncloud
.android
.operations
.GetServerInfoOperation
;
43 import com
.owncloud
.android
.operations
.OAuth2GetAccessToken
;
44 import com
.owncloud
.android
.operations
.RemoveFileOperation
;
45 import com
.owncloud
.android
.operations
.RenameFileOperation
;
46 import com
.owncloud
.android
.operations
.SynchronizeFileOperation
;
47 import com
.owncloud
.android
.operations
.UnshareLinkOperation
;
48 import com
.owncloud
.android
.utils
.Log_OC
;
50 import android
.accounts
.Account
;
51 import android
.accounts
.AccountsException
;
52 import android
.accounts
.AuthenticatorException
;
53 import android
.accounts
.OperationCanceledException
;
54 import android
.app
.Service
;
55 import android
.content
.Intent
;
56 import android
.net
.Uri
;
57 import android
.os
.Binder
;
58 import android
.os
.Handler
;
59 import android
.os
.HandlerThread
;
60 import android
.os
.IBinder
;
61 import android
.os
.Looper
;
62 import android
.os
.Message
;
63 import android
.os
.Process
;
64 import android
.util
.Pair
;
66 public class OperationsService
extends Service
{
68 private static final String TAG
= OperationsService
.class.getSimpleName();
70 public static final String EXTRA_ACCOUNT
= "ACCOUNT";
71 public static final String EXTRA_SERVER_URL
= "SERVER_URL";
72 public static final String EXTRA_AUTH_TOKEN_TYPE
= "AUTH_TOKEN_TYPE";
73 public static final String EXTRA_OAUTH2_QUERY_PARAMETERS
= "OAUTH2_QUERY_PARAMETERS";
74 public static final String EXTRA_REMOTE_PATH
= "REMOTE_PATH";
75 public static final String EXTRA_SEND_INTENT
= "SEND_INTENT";
76 public static final String EXTRA_NEWNAME
= "NEWNAME";
77 public static final String EXTRA_REMOVE_ONLY_LOCAL
= "REMOVE_LOCAL_COPY";
78 public static final String EXTRA_CREATE_FULL_PATH
= "CREATE_FULL_PATH";
79 public static final String EXTRA_SYNC_FILE_CONTENTS
= "SYNC_FILE_CONTENTS";
80 public static final String EXTRA_RESULT
= "RESULT";
82 // TODO review if ALL OF THEM are necessary
83 public static final String EXTRA_WEBDAV_PATH
= "WEBDAV_PATH";
84 public static final String EXTRA_SUCCESS_IF_ABSENT
= "SUCCESS_IF_ABSENT";
85 public static final String EXTRA_USERNAME
= "USERNAME";
86 public static final String EXTRA_PASSWORD
= "PASSWORD";
87 public static final String EXTRA_AUTH_TOKEN
= "AUTH_TOKEN";
88 public static final String EXTRA_FOLLOW_REDIRECTS
= "FOLLOW_REDIRECTS";
89 public static final String EXTRA_COOKIE
= "COOKIE";
91 public static final String ACTION_CREATE_SHARE
= "CREATE_SHARE";
92 public static final String ACTION_UNSHARE
= "UNSHARE";
93 public static final String ACTION_GET_SERVER_INFO
= "GET_SERVER_INFO";
94 public static final String ACTION_OAUTH2_GET_ACCESS_TOKEN
= "OAUTH2_GET_ACCESS_TOKEN";
95 public static final String ACTION_EXISTENCE_CHECK
= "EXISTENCE_CHECK";
96 public static final String ACTION_GET_USER_NAME
= "GET_USER_NAME";
97 public static final String ACTION_RENAME
= "RENAME";
98 public static final String ACTION_REMOVE
= "REMOVE";
99 public static final String ACTION_CREATE_FOLDER
= "CREATE_FOLDER";
100 public static final String ACTION_SYNC_FILE
= "SYNC_FILE";
102 public static final String ACTION_OPERATION_ADDED
= OperationsService
.class.getName() + ".OPERATION_ADDED";
103 public static final String ACTION_OPERATION_FINISHED
= OperationsService
.class.getName() + ".OPERATION_FINISHED";
105 private ConcurrentLinkedQueue
<Pair
<Target
, RemoteOperation
>> mPendingOperations
=
106 new ConcurrentLinkedQueue
<Pair
<Target
, RemoteOperation
>>();
108 private ConcurrentMap
<Integer
, Pair
<RemoteOperation
, RemoteOperationResult
>>
109 mUndispatchedFinishedOperations
=
110 new ConcurrentHashMap
<Integer
, Pair
<RemoteOperation
, RemoteOperationResult
>>();
112 private static class Target
{
113 public Uri mServerUrl
= null
;
114 public Account mAccount
= null
;
115 public String mWebDavUrl
= null
;
116 public String mUsername
= null
;
117 public String mPassword
= null
;
118 public String mAuthToken
= null
;
119 public boolean mFollowRedirects
= true
;
120 public String mCookie
= null
;
122 public Target(Account account
, Uri serverUrl
, String webdavUrl
, String username
, String password
, String authToken
,
123 boolean followRedirects
, String cookie
) {
125 mServerUrl
= serverUrl
;
126 mWebDavUrl
= webdavUrl
;
127 mUsername
= username
;
128 mPassword
= password
;
129 mAuthToken
= authToken
;
130 mFollowRedirects
= followRedirects
;
135 private Looper mServiceLooper
;
136 private ServiceHandler mServiceHandler
;
137 private OperationsServiceBinder mBinder
;
138 private OwnCloudClient mOwnCloudClient
= null
;
139 private Target mLastTarget
= null
;
140 private FileDataStorageManager mStorageManager
;
141 private RemoteOperation mCurrentOperation
= null
;
145 * Service initialization
148 public void onCreate() {
150 HandlerThread thread
= new HandlerThread("Operations service thread", Process
.THREAD_PRIORITY_BACKGROUND
);
152 mServiceLooper
= thread
.getLooper();
153 mServiceHandler
= new ServiceHandler(mServiceLooper
, this);
154 mBinder
= new OperationsServiceBinder();
159 * Entry point to add a new operation to the queue of operations.
161 * New operations are added calling to startService(), resulting in a call to this method.
162 * This ensures the service will keep on working although the caller activity goes away.
164 * IMPORTANT: the only operations performed here right now is {@link GetSharedFilesOperation}. The class
165 * is taking advantage of it due to time constraints.
168 public int onStartCommand(Intent intent
, int flags
, int startId
) {
169 //Log_OC.wtf(TAG, "onStartCommand init" );
170 Message msg
= mServiceHandler
.obtainMessage();
172 mServiceHandler
.sendMessage(msg
);
173 //Log_OC.wtf(TAG, "onStartCommand end" );
174 return START_NOT_STICKY
;
178 public void onDestroy() {
179 //Log_OC.wtf(TAG, "onDestroy init" );
182 ((MainApp
)getApplicationContext()).getOwnCloudClientManager().
183 saveAllClients(this, MainApp
.getAccountType());
185 // TODO - get rid of these exceptions
186 } catch (AccountNotFoundException e
) {
188 } catch (AuthenticatorException e
) {
190 } catch (OperationCanceledException e
) {
192 } catch (IOException e
) {
196 //Log_OC.wtf(TAG, "Clear mUndispatchedFinisiedOperations" );
197 mUndispatchedFinishedOperations
.clear();
199 //Log_OC.wtf(TAG, "onDestroy end" );
205 * Provides a binder object that clients can use to perform actions on the queue of operations,
206 * except the addition of new operations.
209 public IBinder
onBind(Intent intent
) {
210 //Log_OC.wtf(TAG, "onBind" );
216 * Called when ALL the bound clients were unbound.
219 public boolean onUnbind(Intent intent
) {
220 ((OperationsServiceBinder
)mBinder
).clearListeners();
221 return false
; // not accepting rebinding (default behaviour)
226 * Binder to let client components to perform actions on the queue of operations.
228 * It provides by itself the available operations.
230 public class OperationsServiceBinder
extends Binder
/* implements OnRemoteOperationListener */ {
233 * Map of listeners that will be reported about the end of operations from a {@link OperationsServiceBinder} instance
235 private ConcurrentMap
<OnRemoteOperationListener
, Handler
> mBoundListeners
=
236 new ConcurrentHashMap
<OnRemoteOperationListener
, Handler
>();
239 * Cancels an operation
243 public void cancel() {
248 public void clearListeners() {
250 mBoundListeners
.clear();
255 * Adds a listener interested in being reported about the end of operations.
257 * @param listener Object to notify about the end of operations.
258 * @param callbackHandler {@link Handler} to access the listener without breaking Android threading protection.
260 public void addOperationListener (OnRemoteOperationListener listener
, Handler callbackHandler
) {
261 synchronized (mBoundListeners
) {
262 mBoundListeners
.put(listener
, callbackHandler
);
268 * Removes a listener from the list of objects interested in the being reported about the end of operations.
270 * @param listener Object to notify about progress of transfer.
272 public void removeOperationListener (OnRemoteOperationListener listener
) {
273 synchronized (mBoundListeners
) {
274 mBoundListeners
.remove(listener
);
280 * TODO - IMPORTANT: update implementation when more operations are moved into the service
282 * @return 'True' when an operation that enforces the user to wait for completion is in process.
284 public boolean isPerformingBlockingOperation() {
285 return (!mPendingOperations
.isEmpty());
290 * Creates and adds to the queue a new operation, as described by operationIntent
292 * @param operationIntent Intent describing a new operation to queue and execute.
293 * @return Identifier of the operation created, or null if failed.
295 public long newOperation(Intent operationIntent
) {
296 RemoteOperation operation
= null
;
297 Target target
= null
;
299 if (!operationIntent
.hasExtra(EXTRA_ACCOUNT
) &&
300 !operationIntent
.hasExtra(EXTRA_SERVER_URL
)) {
301 Log_OC
.e(TAG
, "Not enough information provided in intent");
304 Account account
= operationIntent
.getParcelableExtra(EXTRA_ACCOUNT
);
305 String serverUrl
= operationIntent
.getStringExtra(EXTRA_SERVER_URL
);
306 String webDavPath
= operationIntent
.getStringExtra(EXTRA_WEBDAV_PATH
);
307 String webDavUrl
= serverUrl
+ webDavPath
;
308 String username
= operationIntent
.getStringExtra(EXTRA_USERNAME
);
309 String password
= operationIntent
.getStringExtra(EXTRA_PASSWORD
);
310 String authToken
= operationIntent
.getStringExtra(EXTRA_AUTH_TOKEN
);
311 boolean followRedirects
= operationIntent
.getBooleanExtra(EXTRA_FOLLOW_REDIRECTS
, true
);
312 String cookie
= operationIntent
.getStringExtra(EXTRA_COOKIE
);
315 (serverUrl
== null
) ? null
: Uri
.parse(serverUrl
),
316 ((webDavPath
== null
) || (serverUrl
== null
)) ? null
: webDavUrl
,
324 String action
= operationIntent
.getAction();
325 if (action
.equals(ACTION_CREATE_SHARE
)) { // Create Share
326 String remotePath
= operationIntent
.getStringExtra(EXTRA_REMOTE_PATH
);
327 Intent sendIntent
= operationIntent
.getParcelableExtra(EXTRA_SEND_INTENT
);
328 if (remotePath
.length() > 0) {
329 operation
= new CreateShareOperation(remotePath
, ShareType
.PUBLIC_LINK
,
330 "", false
, "", 1, sendIntent
);
333 } else if (action
.equals(ACTION_UNSHARE
)) { // Unshare file
334 String remotePath
= operationIntent
.getStringExtra(EXTRA_REMOTE_PATH
);
335 if (remotePath
.length() > 0) {
336 operation
= new UnshareLinkOperation(
338 OperationsService
.this);
341 } else if (action
.equals(ACTION_GET_SERVER_INFO
)) {
342 // check OC server and get basic information from it
343 String authTokenType
=
344 operationIntent
.getStringExtra(EXTRA_AUTH_TOKEN_TYPE
);
345 operation
= new GetServerInfoOperation(
346 serverUrl
, authTokenType
, OperationsService
.this);
348 } else if (action
.equals(ACTION_OAUTH2_GET_ACCESS_TOKEN
)) {
349 /// GET ACCESS TOKEN to the OAuth server
350 String oauth2QueryParameters
=
351 operationIntent
.getStringExtra(EXTRA_OAUTH2_QUERY_PARAMETERS
);
352 operation
= new OAuth2GetAccessToken(
353 getString(R
.string
.oauth2_client_id
),
354 getString(R
.string
.oauth2_redirect_uri
),
355 getString(R
.string
.oauth2_grant_type
),
356 oauth2QueryParameters
);
358 } else if (action
.equals(ACTION_EXISTENCE_CHECK
)) {
360 String remotePath
= operationIntent
.getStringExtra(EXTRA_REMOTE_PATH
);
361 boolean successIfAbsent
= operationIntent
.getBooleanExtra(EXTRA_SUCCESS_IF_ABSENT
, true
);
362 operation
= new ExistenceCheckRemoteOperation(remotePath
, OperationsService
.this, successIfAbsent
);
364 } else if (action
.equals(ACTION_GET_USER_NAME
)) {
366 operation
= new GetRemoteUserNameOperation();
368 } else if (action
.equals(ACTION_RENAME
)) {
369 // Rename file or folder
370 String remotePath
= operationIntent
.getStringExtra(EXTRA_REMOTE_PATH
);
371 String newName
= operationIntent
.getStringExtra(EXTRA_NEWNAME
);
372 operation
= new RenameFileOperation(remotePath
, account
, newName
);
374 } else if (action
.equals(ACTION_REMOVE
)) {
375 // Remove file or folder
376 String remotePath
= operationIntent
.getStringExtra(EXTRA_REMOTE_PATH
);
377 boolean onlyLocalCopy
= operationIntent
.getBooleanExtra(EXTRA_REMOVE_ONLY_LOCAL
, false
);
378 operation
= new RemoveFileOperation(remotePath
, onlyLocalCopy
);
380 } else if (action
.equals(ACTION_CREATE_FOLDER
)) {
382 String remotePath
= operationIntent
.getStringExtra(EXTRA_REMOTE_PATH
);
383 boolean createFullPath
= operationIntent
.getBooleanExtra(EXTRA_CREATE_FULL_PATH
, true
);
384 operation
= new CreateFolderOperation(remotePath
, createFullPath
);
386 } else if (action
.equals(ACTION_SYNC_FILE
)) {
388 String remotePath
= operationIntent
.getStringExtra(EXTRA_REMOTE_PATH
);
389 boolean syncFileContents
= operationIntent
.getBooleanExtra(EXTRA_SYNC_FILE_CONTENTS
, true
);
390 operation
= new SynchronizeFileOperation(remotePath
, account
, syncFileContents
, getApplicationContext());
395 } catch (IllegalArgumentException e
) {
396 Log_OC
.e(TAG
, "Bad information provided in intent: " + e
.getMessage());
400 if (operation
!= null
) {
401 mPendingOperations
.add(new Pair
<Target
, RemoteOperation
>(target
, operation
));
402 startService(new Intent(OperationsService
.this, OperationsService
.class));
403 //Log_OC.wtf(TAG, "New operation added, opId: " + operation.hashCode());
404 // better id than hash? ; should be good enough by the time being
405 return operation
.hashCode();
408 //Log_OC.wtf(TAG, "New operation failed, returned Long.MAX_VALUE");
409 return Long
.MAX_VALUE
;
413 public boolean dispatchResultIfFinished(int operationId
, OnRemoteOperationListener listener
) {
414 Pair
<RemoteOperation
, RemoteOperationResult
> undispatched
=
415 mUndispatchedFinishedOperations
.remove(operationId
);
416 if (undispatched
!= null
) {
417 listener
.onRemoteOperationFinish(undispatched
.first
, undispatched
.second
);
419 //Log_OC.wtf(TAG, "Sending callback later");
421 if (!mPendingOperations
.isEmpty()) {
426 //Log_OC.wtf(TAG, "Not finished yet");
434 * Operations worker. Performs the pending operations in the order they were requested.
436 * Created with the Looper of a new thread, started in {@link OperationsService#onCreate()}.
438 private static class ServiceHandler
extends Handler
{
439 // don't make it a final class, and don't remove the static ; lint will warn about a possible memory leak
440 OperationsService mService
;
441 public ServiceHandler(Looper looper
, OperationsService service
) {
443 if (service
== null
) {
444 throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
450 public void handleMessage(Message msg
) {
451 mService
.nextOperation();
452 mService
.stopSelf(msg
.arg1
);
458 * Performs the next operation in the queue
460 private void nextOperation() {
462 //Log_OC.wtf(TAG, "nextOperation init" );
464 Pair
<Target
, RemoteOperation
> next
= null
;
465 synchronized(mPendingOperations
) {
466 next
= mPendingOperations
.peek();
471 mCurrentOperation
= next
.second
;
472 RemoteOperationResult result
= null
;
474 /// prepare client object to send the request to the ownCloud server
475 if (mLastTarget
== null
|| !mLastTarget
.equals(next
.first
)) {
476 mLastTarget
= next
.first
;
477 if (mLastTarget
.mAccount
!= null
) {
478 mOwnCloudClient
= ((MainApp
)getApplicationContext()).
479 getOwnCloudClientManager().getClientFor(
480 mLastTarget
.mAccount
,
483 new FileDataStorageManager(
484 mLastTarget
.mAccount
,
485 getContentResolver());
487 OwnCloudCredentials credentials
= null
;
488 if (mLastTarget
.mUsername
!= null
) {
489 credentials
= OwnCloudCredentialsFactory
.newBasicCredentials(
490 mLastTarget
.mUsername
,
491 mLastTarget
.mPassword
); // basic
493 } else if (mLastTarget
.mAuthToken
!= null
) {
494 credentials
= OwnCloudCredentialsFactory
.newBearerCredentials(
495 mLastTarget
.mAuthToken
); // bearer token
497 } else if (mLastTarget
.mCookie
!= null
) {
498 credentials
= OwnCloudCredentialsFactory
.newSamlSsoCredentials(
499 mLastTarget
.mCookie
); // SAML SSO
502 mOwnCloudClient
= ((MainApp
)getApplicationContext()).
503 getOwnCloudClientManager().getClientFor(
504 mLastTarget
.mServerUrl
,
505 credentials
, // still can be null, and that is right
508 if (mLastTarget
.mWebDavUrl
!= null
) {
509 mOwnCloudClient
.setWebdavUri(Uri
.parse(mLastTarget
.mWebDavUrl
));
511 mOwnCloudClient
.setFollowRedirects(mLastTarget
.mFollowRedirects
);
512 mStorageManager
= null
;
516 /// perform the operation
517 if (mCurrentOperation
instanceof SyncOperation
) {
518 result
= ((SyncOperation
)mCurrentOperation
).execute(mOwnCloudClient
, mStorageManager
);
520 result
= mCurrentOperation
.execute(mOwnCloudClient
);
523 } catch (AccountsException e
) {
524 if (mLastTarget
.mAccount
== null
) {
525 Log_OC
.e(TAG
, "Error while trying to get authorization for a NULL account", e
);
527 Log_OC
.e(TAG
, "Error while trying to get authorization for " + mLastTarget
.mAccount
.name
, e
);
529 result
= new RemoteOperationResult(e
);
531 } catch (IOException e
) {
532 if (mLastTarget
.mAccount
== null
) {
533 Log_OC
.e(TAG
, "Error while trying to get authorization for a NULL account", e
);
535 Log_OC
.e(TAG
, "Error while trying to get authorization for " + mLastTarget
.mAccount
.name
, e
);
537 result
= new RemoteOperationResult(e
);
538 } catch (Exception e
) {
539 if (mLastTarget
.mAccount
== null
) {
540 Log_OC
.e(TAG
, "Unexpected error for a NULL account", e
);
542 Log_OC
.e(TAG
, "Unexpected error for " + mLastTarget
.mAccount
.name
, e
);
544 result
= new RemoteOperationResult(e
);
547 synchronized(mPendingOperations
) {
548 mPendingOperations
.poll();
552 //sendBroadcastOperationFinished(mLastTarget, mCurrentOperation, result);
553 dispatchResultToOperationListeners(mLastTarget
, mCurrentOperation
, result
);
559 * Sends a broadcast when a new operation is added to the queue.
561 * Local broadcasts are only delivered to activities in the same process, but can't be done sticky :\
563 * @param target Account or URL pointing to an OC server.
564 * @param operation Added operation.
566 private void sendBroadcastNewOperation(Target target
, RemoteOperation operation
) {
567 Intent intent
= new Intent(ACTION_OPERATION_ADDED
);
568 if (target
.mAccount
!= null
) {
569 intent
.putExtra(EXTRA_ACCOUNT
, target
.mAccount
);
571 intent
.putExtra(EXTRA_SERVER_URL
, target
.mServerUrl
);
573 //LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
574 //lbm.sendBroadcast(intent);
575 sendStickyBroadcast(intent
);
579 // TODO - maybe add a notification for real start of operations
582 * Sends a LOCAL broadcast when an operations finishes in order to the interested activities can update their view
584 * Local broadcasts are only delivered to activities in the same process.
586 * @param target Account or URL pointing to an OC server.
587 * @param operation Finished operation.
588 * @param result Result of the operation.
590 private void sendBroadcastOperationFinished(Target target
, RemoteOperation operation
, RemoteOperationResult result
) {
591 Intent intent
= new Intent(ACTION_OPERATION_FINISHED
);
592 intent
.putExtra(EXTRA_RESULT
, result
);
593 if (target
.mAccount
!= null
) {
594 intent
.putExtra(EXTRA_ACCOUNT
, target
.mAccount
);
596 intent
.putExtra(EXTRA_SERVER_URL
, target
.mServerUrl
);
598 //LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
599 //lbm.sendBroadcast(intent);
600 sendStickyBroadcast(intent
);
605 * Notifies the currently subscribed listeners about the end of an operation.
607 * @param target Account or URL pointing to an OC server.
608 * @param operation Finished operation.
609 * @param result Result of the operation.
611 private void dispatchResultToOperationListeners(
612 Target target
, final RemoteOperation operation
, final RemoteOperationResult result
) {
614 Iterator
<OnRemoteOperationListener
> listeners
= mBinder
.mBoundListeners
.keySet().iterator();
615 while (listeners
.hasNext()) {
616 final OnRemoteOperationListener listener
= listeners
.next();
617 final Handler handler
= mBinder
.mBoundListeners
.get(listener
);
618 if (handler
!= null
) {
619 handler
.post(new Runnable() {
622 listener
.onRemoteOperationFinish(operation
, result
);
629 //mOperationResults.put(operation.hashCode(), result);
630 Pair
<RemoteOperation
, RemoteOperationResult
> undispatched
=
631 new Pair
<RemoteOperation
, RemoteOperationResult
>(operation
, result
);
632 mUndispatchedFinishedOperations
.put(operation
.hashCode(), undispatched
);
634 Log_OC
.d(TAG
, "Called " + count
+ " listeners");