• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Gallery2


Commit MetaInfo

修订版515cfec73e24176768aa9e5bbf9b3f5f205fad7b (tree)
时间2010-01-26 04:55:57
作者Venkat Krishnaraj <venkatkrishnaraj@venk...>
CommiterChih-Chung Chang

Log Message

Fix for checking to see if an account has picasa enabled before setting it explicitly to on by default

更改概述

差异

--- a/src/com/cooliris/picasa/PicasaSyncAdapter.java
+++ b/src/com/cooliris/picasa/PicasaSyncAdapter.java
@@ -1,6 +1,11 @@
11 package com.cooliris.picasa;
22
3+import java.io.IOException;
4+
35 import android.accounts.Account;
6+import android.accounts.AccountManager;
7+import android.accounts.AuthenticatorException;
8+import android.accounts.OperationCanceledException;
49 import android.content.AbstractThreadedSyncAdapter;
510 import android.content.BroadcastReceiver;
611 import android.content.ContentProviderClient;
@@ -23,8 +28,30 @@ public class PicasaSyncAdapter extends AbstractThreadedSyncAdapter {
2328 public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient providerClient,
2429 SyncResult syncResult) {
2530 if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false)) {
26- ContentResolver.setIsSyncable(account, authority, 1);
27- ContentResolver.setSyncAutomatically(account, authority, true);
31+ try {
32+ Account[] picasaAccounts = AccountManager.get(getContext())
33+ .getAccountsByTypeAndFeatures(
34+ PicasaService.ACCOUNT_TYPE,
35+ new String[] { PicasaService.FEATURE_SERVICE_NAME },
36+ null /* callback */, null /* handler */).getResult();
37+ boolean isPicasaAccount = false;
38+ for (Account picasaAccount : picasaAccounts) {
39+ if (account.equals(picasaAccount)) {
40+ isPicasaAccount = true;
41+ break;
42+ }
43+ }
44+ if (isPicasaAccount) {
45+ ContentResolver.setIsSyncable(account, authority, 1);
46+ ContentResolver.setSyncAutomatically(account, authority, true);
47+ }
48+ } catch (OperationCanceledException e) {
49+ ;
50+ } catch (IOException e) {
51+ ;
52+ } catch (AuthenticatorException e) {
53+ ;
54+ }
2855 return;
2956 }
3057 PicasaService.performSync(mContext, account, extras, syncResult);