|
@@ -3,31 +3,30 @@
|
|
|
*
|
|
|
* @author Mario Danic
|
|
|
* Copyright (C) 2017 Mario Danic
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
* at your option) any later version.
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
* GNU Affero General Public License for more details.
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
package com.owncloud.android.services;
|
|
|
|
|
|
-import android.app.job.JobInfo;
|
|
|
import android.app.job.JobScheduler;
|
|
|
-import android.content.ComponentName;
|
|
|
import android.content.Context;
|
|
|
import android.media.ExifInterface;
|
|
|
import android.os.Handler;
|
|
|
-import android.os.PersistableBundle;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
+import com.evernote.android.job.JobRequest;
|
|
|
+import com.evernote.android.job.util.support.PersistableBundleCompat;
|
|
|
import com.owncloud.android.MainApp;
|
|
|
import com.owncloud.android.datamodel.SyncedFolder;
|
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
@@ -119,45 +118,33 @@ public class FileAlterationMagicListener implements FileAlterationListener {
|
|
|
|
|
|
final Long finalLastModificationTime = lastModificationTime;
|
|
|
|
|
|
- final Runnable runnable = new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- PersistableBundle bundle = new PersistableBundle();
|
|
|
- bundle.putString(SyncedFolderJobService.LOCAL_PATH, file.getAbsolutePath());
|
|
|
- bundle.putString(SyncedFolderJobService.REMOTE_PATH, FileStorageUtils.getInstantUploadFilePath(
|
|
|
- currentLocale,
|
|
|
- syncedFolder.getRemotePath(), file.getName(),
|
|
|
- finalLastModificationTime,
|
|
|
- syncedFolder.getSubfolderByDate()));
|
|
|
- bundle.putString(SyncedFolderJobService.ACCOUNT, syncedFolder.getAccount());
|
|
|
- bundle.putInt(SyncedFolderJobService.UPLOAD_BEHAVIOUR, syncedFolder.getUploadAction());
|
|
|
-
|
|
|
- JobScheduler js = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
|
|
|
-
|
|
|
- Long date = new Date().getTime();
|
|
|
- JobInfo job = new JobInfo.Builder(
|
|
|
- date.intValue(),
|
|
|
- new ComponentName(context, SyncedFolderJobService.class))
|
|
|
- .setRequiresCharging(syncedFolder.getChargingOnly())
|
|
|
- .setMinimumLatency(10000)
|
|
|
- .setRequiredNetworkType(syncedFolder.getWifiOnly() ? JobInfo.NETWORK_TYPE_UNMETERED :
|
|
|
- JobInfo.NETWORK_TYPE_ANY)
|
|
|
- .setExtras(bundle)
|
|
|
- .setPersisted(true)
|
|
|
- .build();
|
|
|
-
|
|
|
- Integer result = js.schedule(job);
|
|
|
- if (result <= 0) {
|
|
|
- Log_OC.d(TAG, "Job failed to start: " + result);
|
|
|
- }
|
|
|
-
|
|
|
- //fileRunnable.remove(file.getAbsolutePath());
|
|
|
- filesList.remove(file.getAbsolutePath());
|
|
|
- }
|
|
|
- };
|
|
|
+ PersistableBundleCompat bundle = new PersistableBundleCompat();
|
|
|
+ bundle.putString(AutoUploadJob.LOCAL_PATH, file.getAbsolutePath());
|
|
|
+ bundle.putString(AutoUploadJob.REMOTE_PATH, FileStorageUtils.getInstantUploadFilePath(
|
|
|
+ currentLocale,
|
|
|
+ syncedFolder.getRemotePath(), file.getName(),
|
|
|
+ finalLastModificationTime,
|
|
|
+ syncedFolder.getSubfolderByDate()));
|
|
|
+ bundle.putString(AutoUploadJob.ACCOUNT, syncedFolder.getAccount());
|
|
|
+ bundle.putInt(AutoUploadJob.UPLOAD_BEHAVIOUR, syncedFolder.getUploadAction());
|
|
|
+
|
|
|
+ JobScheduler js = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
|
|
|
+
|
|
|
+ int jobId = new JobRequest.Builder(AutoUploadJob.TAG)
|
|
|
+ .setExecutionWindow(30_000L, 40_000L)
|
|
|
+ .setRequiresCharging(syncedFolder.getChargingOnly())
|
|
|
+ .setRequiredNetworkType(syncedFolder.getWifiOnly() ? JobRequest.NetworkType.UNMETERED :
|
|
|
+ JobRequest.NetworkType.ANY)
|
|
|
+ .setExtras(bundle)
|
|
|
+ .setPersisted(true)
|
|
|
+ .build()
|
|
|
+ .schedule();
|
|
|
+
|
|
|
+ //fileRunnable.remove(file.getAbsolutePath());
|
|
|
+ filesList.remove(file.getAbsolutePath());
|
|
|
|
|
|
//fileRunnable.put(file.getAbsolutePath(), runnable);
|
|
|
- handler.postDelayed(runnable, 1500);
|
|
|
+ //handler.post(runnable);
|
|
|
}
|
|
|
|
|
|
}
|