RefreshFolderOperation.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /*
  2. * ownCloud Android client application
  3. *
  4. * @author David A. Velasco
  5. * Copyright (C) 2015 ownCloud Inc.
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2,
  9. * as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.owncloud.android.operations;
  20. import android.accounts.Account;
  21. import android.content.Context;
  22. import android.content.Intent;
  23. import android.util.Log;
  24. import com.owncloud.android.datamodel.DecryptedFolderMetadata;
  25. import com.owncloud.android.datamodel.FileDataStorageManager;
  26. import com.owncloud.android.datamodel.OCFile;
  27. import com.owncloud.android.lib.common.OwnCloudClient;
  28. import com.owncloud.android.lib.common.operations.RemoteOperation;
  29. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  30. import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
  31. import com.owncloud.android.lib.common.utils.Log_OC;
  32. import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
  33. import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
  34. import com.owncloud.android.lib.resources.files.model.RemoteFile;
  35. import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
  36. import com.owncloud.android.lib.resources.shares.OCShare;
  37. import com.owncloud.android.lib.resources.shares.ShareType;
  38. import com.owncloud.android.syncadapter.FileSyncAdapter;
  39. import com.owncloud.android.utils.DataHolderUtil;
  40. import com.owncloud.android.utils.EncryptionUtils;
  41. import com.owncloud.android.utils.FileStorageUtils;
  42. import com.owncloud.android.utils.MimeTypeUtil;
  43. import java.util.ArrayList;
  44. import java.util.HashMap;
  45. import java.util.List;
  46. import java.util.Map;
  47. import java.util.Vector;
  48. import androidx.annotation.NonNull;
  49. import androidx.annotation.Nullable;
  50. /**
  51. * Remote operation performing the synchronization of the list of files contained
  52. * in a folder identified with its remote path.
  53. *
  54. * Fetches the list and properties of the files contained in the given folder, including their
  55. * properties, and updates the local database with them.
  56. *
  57. * Does NOT enter in the child folders to synchronize their contents also.
  58. */
  59. @SuppressWarnings("PMD.AvoidDuplicateLiterals")
  60. public class RefreshFolderOperation extends RemoteOperation {
  61. private static final String TAG = RefreshFolderOperation.class.getSimpleName();
  62. public static final String EVENT_SINGLE_FOLDER_CONTENTS_SYNCED =
  63. RefreshFolderOperation.class.getName() + ".EVENT_SINGLE_FOLDER_CONTENTS_SYNCED";
  64. public static final String EVENT_SINGLE_FOLDER_SHARES_SYNCED =
  65. RefreshFolderOperation.class.getName() + ".EVENT_SINGLE_FOLDER_SHARES_SYNCED";
  66. /** Time stamp for the synchronization process in progress */
  67. private long mCurrentSyncTime;
  68. /** Remote folder to synchronize */
  69. private OCFile mLocalFolder;
  70. /** Access to the local database */
  71. private FileDataStorageManager mStorageManager;
  72. /** Account where the file to synchronize belongs */
  73. private Account mAccount;
  74. /** Android context; necessary to send requests to the download service */
  75. private Context mContext;
  76. /** Files and folders contained in the synchronized folder after a successful operation */
  77. private List<OCFile> mChildren;
  78. /** Counter of conflicts found between local and remote files */
  79. private int mConflictsFound;
  80. /** Counter of failed operations in synchronization of kept-in-sync files */
  81. private int mFailsInKeptInSyncFound;
  82. /**
  83. * Map of remote and local paths to files that where locally stored in a location
  84. * out of the ownCloud folder and couldn't be copied automatically into it
  85. **/
  86. private Map<String, String> mForgottenLocalFiles;
  87. /**
  88. * 'True' means that this operation is part of a full account synchronization
  89. */
  90. private boolean mSyncFullAccount;
  91. /** 'True' means that the remote folder changed and should be fetched */
  92. private boolean mRemoteFolderChanged;
  93. /** 'True' means that Etag will be ignored */
  94. private boolean mIgnoreETag;
  95. private List<SynchronizeFileOperation> mFilesToSyncContents;
  96. // this will be used for every file when 'folder synchronization' replaces 'folder download'
  97. /**
  98. * Creates a new instance of {@link RefreshFolderOperation}.
  99. *
  100. * @param folder Folder to synchronize.
  101. * @param currentSyncTime Time stamp for the synchronization process in progress.
  102. * @param syncFullAccount 'True' means that this operation is part of a full account
  103. * synchronization.
  104. * @param ignoreETag 'True' means that the content of the remote folder should
  105. * be fetched and updated even though the 'eTag' did not
  106. * change.
  107. * @param dataStorageManager Interface with the local database.
  108. * @param account ownCloud account where the folder is located.
  109. * @param context Application context.
  110. */
  111. public RefreshFolderOperation(OCFile folder,
  112. long currentSyncTime,
  113. boolean syncFullAccount,
  114. boolean ignoreETag,
  115. FileDataStorageManager dataStorageManager,
  116. Account account,
  117. Context context) {
  118. mLocalFolder = folder;
  119. mCurrentSyncTime = currentSyncTime;
  120. mSyncFullAccount = syncFullAccount;
  121. mStorageManager = dataStorageManager;
  122. mAccount = account;
  123. mContext = context;
  124. mForgottenLocalFiles = new HashMap<>();
  125. mRemoteFolderChanged = false;
  126. mIgnoreETag = ignoreETag;
  127. mFilesToSyncContents = new Vector<>();
  128. }
  129. public int getConflictsFound() {
  130. return mConflictsFound;
  131. }
  132. public int getFailsInKeptInSyncFound() {
  133. return mFailsInKeptInSyncFound;
  134. }
  135. public Map<String, String> getForgottenLocalFiles() {
  136. return mForgottenLocalFiles;
  137. }
  138. /**
  139. * Returns the list of files and folders contained in the synchronized folder,
  140. * if called after synchronization is complete.
  141. *
  142. * @return List of files and folders contained in the synchronized folder.
  143. */
  144. public List<OCFile> getChildren() {
  145. return mChildren;
  146. }
  147. /**
  148. * Performs the synchronization.
  149. *
  150. * {@inheritDoc}
  151. */
  152. @Override
  153. protected RemoteOperationResult run(OwnCloudClient client) {
  154. RemoteOperationResult result;
  155. mFailsInKeptInSyncFound = 0;
  156. mConflictsFound = 0;
  157. mForgottenLocalFiles.clear();
  158. if (OCFile.ROOT_PATH.equals(mLocalFolder.getRemotePath()) && !mSyncFullAccount) {
  159. updateOCVersion(client);
  160. updateUserProfile();
  161. }
  162. result = checkForChanges(client);
  163. if (result.isSuccess()) {
  164. if (mRemoteFolderChanged) {
  165. result = fetchAndSyncRemoteFolder(client);
  166. } else {
  167. mChildren = mStorageManager.getFolderContent(mLocalFolder, false);
  168. }
  169. if (result.isSuccess()) {
  170. // request for the synchronization of KEPT-IN-SYNC file contents
  171. startContentSynchronizations(mFilesToSyncContents);
  172. }
  173. mLocalFolder.setLastSyncDateForData(System.currentTimeMillis());
  174. mStorageManager.saveFile(mLocalFolder);
  175. }
  176. if (!mSyncFullAccount) {
  177. sendLocalBroadcast(
  178. EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result
  179. );
  180. }
  181. if (result.isSuccess() && !mSyncFullAccount) {
  182. refreshSharesForFolder(client); // share result is ignored
  183. }
  184. if (!mSyncFullAccount) {
  185. sendLocalBroadcast(
  186. EVENT_SINGLE_FOLDER_SHARES_SYNCED, mLocalFolder.getRemotePath(), result
  187. );
  188. }
  189. return result;
  190. }
  191. private void updateOCVersion(OwnCloudClient client) {
  192. UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext);
  193. RemoteOperationResult result = update.execute(client);
  194. if (result.isSuccess()) {
  195. // Update Capabilities for this account
  196. updateCapabilities();
  197. }
  198. }
  199. private void updateUserProfile() {
  200. GetUserProfileOperation update = new GetUserProfileOperation();
  201. RemoteOperationResult result = update.execute(mStorageManager, mContext);
  202. if (!result.isSuccess()) {
  203. Log_OC.w(TAG, "Couldn't update user profile from server");
  204. } else {
  205. Log_OC.i(TAG, "Got display name: " + result.getData().get(0));
  206. }
  207. }
  208. private void updateCapabilities() {
  209. GetCapabilitiesOperation getCapabilities = new GetCapabilitiesOperation();
  210. RemoteOperationResult result = getCapabilities.execute(mStorageManager, mContext);
  211. if (!result.isSuccess()) {
  212. Log_OC.w(TAG, "Update Capabilities unsuccessfully");
  213. }
  214. }
  215. private RemoteOperationResult checkForChanges(OwnCloudClient client) {
  216. mRemoteFolderChanged = true;
  217. RemoteOperationResult result;
  218. String remotePath = mLocalFolder.getRemotePath();
  219. Log_OC.d(TAG, "Checking changes in " + mAccount.name + remotePath);
  220. // remote request
  221. result = new ReadFileRemoteOperation(remotePath).execute(client, true);
  222. if (result.isSuccess()) {
  223. OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
  224. if (!mIgnoreETag) {
  225. // check if remote and local folder are different
  226. String remoteFolderETag = remoteFolder.getEtag();
  227. if (remoteFolderETag != null) {
  228. mRemoteFolderChanged =
  229. !(remoteFolderETag.equalsIgnoreCase(mLocalFolder.getEtag()));
  230. } else {
  231. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  232. "No ETag received from server");
  233. }
  234. }
  235. result = new RemoteOperationResult(ResultCode.OK);
  236. Log_OC.i(TAG, "Checked " + mAccount.name + remotePath + " : " +
  237. (mRemoteFolderChanged ? "changed" : "not changed"));
  238. } else {
  239. // check failed
  240. if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
  241. removeLocalFolder();
  242. }
  243. if (result.isException()) {
  244. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  245. result.getLogMessage(), result.getException());
  246. } else {
  247. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  248. result.getLogMessage());
  249. }
  250. }
  251. return result;
  252. }
  253. private RemoteOperationResult fetchAndSyncRemoteFolder(OwnCloudClient client) {
  254. String remotePath = mLocalFolder.getRemotePath();
  255. RemoteOperationResult result = new ReadFolderRemoteOperation(remotePath).execute(client, true);
  256. Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
  257. if (result.isSuccess()) {
  258. synchronizeData(result.getData());
  259. if (mConflictsFound > 0 || mFailsInKeptInSyncFound > 0) {
  260. result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
  261. // should be a different result code, but will do the job
  262. }
  263. } else {
  264. if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
  265. removeLocalFolder();
  266. }
  267. }
  268. return result;
  269. }
  270. private void removeLocalFolder() {
  271. if (mStorageManager.fileExists(mLocalFolder.getFileId())) {
  272. String currentSavePath = FileStorageUtils.getSavePath(mAccount.name);
  273. mStorageManager.removeFolder(
  274. mLocalFolder,
  275. true,
  276. mLocalFolder.isDown() && mLocalFolder.getStoragePath().startsWith(currentSavePath)
  277. );
  278. }
  279. }
  280. /**
  281. * Synchronizes the data retrieved from the server about the contents of the target folder
  282. * with the current data in the local database.
  283. *
  284. * Grants that mChildren is updated with fresh data after execution.
  285. *
  286. * @param folderAndFiles Remote folder and children files in Folder
  287. */
  288. private void synchronizeData(List<Object> folderAndFiles) {
  289. // get 'fresh data' from the database
  290. mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
  291. // parse data from remote folder
  292. OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) folderAndFiles.get(0));
  293. remoteFolder.setParentId(mLocalFolder.getParentId());
  294. remoteFolder.setFileId(mLocalFolder.getFileId());
  295. Log_OC.d(TAG, "Remote folder " + mLocalFolder.getRemotePath() + " changed - starting update of local data ");
  296. List<OCFile> updatedFiles = new ArrayList<>(folderAndFiles.size() - 1);
  297. mFilesToSyncContents.clear();
  298. // if local folder is encrypted, download fresh metadata
  299. boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, mStorageManager);
  300. mLocalFolder.setEncrypted(encryptedAncestor);
  301. // update permission
  302. mLocalFolder.setPermissions(remoteFolder.getPermissions());
  303. DecryptedFolderMetadata metadata = getDecryptedFolderMetadata(encryptedAncestor);
  304. // get current data about local contents of the folder to synchronize
  305. Map<String, OCFile> localFilesMap = prefillLocalFilesMap(metadata,
  306. mStorageManager.getFolderContent(mLocalFolder, false));
  307. // loop to update every child
  308. OCFile remoteFile;
  309. OCFile localFile;
  310. OCFile updatedFile;
  311. RemoteFile r;
  312. for (int i = 1; i < folderAndFiles.size(); i++) {
  313. /// new OCFile instance with the data from the server
  314. r = (RemoteFile) folderAndFiles.get(i);
  315. remoteFile = FileStorageUtils.fillOCFile(r);
  316. // new OCFile instance to merge fresh data from server with local state
  317. updatedFile = FileStorageUtils.fillOCFile(r);
  318. updatedFile.setParentId(mLocalFolder.getFileId());
  319. // retrieve local data for the read file
  320. localFile = localFilesMap.remove(remoteFile.getRemotePath());
  321. // add to updatedFile data about LOCAL STATE (not existing in server)
  322. updatedFile.setLastSyncDateForProperties(mCurrentSyncTime);
  323. // add to updatedFile data from local and remote file
  324. setLocalFileDataOnUpdatedFile(remoteFile, localFile, updatedFile, mRemoteFolderChanged);
  325. // check and fix, if needed, local storage path
  326. FileStorageUtils.searchForLocalFileInDefaultPath(updatedFile, mAccount);
  327. // update file name for encrypted files
  328. if (metadata != null) {
  329. updateFileNameForEncryptedFile(metadata, updatedFile);
  330. }
  331. // we parse content, so either the folder itself or its direct parent (which we check) must be encrypted
  332. boolean encrypted = updatedFile.isEncrypted() || mLocalFolder.isEncrypted();
  333. updatedFile.setEncrypted(encrypted);
  334. updatedFiles.add(updatedFile);
  335. }
  336. // save updated contents in local database
  337. mStorageManager.saveFolder(remoteFolder, updatedFiles, localFilesMap.values());
  338. mChildren = updatedFiles;
  339. }
  340. @Nullable
  341. private DecryptedFolderMetadata getDecryptedFolderMetadata(boolean encryptedAncestor) {
  342. DecryptedFolderMetadata metadata;
  343. if (encryptedAncestor && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
  344. metadata = EncryptionUtils.downloadFolderMetadata(mLocalFolder, getClient(), mContext, mAccount);
  345. } else {
  346. metadata = null;
  347. }
  348. return metadata;
  349. }
  350. private void updateFileNameForEncryptedFile(@NonNull DecryptedFolderMetadata metadata, OCFile updatedFile) {
  351. updatedFile.setEncryptedFileName(updatedFile.getFileName());
  352. try {
  353. String decryptedFileName = metadata.getFiles().get(updatedFile.getFileName()).getEncrypted()
  354. .getFilename();
  355. String mimetype = metadata.getFiles().get(updatedFile.getFileName()).getEncrypted().getMimetype();
  356. updatedFile.setFileName(decryptedFileName);
  357. if (mimetype == null || mimetype.isEmpty()) {
  358. updatedFile.setMimeType("application/octet-stream");
  359. } else {
  360. updatedFile.setMimeType(mimetype);
  361. }
  362. } catch (NullPointerException e) {
  363. Log_OC.e(TAG, "Metadata for file " + updatedFile.getFileId() + " not found!");
  364. }
  365. }
  366. private void setLocalFileDataOnUpdatedFile(OCFile remoteFile, OCFile localFile, OCFile updatedFile, boolean remoteFolderChanged) {
  367. if (localFile != null) {
  368. updatedFile.setFileId(localFile.getFileId());
  369. updatedFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
  370. updatedFile.setModificationTimestampAtLastSyncForData(
  371. localFile.getModificationTimestampAtLastSyncForData()
  372. );
  373. updatedFile.setStoragePath(localFile.getStoragePath());
  374. // eTag will not be updated unless file CONTENTS are synchronized
  375. if (!updatedFile.isFolder() && localFile.isDown() &&
  376. !updatedFile.getEtag().equals(localFile.getEtag())) {
  377. updatedFile.setEtagInConflict(updatedFile.getEtag());
  378. }
  379. updatedFile.setEtag(localFile.getEtag());
  380. if (updatedFile.isFolder()) {
  381. updatedFile.setFileLength(remoteFile.getFileLength());
  382. updatedFile.setMountType(remoteFile.getMountType());
  383. } else if (remoteFolderChanged && MimeTypeUtil.isImage(remoteFile) &&
  384. remoteFile.getModificationTimestamp() !=
  385. localFile.getModificationTimestamp()) {
  386. updatedFile.setUpdateThumbnailNeeded(true);
  387. Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
  388. }
  389. updatedFile.setPublicLink(localFile.getPublicLink());
  390. updatedFile.setSharedViaLink(localFile.isSharedViaLink());
  391. updatedFile.setSharedWithSharee(localFile.isSharedWithSharee());
  392. } else {
  393. // remote eTag will not be updated unless file CONTENTS are synchronized
  394. updatedFile.setEtag("");
  395. }
  396. // eTag on Server is used for thumbnail validation
  397. updatedFile.setEtagOnServer(remoteFile.getEtag());
  398. }
  399. @NonNull
  400. private Map<String, OCFile> prefillLocalFilesMap(DecryptedFolderMetadata metadata, List<OCFile> localFiles) {
  401. Map<String, OCFile> localFilesMap = new HashMap<>(localFiles.size());
  402. for (OCFile file : localFiles) {
  403. String remotePath = file.getRemotePath();
  404. if (metadata != null && !file.isFolder()) {
  405. remotePath = file.getParentRemotePath() + file.getEncryptedFileName();
  406. }
  407. localFilesMap.put(remotePath, file);
  408. }
  409. return localFilesMap;
  410. }
  411. /**
  412. * Performs a list of synchronization operations, determining if a download or upload is needed
  413. * or if exists conflict due to changes both in local and remote contents of the each file.
  414. *
  415. * If download or upload is needed, request the operation to the corresponding service and goes
  416. * on.
  417. *
  418. * @param filesToSyncContents Synchronization operations to execute.
  419. */
  420. private void startContentSynchronizations(List<SynchronizeFileOperation> filesToSyncContents) {
  421. RemoteOperationResult contentsResult;
  422. for (SynchronizeFileOperation op : filesToSyncContents) {
  423. contentsResult = op.execute(mStorageManager, mContext); // async
  424. if (!contentsResult.isSuccess()) {
  425. if (contentsResult.getCode() == ResultCode.SYNC_CONFLICT) {
  426. mConflictsFound++;
  427. } else {
  428. mFailsInKeptInSyncFound++;
  429. if (contentsResult.getException() != null) {
  430. Log_OC.e(TAG, "Error while synchronizing favourites : "
  431. + contentsResult.getLogMessage(), contentsResult.getException());
  432. } else {
  433. Log_OC.e(TAG, "Error while synchronizing favourites : "
  434. + contentsResult.getLogMessage());
  435. }
  436. }
  437. } // won't let these fails break the synchronization process
  438. }
  439. }
  440. /**
  441. * Syncs the Share resources for the files contained in the folder refreshed (children, not deeper descendants).
  442. *
  443. * @param client Handler of a session with an OC server.
  444. * @return The result of the remote operation retrieving the Share resources in the folder refreshed by
  445. * the operation.
  446. */
  447. private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
  448. RemoteOperationResult result;
  449. // remote request
  450. GetRemoteSharesForFileOperation operation =
  451. new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), true, true);
  452. result = operation.execute(client);
  453. if (result.isSuccess()) {
  454. // update local database
  455. ArrayList<OCShare> shares = new ArrayList<>();
  456. OCShare share;
  457. for (Object obj : result.getData()) {
  458. share = (OCShare) obj;
  459. if (!ShareType.NO_SHARED.equals(share.getShareType())) {
  460. shares.add(share);
  461. }
  462. }
  463. mStorageManager.saveSharesInFolder(shares, mLocalFolder);
  464. }
  465. return result;
  466. }
  467. /**
  468. * Sends a message to any application component interested in the progress
  469. * of the synchronization.
  470. *
  471. * @param event broadcast event (Intent Action)
  472. * @param dirRemotePath Remote path of a folder that was just synchronized
  473. * (with or without success)
  474. * @param result remote operation result
  475. */
  476. private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) {
  477. Log_OC.d(TAG, "Send broadcast " + event);
  478. Intent intent = new Intent(event);
  479. intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, mAccount.name);
  480. if (dirRemotePath != null) {
  481. intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath);
  482. }
  483. DataHolderUtil dataHolderUtil = DataHolderUtil.getInstance();
  484. String dataHolderItemId = dataHolderUtil.nextItemId();
  485. dataHolderUtil.save(dataHolderItemId, result);
  486. intent.putExtra(FileSyncAdapter.EXTRA_RESULT, dataHolderItemId);
  487. intent.setPackage(mContext.getPackageName());
  488. mContext.sendStickyBroadcast(intent);
  489. }
  490. }