mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Acquire wakelocks to make sure all is good
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
d18d618ac4
commit
441e5c7511
2 changed files with 19 additions and 0 deletions
|
@ -24,6 +24,7 @@ package com.owncloud.android.jobs;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.PowerManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.evernote.android.job.Job;
|
import com.evernote.android.job.Job;
|
||||||
|
@ -47,7 +48,14 @@ public class AutoUploadJob extends Job {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Result onRunJob(Params params) {
|
protected Result onRunJob(Params params) {
|
||||||
|
|
||||||
final Context context = MainApp.getAppContext();
|
final Context context = MainApp.getAppContext();
|
||||||
|
|
||||||
|
PowerManager powerManager = (PowerManager) context.getSystemService(context.POWER_SERVICE);
|
||||||
|
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
|
TAG);
|
||||||
|
wakeLock.acquire();
|
||||||
|
|
||||||
PersistableBundleCompat bundle = params.getExtras();
|
PersistableBundleCompat bundle = params.getExtras();
|
||||||
final String filePath = bundle.getString(LOCAL_PATH, "");
|
final String filePath = bundle.getString(LOCAL_PATH, "");
|
||||||
final String remotePath = bundle.getString(REMOTE_PATH, "");
|
final String remotePath = bundle.getString(REMOTE_PATH, "");
|
||||||
|
@ -76,6 +84,7 @@ public class AutoUploadJob extends Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wakeLock.release();
|
||||||
return Result.SUCCESS;
|
return Result.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ package com.owncloud.android.jobs;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.PowerManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -62,9 +63,16 @@ public class NewAutoUploadJob extends Job {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Result onRunJob(Params params) {
|
protected Result onRunJob(Params params) {
|
||||||
|
|
||||||
final Context context = MainApp.getAppContext();
|
final Context context = MainApp.getAppContext();
|
||||||
final ContentResolver contentResolver = context.getContentResolver();
|
final ContentResolver contentResolver = context.getContentResolver();
|
||||||
|
|
||||||
|
PowerManager powerManager = (PowerManager) context.getSystemService(context.POWER_SERVICE);
|
||||||
|
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
|
TAG);
|
||||||
|
wakeLock.acquire();
|
||||||
|
|
||||||
|
|
||||||
// Create all the providers we'll need
|
// Create all the providers we'll need
|
||||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(contentResolver);
|
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(contentResolver);
|
||||||
final FilesystemDataProvider filesystemDataProvider = new FilesystemDataProvider(contentResolver);
|
final FilesystemDataProvider filesystemDataProvider = new FilesystemDataProvider(contentResolver);
|
||||||
|
@ -114,6 +122,8 @@ public class NewAutoUploadJob extends Job {
|
||||||
Log.d(TAG, "Something went wrong while indexing files for auto upload");
|
Log.d(TAG, "Something went wrong while indexing files for auto upload");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wakeLock.release();
|
||||||
return Result.SUCCESS;
|
return Result.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue