...
 
Commits (34)
......@@ -4,6 +4,8 @@ stages:
- build
before_script:
- git submodule sync
- git submodule update --init --recursive
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
......
[submodule "android-nc-lib"]
path = android-nc-lib
url = ../nextcloud-android-lib.git
......@@ -8,6 +8,7 @@
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/android-nc-lib" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
......
......@@ -5,6 +5,7 @@
<module fileurl="file://$PROJECT_DIR$/Drive.iml" filepath="$PROJECT_DIR$/Drive.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/eDrive.iml" filepath="$PROJECT_DIR$/eDrive.iml" />
<module fileurl="file://$PROJECT_DIR$/android-nc-lib/ncLib.iml" filepath="$PROJECT_DIR$/android-nc-lib/ncLib.iml" />
</modules>
</component>
</project>
\ No newline at end of file
......@@ -9,8 +9,7 @@
To disable All the synchronisation, go into your account and disable BOTH: "application settings" AND "Photos and videos"
#### Actu:
Fix account's deletion
Fix disabled sync in account's settings: I update DB, so it might cause issue after update. One solution in this case is to remove your account and add it again.
In Branch data_reduction: Added the Android-NC-Libray as a submodule and from repo on this Gitlab instance. This branch is a next node on eelo-0.2 branch.
Check the [wiki](https://gitlab.e.foundation/e/apps/eDrive/wikis/home) for more information
......@@ -18,7 +17,7 @@ Check the [wiki](https://gitlab.e.foundation/e/apps/eDrive/wikis/home) for more
This is the current pending goal List:
+ Handle lack of space localy
+ Issue # 0 : apps crash if request are too long and fails because of that
+ Issue # 0 : SSL socket timeout exception not handled
+ Add Unit test
+ ScheduleInitialization while it hasn't run completely or user hasn't disable both sync type.
......
Subproject commit b0ff4872a08bd5eab75708c8acf3518abe6fd374
buildscript {
/*repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}*/
}
import java.text.SimpleDateFormat;
apply plugin: 'com.android.application'
//apply plugin: 'io.fabric'
def versionMajor = 1
def buildTime() {
......@@ -23,8 +14,7 @@ android {
compileSdkVersion 26
defaultConfig {
applicationId "io.eelo.drive"
minSdkVersion 25
targetSdkVersion 26
minSdkVersion 26
versionCode 1
//versionName "1.0"
versionName "alpha-${versionMajor}-build-${buildTime()}"
......@@ -47,24 +37,16 @@ android {
unitTests.returnDefaultValues = true
}
}
repositories {
maven { url "https://jitpack.io" }
//maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
api 'com.github.nextcloud:android-library:1.1.0'
/*api('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
transitive = true;
}*/
api 'com.android.support:support-annotations:27.1.1'
implementation project(':ncLib')
}
......@@ -17,13 +17,16 @@ http://www.gnu.org/licenses/gpl.html
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <!-- needed for PersistedJob -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<permission android:name="android.permission.FORCE_STOP_PACKAGES"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signature"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_eelo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_eelo_round"
android:supportsRtl="true">
android:roundIcon="@mipmap/ic_eelo_round">
<provider
android:authorities="io.eelo.drive.providers.MediasSyncProvider"
android:name="io.eelo.drive.providers.MediasSyncProvider"
......@@ -40,10 +43,9 @@ http://www.gnu.org/licenses/gpl.html
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="drive.services.InitializerService" /> <!-- @TODO replace initializer by Initializer and ask Nihar to report the change to accountManager -->
<action android:name="drive.services.InitializerService" />
</intent-filter>
</service>
<service android:name=".services.ResetService"
android:enabled="true"
android:exported="true">
......@@ -54,10 +56,16 @@ http://www.gnu.org/licenses/gpl.html
<service android:name=".jobs.ScannerJob"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service android:name=".services.ObserverService"
android:enabled="true"
android:exported="true">
android:enabled="true">
</service>
<service android:name=".services.ObserverServiceV2"
android:enabled="true">
</service>
<service android:name=".services.OperationManagerService"/>
<receiver android:name=".receivers.BatteryStateReceiver" android:enabled="true">
<intent-filter>
......@@ -70,8 +78,5 @@ http://www.gnu.org/licenses/gpl.html
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<!--<meta-data
android:name="io.fabric.ApiKey"
android:value="63e8fd2ffc15b7b187bd369a9c0535e9fe151e8a" />-->
</application>
</manifest>
package io.eelo.drive.database;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
public abstract class AbstractDAO {
protected SQLiteDatabase mDB;
protected final DbHelper mHelper;
protected AbstractDAO(Context context){
this.mHelper = new DbHelper(context);
}
/**
* Open Database connexion
* @param writeMod Connexion mod. If set to true, database is open in writable mod, else it is opened in read mod.
* @throws SQLException SqlException
*/
protected void open(Boolean writeMod) throws SQLException {
mDB = (writeMod)? mHelper.getWritableDatabase() : mHelper.getReadableDatabase();
}
/**
* Close Database connexion
*/
protected void close() {
mHelper.close();
}
}
......@@ -16,6 +16,7 @@ import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import io.eelo.drive.models.OperationDone;
import io.eelo.drive.models.SyncedFolder;
import io.eelo.drive.models.SyncedFileState;
......@@ -29,7 +30,7 @@ import io.eelo.drive.models.SyncedFileState;
public final class DbHelper extends SQLiteOpenHelper {
final private static String TAG = DbHelper.class.getSimpleName(); //Tag for log
private static final int DATABASE_VERSION = 19; //20/09/2018
private static final int DATABASE_VERSION = 20; //20/09/2018
public static final String DATABASE_NAME = "eelo_drive.db";
/**
......@@ -47,6 +48,7 @@ public final class DbHelper extends SQLiteOpenHelper {
public void onCreate(SQLiteDatabase db) {
db.execSQL(SyncedFolderContract.SQL_CREATE_TABLE_SYNCEDFOLDER);
db.execSQL(SyncedFileStateContract.SQL_CREATE_TABLE_SYNCEDFILESTATE);
db.execSQL(OperationDoneContract.SQL_CREATE_TABLE_OPERATIONDONE);
}
/**
......
package io.eelo.drive.database;
import android.provider.BaseColumns;
public class OperationDoneContract implements BaseColumns {
/** Table structure **/
static final String TABLE_NAME ="operation_done";
static final String TARGET_PATH ="target_path";
static final String SOURCE_PATH ="source_path";
static final String OPERATION_CODE = "operation_code";
static final String RESULT_CODE = "result_code";
static final String IS_SUCCESS = "is_success";
static final String NEW_ETAG = "new_etag";
static final String SQL_CREATE_TABLE_OPERATIONDONE=
"CREATE TABLE "+TABLE_NAME+" ( "
+_ID+" INTEGER PRIMARY KEY, "
+TARGET_PATH+" TEXT, "
+SOURCE_PATH+" TEXT, "
+OPERATION_CODE+" INTEGER, "
+RESULT_CODE+" TEXT, "
+IS_SUCCESS+" INTEGER, "
+ NEW_ETAG +" TEXT, "
+"CONSTRAINT synced_unicity_constraint UNIQUE ("
+TARGET_PATH+", "
+SOURCE_PATH
+"))";
static final String SQL_DELETE_TABLE_OPERATIONDONE = " DROP TABLE IF EXISTS "
+ TABLE_NAME;
}
package io.eelo.drive.database;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import io.eelo.drive.models.OperationDone;
import static io.eelo.drive.database.OperationDoneContract.IS_SUCCESS;
import static io.eelo.drive.database.OperationDoneContract.NEW_ETAG;
import static io.eelo.drive.database.OperationDoneContract.OPERATION_CODE;
import static io.eelo.drive.database.OperationDoneContract.RESULT_CODE;
import static io.eelo.drive.database.OperationDoneContract.SOURCE_PATH;
import static io.eelo.drive.database.OperationDoneContract.TABLE_NAME;
import static io.eelo.drive.database.OperationDoneContract.TARGET_PATH;
public class OperationDoneDAO extends AbstractDAO {
final private static String TAG = OperationDoneDAO.class.getSimpleName();
private final String[] allColumns = {
OperationDoneContract._ID,
TARGET_PATH,
SOURCE_PATH,
OPERATION_CODE,
RESULT_CODE,
IS_SUCCESS,
NEW_ETAG
};
OperationDoneDAO(Context context){
super(context);
}
/**
* Remove all entry from DB
* @return
*/
public int clearTable(){
return mDB.delete(TABLE_NAME, "1", null);
}
/**
* Get list of OperationDone
* @param selection A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given table.
* @param args You may include ?s in selection, which will be replaced by the values from selectionArgs, in order that they appear in the selection. The values will be bound as Strings.
* @return List of all OperationDone
*/
List<OperationDone> getOperationDoneList(String selection, String[] args) {
List<OperationDone> result = new ArrayList<OperationDone>();
Cursor cursor = mDB.query(TABLE_NAME, allColumns, selection,args, null, null,
null);
cursor.moveToFirst();
while ( !cursor.isAfterLast() ) {
OperationDone operationDone = cursorToOperationDone(cursor);
if(operationDone != null ){
result.add(operationDone);
}
cursor.moveToNext();
}
cursor.close();
return result;
}
/**
* Insert new OperationDone
* @param operationDone element to register
* @return the row ID of the newly inserted row OR -1
*/
long insert(OperationDone operationDone){
return mDB.insertWithOnConflict(TABLE_NAME,
null,
toContentValues(operationDone),
SQLiteDatabase.CONFLICT_IGNORE);
}
/**
* Update a specific OperationDone
* @param operationDone OperationDone to update
* @return Number of row affected
*/
public int update(OperationDone operationDone){
int result = 0;
try{
result = mDB.update(TABLE_NAME,
toContentValues(operationDone),
OperationDoneContract._ID+" = "+ operationDone.getId(),
null);
}catch(Exception e){
Log.e(TAG, e.toString());
}
return result;
}
/**
* Convert a operationDone into a ContentValues object
* @param operationDone syncedFileState to convert
* @return a ContentValues object
*/
private ContentValues toContentValues(OperationDone operationDone){
ContentValues values = new ContentValues();
values.put( TARGET_PATH, operationDone.getTargetPath() );
values.put( SOURCE_PATH, operationDone.getSourcePath() );
values.put( OPERATION_CODE, operationDone.getOperationCode() );
values.put( RESULT_CODE, operationDone.getResultCode() );
values.put( IS_SUCCESS, operationDone.isSuccess() ? 1 : 0 );
values.put( NEW_ETAG, operationDone.getNewEtag() );
return values;
}
/**
* Create SyncedFileState from cursor
* @param cursor Cursor containing data to build SyncedFileState
* @return SyncedFileState instance
*/
private OperationDone cursorToOperationDone(Cursor cursor) {
OperationDone result = new OperationDone(
cursor.getString(1 ),//targetPath
cursor.getString(2 ),//sourcePath
cursor.getInt(3 ),//operationCode
cursor.getString(4 ),//resultCode
(cursor.getInt(5) == 1 ) //is success
);
result.setId( cursor.getInt(0)); //Id
result.setNewEtag(cursor.getString(6)); //Etag
return result;
}
}
......@@ -11,7 +11,6 @@ package io.eelo.drive.database;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
......@@ -34,11 +33,9 @@ import static io.eelo.drive.database.SyncedFileStateContract.SYNCEDFOLDER_ID;
* @author Vincent Bourgmayer
* Offers Query to CRUD operation for SyncedFIleState Object
*/
class SyncedFileStateDAO {
class SyncedFileStateDAO extends AbstractDAO {
final private static String TAG = SyncedFileStateDAO.class.getSimpleName(); //Tag for log
private SQLiteDatabase mDB;
private final DbHelper mHelper;
/*private final String[] allColumns = { SyncedFileStateContract._ID,
SyncedFileStateContract.FILE_NAME,
SyncedFileStateContract.LOCAL_PATH,
......@@ -51,23 +48,7 @@ class SyncedFileStateDAO {
};*/
SyncedFileStateDAO(Context context){
this.mHelper = new DbHelper(context);
}
/**
* Open Database connexion
* @param writeMod if true, open DB in write mod, else open it in read mod
* @throws SQLException throw an SQL Exception
*/
void open(Boolean writeMod ) throws SQLException {
this.mDB = ( writeMod ) ? mHelper.getWritableDatabase(): mHelper.getReadableDatabase();
}
/**
* Close DB connexion.
*/
void close() {
mHelper.close();
super(context);
}
/**
......@@ -137,6 +118,11 @@ class SyncedFileStateDAO {
return result;
}
/**
* Fetch many SyncedFileState by its localPath
* @param syncedFolderids List<String> of path to filter. Need to be directory path
......
......@@ -11,7 +11,6 @@ package io.eelo.drive.database;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import java.util.ArrayList;
......@@ -33,10 +32,9 @@ import static io.eelo.drive.database.SyncedFolderContract.TABLE_NAME;
* @author Vincent Bourgmayer
* Source: https://vogella.developpez.com/tutoriels/android/utilisation-base-donnees-sqlite/
*/
class SyncedFolderDAO {
class SyncedFolderDAO extends AbstractDAO {
final private static String TAG = SyncedFolderDAO.class.getSimpleName(); //Tag for log
private SQLiteDatabase mDB;
private final DbHelper mHelper;
private final String[] allColumns = { SyncedFolderContract._ID,
CATEGORIE_LABEL,
LOCAL_PATH,
......@@ -50,23 +48,7 @@ class SyncedFolderDAO {
};
SyncedFolderDAO(Context context){
this.mHelper = new DbHelper(context);
}
/**
* Open Database connexion
* @param writeMod Connexion mod. If set to true, database is open in writable mod, else it is opened in read mod.
* @throws SQLException SqlException
*/
void open(Boolean writeMod) throws SQLException {
mDB = (writeMod)? mHelper.getWritableDatabase() : mHelper.getReadableDatabase();
}
/**
* Close Database connexion
*/
void close() {
mHelper.close();
super(context);
}
/**
......@@ -133,24 +115,19 @@ class SyncedFolderDAO {
* @return List of all syncedFolder
*/
List<SyncedFolder> getSyncedFolderList(String selection, String[] args) {
Log.i(TAG, "getSyncedFolderList("+selection+", "+args+")");
List<SyncedFolder> syncedFolders = new ArrayList<SyncedFolder>();
Cursor cursor = mDB.query(TABLE_NAME, allColumns, selection,args, null, null,
null);
cursor.moveToFirst();
while ( !cursor.isAfterLast() ) {
SyncedFolder syncedFolder = cursorToSyncedFolder(cursor);
if(syncedFolder == null ){
Log.e(TAG, "getAllSyncedFolders : current Folder is null");
}else {
if(syncedFolder != null ){
syncedFolders.add(syncedFolder);
}
cursor.moveToNext();
}
// assurez-vous de la fermeture du curseur
cursor.close();
return syncedFolders;
}
......
......@@ -16,6 +16,7 @@ import android.util.Log;
import io.eelo.drive.receivers.ScreenOffReceiver;
import io.eelo.drive.services.ObserverService;
import io.eelo.drive.services.ObserverServiceV2;
import io.eelo.drive.utils.CommonUtils;
/**
......@@ -33,7 +34,7 @@ public class ScannerJob extends JobService {
filter.addAction(Intent.ACTION_SCREEN_OFF);
getApplicationContext().registerReceiver(ScreenOffReceiver.getInstance(), filter);
Intent observerServiceIntent = new Intent(this, ObserverService.class);
Intent observerServiceIntent = new Intent(this, ObserverServiceV2.class);
this.startService(observerServiceIntent);
jobFinished(params, false);
return true;
......
package io.eelo.drive.models;
import com.owncloud.android.lib.resources.files.model.ISynchronizableContent;
public class Operation{
public final static int OPERATION_DOWNLOAD =0; //opposed = 1;
public final static int OPERATION_UPLOAD = 1; //opposed = 0;
public final static int OPERATION_REMOVE_REMOTE = 2; // opposed = 3;
public final static int OPERATION_REMOVE_LOCAL = 3; //opposed = 2
public final static int OPERATION_MKCOL =4; //opposed = 5;
public final static int OPERATION_CREATE_FOLDER_LOCAL = 5; // opposed = 4;
private ISynchronizableContent file;
private int operationCode; //Identify which type of operation it is
private String resultHash;
private boolean isSuccess;
private boolean isMediaType; //define if it's media or settings
public Operation(ISynchronizableContent file, int operationCode){
this.file = file;
this.operationCode = operationCode;
this.isSuccess = false;
}
public Operation(int operationCode, boolean isSuccess, String resultHash){
this.operationCode = operationCode;
this.isSuccess = isSuccess;
this.resultHash = resultHash;
}
public ISynchronizableContent getFile(){
return this.file;
}
public int getOperationCode(){
return this.operationCode;
}
public boolean isSuccess(){return this.isSuccess;}
public String getResultHash(){
return this.resultHash;
}
public void setFile(ISynchronizableContent file) {
this.file = file;
}
public void setOperationCode(int operationCode) {
this.operationCode = operationCode;
}
public void setResultHash(String resultHash) {
this.resultHash = resultHash;
}
public void setSuccess(boolean success) {
isSuccess = success;
}
public boolean isMediaType() {
return isMediaType;
}
public void setMediaType(boolean mediaType) {
isMediaType = mediaType;
}
}
package io.eelo.drive.models;
public class OperationDone {
private int id;
private String targetPath;
private String sourcePath;
private int operationCode;
private String resultCode;
private boolean isSuccess;
private String newEtag; // Upload operation only
public OperationDone(String targetPath, String sourcePath, int operationCode, String resultCode, boolean isSuccess){
this.targetPath = targetPath;
this.sourcePath = sourcePath;
this.operationCode = operationCode;
this.resultCode = resultCode;
this.isSuccess = isSuccess;
}
/**
* Return the new etag after an upload operation
* @return can be null if it's not an upload operation
*/
public String getNewEtag(){
return newEtag;
}
public void setNewEtag(String value){
this.newEtag = value;
}
public String getTargetPath() {
return targetPath;
}
public void setTargetPath(String targetPath) {
this.targetPath = targetPath;
}
public String getSourcePath() {
return sourcePath;
}
public void setSourcePath(String sourcePath) {
this.sourcePath = sourcePath;
}
public int getOperationCode() {
return operationCode;
}
public void setOperationCode(int operationCode) {
this.operationCode = operationCode;
}
public String getResultCode() {
return resultCode;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
public boolean isSuccess() {
return isSuccess;
}
public void setSuccess(boolean success) {
isSuccess = success;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
......@@ -14,7 +14,7 @@ import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import java.io.File;
......@@ -48,21 +48,21 @@ public class CreateInitialRemoteFolderOperation extends RemoteOperation {
Log.e(TAG, "Local folder doesn't exist, so create it");
folder.mkdirs();
}
CreateRemoteFolderOperation createFolderOperation = new CreateRemoteFolderOperation(mRemotePath, mCreateFullPath);
RemoteOperationResult createOperationResult;
createOperationResult = createFolderOperation.execute(client, true);
//Perfom request
CreateFolderRemoteOperation createFolderOperation = new CreateFolderRemoteOperation(mRemotePath, mCreateFullPath);
RemoteOperationResult createOperationResult = createFolderOperation.execute(client, true);
if(createOperationResult.isSuccess() || createOperationResult.getCode() == RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS ){
if(DbHelper.insertSyncedFolder(mSyncedFolder, mContext) >= 0 ) {
Log.d(TAG, "Insertion in DB succeed");
return new RemoteOperationResult(RemoteOperationResult.ResultCode.OK);
}else {
Log.d(TAG, "insertion of folder in DB failed");
return new RemoteOperationResult(RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS);
}
}
Log.d(TAG, createOperationResult.getLogMessage()+" \n"+createOperationResult.getCode()+
" \n"+createOperationResult.getHttpCode()+" \n"+createOperationResult.getAuthenticateHeaders().toString());
return createOperationResult;
}
}
......@@ -15,7 +15,7 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import java.io.File;
......@@ -166,7 +166,7 @@ public class DownloadFileOperation extends RemoteOperation implements Comparable
//So now, we can update instance of SyncedState and save it to DB
if( DbHelper.manageSyncedFileStateDB( mSyncedState, "UPDATE", mContext ) <= 0 ){
Log.e(TAG, "DB update failed: 0 affected row");
//@TODO : do smtg
//@TODO : do smtg if syncedFileState didn't update
}
return new RemoteOperationResult( mResultCode );
}
......
package io.eelo.drive.operations;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import java.io.File;
import java.lang.annotation.Target;
import io.eelo.drive.utils.CommonUtils;
public class DownloadFileOperationV2 extends RemoteOperation implements ComparableOperation{
private final static String TAG = DownloadFileOperation.class.getSimpleName();
private final RemoteFile mRFile;
private final Context mContext;
private String mTargetPath;
private Boolean isMediaType;
/**
* COnstructor of download operation where syncedFileState is already known
* @param remoteFile remote file to Download
* @param targetPath can be null if defined in syncedFileState
* @param context calling context
*/
public DownloadFileOperationV2(RemoteFile remoteFile, String targetPath, boolean isMediaType, Context context){
this.mRFile = remoteFile;
this.mContext = context;
this.mTargetPath = targetPath;
this.isMediaType = isMediaType;
}
@Override
protected RemoteOperationResult run(OwnCloudClient ownCloudClient) {
Log.i(TAG, "run(ownCloudClient)");
//get or build synced file equivalent of this.mFile
if(mTargetPath == null || mTargetPath.isEmpty()) {
Log.e(TAG, "mSyncedState or mTargetPath is empty or null. Can't Download in those conditions");
return new RemoteOperationResult(RemoteOperationResult.ResultCode.FORBIDDEN);
}
String fileName = CommonUtils.getFileNameFromPath(mTargetPath);
String tmpTargetPath = mContext.getExternalCacheDir()+ FileUtils.PATH_SEPARATOR+fileName;
DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(mRFile.getRemotePath(),
tmpTargetPath);
RemoteOperationResult downloadResult = downloadOperation.execute( ownCloudClient );
RemoteOperationResult.ResultCode mResultCode;
if( downloadResult.isSuccess() ){
File tmpLocalFile = new File(tmpTargetPath);
if( !tmpLocalFile.exists() ){
Log.e(TAG, "Downloaded file doesn't exist or is null");
mResultCode = RemoteOperationResult.ResultCode.FILE_NOT_FOUND;
}else if(tmpLocalFile.length() != mRFile.getLength() ){
Log.e(TAG, "Local and remote file doesn't have the same size.");
mResultCode = RemoteOperationResult.ResultCode.INVALID_OVERWRITE;
tmpLocalFile.delete();
}else{
//file has been correctly download.
File localFile = new File(mTargetPath);
if( localFile.exists() ){
localFile.delete(); //Remove existing file
}
//Check parentFolder existence and create if needed
String parentFoldersPath = localFile.getParent();
File localParentFile = new File(parentFoldersPath);
if( !localParentFile.exists() ){
if( localParentFile.mkdirs() )
Log.d(TAG, "Created folders: "+parentFoldersPath );
else
Log.d(TAG, "Can't create folders: "+parentFoldersPath );
}
boolean renameResult = tmpLocalFile.renameTo(localFile);
if(!renameResult)
Log.d(TAG, "File hasn't been successfully moved at its place");
mResultCode = RemoteOperationResult.ResultCode.OK;
//needed to make Gallery show new image
CommonUtils.doActionMediaScannerConnexionScanFile(mContext, mTargetPath );
}
}else{
//If download failed
Log.e(TAG, "Download failed: "+downloadResult.getLogMessage() );
mResultCode = RemoteOperationResult.ResultCode.UNKNOWN_ERROR;
}
return new RemoteOperationResult( mResultCode );
}
@Override
public String getRemotePath() {
return mRFile.getRemotePath();
}
@Override
public String getLocalPath() {
return mTargetPath;
}
@Override
public boolean isMediaType() {
return isMediaType;
}
@Override
public RemoteOperation toRemoteOperation() {
return this;
}
}
//@TODO: Move this into Nextcloud android lib. By replaceing current DownloadRemoteFileOperation.
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2015 ownCloud Inc.
*
......@@ -24,8 +26,9 @@
*/
package io.eelo.drive.operations;
import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.OperationCancelledException;
import com.owncloud.android.lib.common.operations.RemoteOperation;
......@@ -41,9 +44,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
/**
......@@ -58,7 +58,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
private static final String TAG = DownloadRemoteFileOperation.class.getSimpleName();
private final Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
private long mModificationTimestamp = 0;
private String mEtag = "";
......@@ -105,8 +104,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
int status = -1;
boolean savedFile = false;
mGet = new GetMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
Iterator<OnDatatransferProgressListener> dataTransferListenerIterator = null;
Log.d("DownloadRemoteFileOp","query string:"+mGet.getQueryString());
FileOutputStream fos = null;
try {
status = client.executeMethod(mGet);
......@@ -132,13 +130,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
fos.write(bytes, 0, readResult);
transferred += readResult;
synchronized (mDataTransferListeners) {
dataTransferListenerIterator = mDataTransferListeners.iterator();
while (dataTransferListenerIterator.hasNext()) {
dataTransferListenerIterator.next().onTransferProgress(readResult, transferred, totalToTransfer,
targetFile.getName());
}
}
}
// Check if the file is completed
// if transfer-encoding: chunked we cannot check if the file is complete
......
......@@ -14,8 +14,8 @@ import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.LightReadFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import java.io.File;
import java.util.ArrayList;
......@@ -76,25 +76,26 @@ public class ListRemoteFileOperation extends RemoteOperation {
}
if(syncedFolder.getId() > 0){
//Create ReadRemoteOperation
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(syncedFolder.getRemoteFolder());
LightReadFolderRemoteOperation operation = new LightReadFolderRemoteOperation(syncedFolder.getRemoteFolder(), 1, false);
RemoteOperationResult result = operation.execute(ownCloudClient);
if(result.isSuccess() ){
//is success then data can't be null
int dataSize = result.getData().size();
if(dataSize > 1){ //There is at least one subfiles
RemoteFile directory = (RemoteFile) result.getData().get(0);
if(!directory.getEtag().equals(syncedFolder.getLastEtag() )){ //if etag differs
List<Object> remoteFiles = result.getData().subList( 1, dataSize ); //get list of subfiles
//is success thus data can't be null
ArrayList<Object> datas = result.getData();
int dataSize = datas.size();
if(dataSize > 1){ //There is at least one subfiles. Note: data[0] contains the folder.
RemoteFile directory = (RemoteFile) datas.get(0);
if( !( directory.getEtag().equals( syncedFolder.getLastEtag() ) ) ){ //if etag differs
//loop through subelements
for (int i = -1, remoteFilesSize = remoteFiles.size(); ++i < remoteFilesSize; ){
RemoteFile remoteFile = (RemoteFile) remoteFiles.get(i);
for (int i = 0; ++i < dataSize; ){
RemoteFile remoteFile = (RemoteFile) datas.get(i);
if( remoteFile.getMimeType().equals("DIR") ) {
String suffixPath = remoteFile.getRemotePath().substring( syncedFolder.getRemoteFolder().length() );
//but is it already known as SyncedFolder?
SyncedFolder subSyncedFolder = new SyncedFolder(syncedFolder, suffixPath, 0L, "" ); //need to set empty etag to allow it to be scan
mSyncedFolderIterator.add(subSyncedFolder);
mSyncedFolderIterator.previous();
......
/*
* Copyright © Vincent Bourgmayer (/e/ foundation).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package io.eelo.drive.operations;
import android.content.Context;
import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.LightReadFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import org.apache.jackrabbit.webdav.property.DavPropertyName;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import io.eelo.drive.database.DbHelper;
import io.eelo.drive.models.SyncedFolder;
import io.eelo.drive.utils.AppConstants;
/**
*
* @author Vincent Bourgmayer
* Created by Vincent on 04/05/2018.
*/
public class ListRemoteFileOperation_v2 extends RemoteOperation {
private final String TAG = ListRemoteFileOperation_v2.class.getSimpleName();
private final Context mContext;
public ListRemoteFileOperation_v2(Context context){
Log.i(TAG, "Constructor of ListRemoteFileOperation");
this.mContext = context;
}
/**
* Execute l'operation
* @param ownCloudClient DAV client
* @return List containing remoteFolder followed by remote files
*/
@Override
protected RemoteOperationResult run(OwnCloudClient ownCloudClient){
Log.i(TAG, "run()");
RemoteOperationResult finalResult;
LightReadFolderRemoteOperation operation = new LightReadFolderRemoteOperation("/", DavPropertyName.DEPTH_INFINITY, AppConstants.ALLOW_GZIP);
RemoteOperationResult result = operation.execute(ownCloudClient);
if(result.isSuccess()){
ArrayList<Object> mRemoteFiles = new ArrayList<>();
ArrayList<Object> datas = result.getData();
//loop through subelements
for (int i = -1, dataSize = datas.size(); ++i < dataSize; ) {
mRemoteFiles.add(datas.get(i));
}
finalResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.OK);
finalResult.setData(mRemoteFiles);
return finalResult;
}
Log.v(TAG, "end of run()");
return result;
}
}
......@@ -9,7 +9,7 @@
package io.eelo.drive.operations;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
import io.eelo.drive.models.SyncedFileState;
......@@ -19,7 +19,7 @@ import io.eelo.drive.models.SyncedFileState;
* Created by Vincent on 19/06/2018.
* Class to be able to wrap concerned SyncedFileState in operation, so it can be retrieve at the end
*/
public class RemoveFileOperation extends RemoveRemoteFileOperation implements ComparableOperation{
public class RemoveFileOperation extends RemoveFileRemoteOperation implements ComparableOperation{
private SyncedFileState mSyncedFileState;
......
......@@ -8,23 +8,20 @@
package io.eelo.drive.operations;
import android.app.NotificationManager;
import android.content.Context;
import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.UserInfo;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import io.eelo.drive.database.DbHelper;
import io.eelo.drive.models.SyncedFileState;
import io.eelo.drive.utils.CommonUtils;
......@@ -41,7 +38,6 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
private long previousLastModified;
private boolean checkEtag;
private String mTargetPath;
private final File mFile;
private final Context mContext;
private SyncedFileState mSyncedState;
......@@ -126,15 +122,33 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
return new RemoteOperationResult(RemoteOperationResult.ResultCode.SYNC_CONFLICT);
}
/* @code to verify */
GetRemoteUserInfoOperation getRemoteUserInfoOperation = new GetRemoteUserInfoOperation();
RemoteOperationResult ocsResult = getRemoteUserInfoOperation.execute(client);
if(ocsResult.isSuccess() && ocsResult.getData() != null){
if( ((UserInfo) ocsResult.getData().get(0)).getQuota().getFree() < mFile.length() ) {
Log.w(TAG, "quota exceeded!");
return new RemoteOperationResult(RemoteOperationResult.ResultCode.QUOTA_EXCEEDED);
}else{
Log.d(TAG, "Quota Okay");
}
}else{
Log.w(TAG, "getRemoteUserInfoOperation failed: "+ocsResult.getHttpCode() );
return new RemoteOperationResult(ocsResult.getCode());
}
/* end of code to verify */
String timeStamp = ( (Long) ( mFile.lastModified() / 1000) ).toString() ;
//create UploadFileOperation
UploadRemoteFileOperation uploadRemoteFileOperation = new UploadRemoteFileOperation( mSyncedState.getLocalPath(),
UploadFileRemoteOperation uploadRemoteFileOperation = new UploadFileRemoteOperation( mSyncedState.getLocalPath(),
( mTargetPath != null ) ? mTargetPath : mSyncedState.getRemotePath(),
CommonUtils.getMimeType( mFile ),
( !checkEtag || mSyncedState.getLastETAG().isEmpty() )? null : mSyncedState.getLastETAG(), //If not null, This can cause error 412; that means remote file has change
timeStamp );
uploadRemoteFileOperation.askResultEtag(true);
// Execute UploadFileOperation
RemoteOperationResult uploadResult = uploadRemoteFileOperation.execute( client );
......@@ -144,46 +158,22 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
//if upload is a success
if( uploadResult.isSuccess() ){
// get new Etag of the file on the server
ReadRemoteFileOperation getEtagOp = new ReadRemoteFileOperation( mTargetPath );
RemoteOperationResult readRemoteOpResult = getEtagOp.execute( client );
//if readRemoteFile is a success
if ( readRemoteOpResult.isSuccess() ) {
List<Object> datas = readRemoteOpResult.getData();
if(datas != null) {
//extract new Etag and update SyncedFileState;
RemoteFile rf = (RemoteFile) datas.get(0);
//If length differs then there is an issue during transfer
if( rf.getLength() != this.mFile.length() ){
Log.e(TAG, "Local and remote file doesn't have the same size.\n"+restartCounter
+" unsuccessfull trial(s) of uploading file "
+rf.getRemotePath() );
mResultCode = RemoteOperationResult.ResultCode.INVALID_OVERWRITE;
}else {
mSyncedState.setLastETAG(rf.getEtag());
mSyncedState.setLocalLastModified(mFile.lastModified());
mResultCode = RemoteOperationResult.ResultCode.OK;
mustRestart = false;
}
}else{
Log.e(TAG, "No data in readRemoteResult ");
mResultCode = RemoteOperationResult.ResultCode.CONFLICT;
}
}else{
//readRemoteOperation failed
Log.e( TAG, "ReadRemoteFileOperation => Uploaded file not found on server " );
mResultCode = RemoteOperationResult.ResultCode.CONFLICT;
Object data = uploadResult.getSingleData();
if(data != null){
String etag = (String) data;
Log.d(TAG, "got new etag from PUT result: "+etag);
mSyncedState.setLastETAG(etag);
}
mSyncedState.setLocalLastModified(mFile.lastModified());
mResultCode = uploadResult.getCode();
}else{
//Si les répértoires ou mettre le fichier n'existe pas, on les ajoutes.
if( uploadResult.getCode() == RemoteOperationResult.ResultCode.FILE_NOT_FOUND ){
Log.d(TAG, "Catched a File not found result for : "+mFile.getName()+", create missing remote path then retry");
String remoteFoldersPath = mTargetPath.substring( 0, mTargetPath.lastIndexOf(FileUtils.PATH_SEPARATOR)+1 );
mResultCode = RemoteOperationResult.ResultCode.FILE_NOT_FOUND;
CreateRemoteFolderOperation createFolderOperation = new CreateRemoteFolderOperation( remoteFoldersPath, true );
CreateFolderRemoteOperation createFolderOperation = new CreateFolderRemoteOperation( remoteFoldersPath, true );
try{
createFolderOperation.execute( client );
}catch(Exception e){
......@@ -237,8 +227,8 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
}
/**
* @inherited
* @return
* Return the path of a file in the cloud
* @return String. The path to the file
*/
@Override
public String getRemotePath() {
......@@ -246,8 +236,8 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
}
/**
* @inherited
* @return
* Return the path on the device of a file.
* @return String. The path to the file
*/
@Override
public String getLocalPath() {
......
package io.eelo.drive.operations;
import android.content.Context;
import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.UserInfo;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
import java.io.File;
import io.eelo.drive.utils.CommonUtils;
public class UploadFileOperationV2 extends RemoteOperation implements ComparableOperation {
private final static String TAG = UploadFileOperationV2.class.getSimpleName();
private boolean isMediaType;
private int restartCounter =0;
private long previousLastModified;
private boolean checkEtag;
private String mTargetPath;
private final File mFile;
private final Context mContext;
@Override
public RemoteOperation toRemoteOperation() {
return this;
}
/**
* Construct an upload operation with an already known syncedFileState
* @param file File to upload
* @param context context in which to upload
* @param checkEtag if we should use IF MATCH header with etag
*/
public UploadFileOperationV2 (File file, String mTargetPath, Context context, boolean checkEtag){
this.mFile = file;
this.mContext = context;
this.mTargetPath = mTargetPath;
this.checkEtag = checkEtag;
}
/**
* Execute the operation:
*
* creates UploadFileOperation and execute it synchronously.
* When result is get and if it's a success
* Start scan remoteFile to get remote file Etag and save it in the SyncedFileState database.
* @param client (OwnCloudClient)
* @return RemoteOperationResult. Contains "Unknown error" as result code if upload fails or can contains
* "conflict" result code if it can got new Etag. It contains resultCode "Ok" if everything is allright or "sync_conflict" if file
* hasn't change since last update or "forbidden" if no remote path can be fetch.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client ) {
//as operation isn't executed immediatly, file might have been deleted since creation of operation
if(mTargetPath == null || !mFile.exists()){
Log.e(TAG, "run(client): no syncedFileState or target path, can't perform upload operation");
return new RemoteOperationResult(RemoteOperationResult.ResultCode.FORBIDDEN);
}
/* @code to verify */
GetRemoteUserInfoOperation getRemoteUserInfoOperation = new GetRemoteUserInfoOperation();
RemoteOperationResult ocsResult = getRemoteUserInfoOperation.execute(client);
if(ocsResult.isSuccess() && ocsResult.getData() != null){
if( ((UserInfo) ocsResult.getData().get(0)).getQuota().getFree() < mFile.length() ) {
Log.w(TAG, "quota exceeded!");
return new RemoteOperationResult(RemoteOperationResult.ResultCode.QUOTA_EXCEEDED);
}else{
Log.d(TAG, "Quota Okay");
}
}else{
Log.w(TAG, "getRemoteUserInfoOperation failed: "+ocsResult.getHttpCode() );
return new RemoteOperationResult(ocsResult.getCode());
}
/* end of code to verify */
String timeStamp = ( (Long) ( mFile.lastModified() / 1000) ).toString() ;
//create UploadFileOperation
/*UploadFileRemoteOperation uploadRemoteFileOperation = new UploadFileRemoteOperation( mSyncedState.getLocalPath(),
( mTargetPath != null ) ? mTargetPath : mSyncedState.getRemotePath(),
CommonUtils.getMimeType( mFile ),
( !checkEtag || mSyncedState.getLastETAG().isEmpty() )? null : mSyncedState.getLastETAG(), //If not null, This can cause error 412; that means remote file has change
timeStamp );
uploadRemoteFileOperation.askResultEtag(true);*/
// Execute UploadFileOperation
//RemoteOperationResult uploadResult = uploadRemoteFileOperation.execute( client );
RemoteOperationResult.ResultCode mResultCode;
//if upload is a success
/*if( uploadResult.isSuccess() ){
// get new Etag of the file on the server
Object data = uploadResult.getSingleData();
if(data != null){
String etag = (String) data;
Log.d(TAG, "got new etag from PUT result: "+etag);
}
mResultCode = uploadResult.getCode();
}else{
//Si les répértoires ou mettre le fichier n'existe pas, on les ajoutes.
if( uploadResult.getCode() == RemoteOperationResult.ResultCode.FILE_NOT_FOUND ){
Log.d(TAG, "Catched a File not found result for : "+mFile.getName()+", create missing remote path then retry");
String remoteFoldersPath = mTargetPath.substring( 0, mTargetPath.lastIndexOf(FileUtils.PATH_SEPARATOR)+1 );
mResultCode = RemoteOperationResult.ResultCode.FILE_NOT_FOUND;
CreateFolderRemoteOperation createFolderOperation = new CreateFolderRemoteOperation( remoteFoldersPath, true );
try{
createFolderOperation.execute( client );
}catch(Exception e){
return new RemoteOperationResult(e);
}
}else if(uploadResult.getCode() == RemoteOperationResult.ResultCode.QUOTA_EXCEEDED){
mResultCode = RemoteOperationResult.ResultCode.QUOTA_EXCEEDED;
mustRestart = false;
}else{
//Upload failed
Log.e(TAG, "UploadRemoteFileOperation for : " + mFile.getName() + " failed => code: " + uploadResult.getCode());
mResultCode = RemoteOperationResult.ResultCode.UNKNOWN_ERROR;
}
}
// updated syncedFile in DB
DbHelper.manageSyncedFileStateDB(mSyncedState, "UPDATE", mContext);
ArrayList<Object> datas = new ArrayList<>();
datas.add(mSyncedState.getSyncedFolderId());
final RemoteOperationResult finalResult = new RemoteOperationResult(mResultCode);
finalResult.setData(datas);*/
return ocsResult;
}
/**
* Return the file that should be uploading
* @return File given to this operation
*/
public File getFile() {
return mFile;
}
/**
* tell what type of operation is it
* @return true if it is an operation for media's element, then false mean its a settings operation
*/
@Override
public boolean isMediaType(){
return isMediaType;
}
/**
* Return the path of a file in the cloud
* @return String. The path to the file
*/
@Override
public String getRemotePath() {
return mTargetPath;
}
/**
* Return the path on the device of a file.
* @return String. The path to the file
*/
@Override
public String getLocalPath() {
return CommonUtils.getLocalPath(mFile);
}
}
......@@ -35,7 +35,6 @@ public class PackageEventReceiver extends BroadcastReceiver {
DbHelper dbHelper = new DbHelper(context);
dbHelper.getWritableDatabase().close(); //Force upgrade of db.
/*if (!pref.getBoolean(AppConstants.INITIALIZATION_HAS_BEEN_DONE, false)) {
context.startService(new Intent(context, InitializerService.class));
} else if(CommonUtils.getAccount( pref.getString(AccountManager.KEY_ACCOUNT_NAME,""),
......
......@@ -14,6 +14,7 @@ import android.content.Intent;
import android.util.Log;
import io.eelo.drive.services.ObserverService;
import io.eelo.drive.services.ObserverServiceV2;
import io.eelo.drive.utils.CommonUtils;
/**
......@@ -48,7 +49,7 @@ public class ScreenOffReceiver extends BroadcastReceiver {
} else if ( intent.getAction().equals(Intent.ACTION_SCREEN_OFF)
&& CommonUtils.haveNetworkConnexion( context ) ) {
Log.d(TAG, "onReceive: ACTION_SCREEN_OFF");
Intent cloudIntent = new Intent(context, ObserverService.class);
Intent cloudIntent = new Intent(context, ObserverServiceV2.class);
context.startService(cloudIntent);
}
}
......
......@@ -39,9 +39,7 @@ import io.eelo.drive.utils.JobUtils;
import static com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR;
import static io.eelo.drive.utils.AppConstants.INITIALFOLDERS_NUMBER;
import static io.eelo.drive.utils.AppConstants.MEDIASYNC_PROVIDER_AUTHORITY;
import static io.eelo.drive.utils.AppConstants.MEDIA_SYNCABLE_CATEGORIES;
import static io.eelo.drive.utils.AppConstants.SETTINGSYNC_PROVIDER_AUTHORITY;
import static io.eelo.drive.utils.AppConstants.SETTINGS_SYNCABLE_CATEGORIES;
/**
......@@ -59,7 +57,7 @@ public class InitializerService extends Service implements OnRemoteOperationList
@Override