<uses-sdk
android:minSdkVersion="8"
- android:targetSdkVersion="13" />
+ android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
</uses-permission>
</service>
<service
android:name=".syncadapter.FileSyncService"
- android:exported="true" >
+ android:exported="true"
+ android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
# project structure.
# Project target.
-target=android-17
+target=android-19
android.library.reference.1=actionbarsherlock/library
<resources>
<!-- App name and other strings-->
<string name="app_name">ownCloud</string>
- <string name="account_type">owncloud</string>
- <string name="authority">org.owncloud</string>
+ <string name="account_type">owncloud</string> <!-- better if was a domain name; but changing it now would require migrate accounts when the app is updated -->
+ <string name="authority">org.owncloud</string> <!-- better if was the app package with ".provider" appended ; it identifies the provider -->
<string name ="db_file">owncloud.db</string>
<string name ="db_name">ownCloud</string>
<string name ="data_folder">owncloud</string>
android:contentAuthority="@string/authority"
android:accountType="@string/account_type"
android:supportsUploading="true"
+ android:userVisible="true"
+ android:allowParallelSyncs="true"
+ android:isAlwaysSyncable="true"
/>
* Is used by android system to assign accounts to authenticators. Should be
* used by application and all extensions.
*/
- /* These constants are now in MainApp
- public static final String ACCOUNT_TYPE = "owncloud";
- public static final String AUTHORITY = "org.owncloud";
- public static final String AUTH_TOKEN_TYPE = "org.owncloud";
- public static final String AUTH_TOKEN_TYPE_PASSWORD = "owncloud.password";
- public static final String AUTH_TOKEN_TYPE_ACCESS_TOKEN = "owncloud.oauth2.access_token";
- public static final String AUTH_TOKEN_TYPE_REFRESH_TOKEN = "owncloud.oauth2.refresh_token";
- public static final String AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE = "owncloud.saml.web_sso.session_cookie";
- */
public static final String KEY_AUTH_TOKEN_TYPE = "authTokenType";
public static final String KEY_REQUIRED_FEATURES = "requiredFeatures";
public static final String KEY_LOGIN_OPTIONS = "loginOptions";
public class AccountAuthenticatorService extends Service {
private AccountAuthenticator mAuthenticator;
- //static final public String ACCOUNT_TYPE = "owncloud";
@Override
public void onCreate() {
if (id > FileDataStorageManager.ROOT_PARENT_ID) {
Log_OC.d(TAG, "Updating size of " + id);
if (getContentResolver() != null) {
- getContentResolver().update(ProviderTableMeta.CONTENT_URI_DIR, null,
+ getContentResolver().update(ProviderTableMeta.CONTENT_URI_DIR,
+ new ContentValues(), // won't be used, but cannot be null; crashes in KLP
ProviderTableMeta._ID + "=?",
new String[] { String.valueOf(id) });
} else {
try {
- getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_DIR, null,
- ProviderTableMeta._ID + "=?",
- new String[] { String.valueOf(id) });
+ getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_DIR,
+ new ContentValues(), // won't be used, but cannot be null; crashes in KLP
+ ProviderTableMeta._ID + "=?",
+ new String[] { String.valueOf(id) });
} catch (RemoteException e) {
Log_OC.e(TAG, "Exception in update of folder size through compatibility patch " + e.getMessage());
return (currentState == MediaService.State.PLAYING || currentState == MediaService.State.PAUSED);
}
+
+ @Override
+ public int getAudioSessionId() {
+ return 1; // not really used
+ }
+
}
\r
private AccountManager accountManager;\r
private Account account;\r
- private ContentProviderClient contentProvider;\r
+ private ContentProviderClient mContentProviderClient;\r
private FileDataStorageManager mStoreManager;\r
\r
private WebdavClient mClient = null;\r
this.setAccountManager(AccountManager.get(context));\r
}\r
\r
+ public AbstractOwnCloudSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {\r
+ super(context, autoInitialize, allowParallelSyncs);\r
+ this.setAccountManager(AccountManager.get(context));\r
+ }\r
+\r
public AccountManager getAccountManager() {\r
return accountManager;\r
}\r
this.account = account;\r
}\r
\r
- public ContentProviderClient getContentProvider() {\r
- return contentProvider;\r
+ public ContentProviderClient getContentProviderClient() {\r
+ return mContentProviderClient;\r
}\r
\r
- public void setContentProvider(ContentProviderClient contentProvider) {\r
- this.contentProvider = contentProvider;\r
+ public void setContentProviderClient(ContentProviderClient contentProvider) {\r
+ this.mContentProviderClient = contentProvider;\r
}\r
\r
public void setStorageManager(FileDataStorageManager storage_manager) {\r
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
setAccount(account);
- setContentProvider(provider);
+ setContentProviderClient(provider);
Cursor c = getLocalContacts(false);
if (c.moveToFirst()) {
do {
/**
- * Creates an {@link FileSyncAdapter}
+ * Creates a {@link FileSyncAdapter}
*
* {@inheritDoc}
*/
/**
+ * Creates a {@link FileSyncAdapter}
+ *
+ * {@inheritDoc}
+ */
+ public FileSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
+ super(context, autoInitialize, allowParallelSyncs);
+ }
+
+
+ /**
* {@inheritDoc}
*/
@Override
public synchronized void onPerformSync(Account account, Bundle extras,
- String authority, ContentProviderClient provider,
+ String authority, ContentProviderClient providerClient,
SyncResult syncResult) {
mCancellation = false;
mSyncResult.delayUntil = 60*60*24; // avoid too many automatic synchronizations
this.setAccount(account);
- this.setContentProvider(provider);
- this.setStorageManager(new FileDataStorageManager(account, provider));
+ this.setContentProviderClient(providerClient);
+ this.setStorageManager(new FileDataStorageManager(account, providerClient));
try {
this.initClientForCurrentAccount();
} catch (IOException e) {
*/\r
package com.owncloud.android.syncadapter;\r
\r
+import com.owncloud.android.Log_OC;\r
+\r
import android.app.Service;\r
import android.content.Intent;\r
import android.os.IBinder;\r
public static final String ACCOUNT_NAME = "ACCOUNT_NAME";\r
public static final String SYNC_RESULT = "SYNC_RESULT";\r
\r
+ // Storage for an instance of the sync adapter\r
+ private static FileSyncAdapter sSyncAdapter = null;\r
+ // Object to use as a thread-safe lock\r
+ private static final Object sSyncAdapterLock = new Object();\r
+ \r
public static String getSyncMessage(){\r
return FileSyncService.class.getName().toString() + SYNC_MESSAGE;\r
}\r
*/\r
@Override\r
public void onCreate() {\r
+ synchronized (sSyncAdapterLock) {\r
+ if (sSyncAdapter == null) {\r
+ sSyncAdapter = new FileSyncAdapter(getApplicationContext(), true);\r
+ }\r
+ }\r
}\r
\r
/*\r
*/\r
@Override\r
public IBinder onBind(Intent intent) {\r
- return new FileSyncAdapter(getApplicationContext(), true).getSyncAdapterBinder();\r
+ return sSyncAdapter.getSyncAdapterBinder();\r
}\r
\r
}\r
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.IntentFilter.AuthorityEntry;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
+import android.content.SyncRequest;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
import android.net.Uri;
}
private void startSynchronization() {
- ContentResolver.cancelSync(null, MainApp.getAuthTokenType()); // cancel the current synchronizations of any ownCloud account
- Bundle bundle = new Bundle();
- bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
- ContentResolver.requestSync(
- getAccount(),
- MainApp.getAuthTokenType(), bundle);
+ Log_OC.e(TAG, "Got to start sync");
+ if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
+ Log_OC.e(TAG, "Canceling all syncs for " + MainApp.getAuthority());
+ ContentResolver.cancelSync(null, MainApp.getAuthority()); // cancel the current synchronizations of any ownCloud account
+ Bundle bundle = new Bundle();
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
+ Log_OC.e(TAG, "Requesting sync for " + getAccount().name + " at " + MainApp.getAuthority());
+ ContentResolver.requestSync(
+ getAccount(),
+ MainApp.getAuthority(), bundle);
+ } else {
+ Log_OC.e(TAG, "Requesting sync for " + getAccount().name + " at " + MainApp.getAuthority() + " with new API");
+ SyncRequest.Builder builder = new SyncRequest.Builder();
+ builder.setSyncAdapter(getAccount(), MainApp.getAuthority());
+ builder.setExpedited(true);
+ builder.setManual(true);
+ builder.syncOnce();
+ SyncRequest request = builder.build();
+ ContentResolver.requestSync(request);
+ }
}