summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Nishi <dhnishi@google.com>2017-02-07 17:09:59 -0800
committerDaniel Nishi <dhnishi@google.com>2017-02-09 12:47:36 -0800
commitd10936319dce2526d8072db81b4876f73834d93f (patch)
tree5cbad7d4c73cddaff272368fb56934321290059c /src
parent20be9e9d7e06e3c6a68ca774c3df75e4b25dbb07 (diff)
downloadStorageManager-d10936319dce2526d8072db81b4876f73834d93f.tar.gz
Remove Downloads from Storage Manager.
Bug: 32338407 Test: No Robotest regressions Change-Id: I5f0d0c638591b48998cda140bd2e249c90821f1f
Diffstat (limited to 'src')
-rw-r--r--src/com/android/storagemanager/automatic/AutomaticStorageBroadcastReceiver.java21
-rw-r--r--src/com/android/storagemanager/automatic/DownloadsBackupJobService.java78
-rw-r--r--src/com/android/storagemanager/overlay/DownloadsBackupJobProvider.java37
-rw-r--r--src/com/android/storagemanager/overlay/FeatureFactory.java5
-rw-r--r--src/com/android/storagemanager/overlay/FeatureFactoryImpl.java5
5 files changed, 0 insertions, 146 deletions
diff --git a/src/com/android/storagemanager/automatic/AutomaticStorageBroadcastReceiver.java b/src/com/android/storagemanager/automatic/AutomaticStorageBroadcastReceiver.java
index 48fe9a5..e1c9d8c 100644
--- a/src/com/android/storagemanager/automatic/AutomaticStorageBroadcastReceiver.java
+++ b/src/com/android/storagemanager/automatic/AutomaticStorageBroadcastReceiver.java
@@ -23,7 +23,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.SystemProperties;
-import android.provider.Settings;
import android.text.format.DateUtils;
/**
* A {@link BroadcastReceiver} listening for {@link Intent#ACTION_BOOT_COMPLETED} broadcasts to
@@ -32,7 +31,6 @@ import android.text.format.DateUtils;
*/
public class AutomaticStorageBroadcastReceiver extends BroadcastReceiver {
private static final int AUTOMATIC_STORAGE_JOB_ID = 0;
- public static final int DOWNLOADS_BACKUP_JOB_ID = 1;
private static final long PERIOD = DateUtils.DAY_IN_MILLIS;
private static final String DEBUG_PERIOD_FLAG = "debug.asm.period";
@@ -50,24 +48,5 @@ public class AutomaticStorageBroadcastReceiver extends BroadcastReceiver {
.setPeriodic(periodicOverride)
.build();
jobScheduler.schedule(job);
-
- // Downloads backup
- int requiredNetworkType = JobInfo.NETWORK_TYPE_UNMETERED;
- if (Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.DOWNLOADS_BACKUP_ALLOW_METERED, 0) != 0) {
- requiredNetworkType = JobInfo.NETWORK_TYPE_ANY;
- }
- boolean requiresCharging = Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.DOWNLOADS_BACKUP_CHARGING_ONLY, 1) == 1;
- ComponentName downloadsBackupComponent = new ComponentName(context,
- DownloadsBackupJobService.class);
- JobInfo downloadsBackupJob =
- new JobInfo.Builder(DOWNLOADS_BACKUP_JOB_ID, downloadsBackupComponent)
- .setRequiredNetworkType(requiredNetworkType)
- .setRequiresCharging(requiresCharging)
- .setRequiresDeviceIdle(true)
- .setPeriodic(periodicOverride)
- .build();
- jobScheduler.schedule(downloadsBackupJob);
}
} \ No newline at end of file
diff --git a/src/com/android/storagemanager/automatic/DownloadsBackupJobService.java b/src/com/android/storagemanager/automatic/DownloadsBackupJobService.java
deleted file mode 100644
index 1e1dfb8..0000000
--- a/src/com/android/storagemanager/automatic/DownloadsBackupJobService.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.storagemanager.automatic;
-
-import android.app.job.JobParameters;
-import android.app.job.JobService;
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.storagemanager.overlay.DownloadsBackupJobProvider;
-import com.android.storagemanager.overlay.FeatureFactory;
-
-/**
- * This {@link JobService} starts an automatic job to backup the Downloads folder. It only runs when
- * backup is enabled.
- */
-public class DownloadsBackupJobService extends JobService {
- private DownloadsBackupJobProvider mJobProvider;
-
- @Override
- public boolean onStartJob(JobParameters jobParameters) {
- // Check that conditions for task are met again. This is necessary because the JobScheduler
- // is forced to run even if the conditions are not met.
- if (!isBackupEnabled() || !preconditionsFulfilled()){
- return false;
- }
-
- mJobProvider = FeatureFactory.getFactory(this).getDownloadsBackupJobProvider();
-
- if (mJobProvider != null) {
- return mJobProvider.onStartJob(this, jobParameters);
- }
-
- return false;
- }
-
- @Override
- public boolean onStopJob(JobParameters jobParameters) {
- if (mJobProvider != null) {
- return mJobProvider.onStopJob(this, jobParameters);
- }
- return true;
- }
-
- private boolean preconditionsFulfilled() {
- Context context = getApplicationContext();
- boolean isNetworkMetered = JobPreconditions.isNetworkMetered(context);
- boolean isWifiConnected = JobPreconditions.isWifiConnected(context);
- boolean allowMeteredNetwork = Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.DOWNLOADS_BACKUP_ALLOW_METERED, 0) != 0;
- boolean isNetworkConditionMet = (!isNetworkMetered && isWifiConnected) ||
- allowMeteredNetwork;
- boolean isCharging = JobPreconditions.isCharging(context);
- boolean allowBackupWhenNotCharging = Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.DOWNLOADS_BACKUP_CHARGING_ONLY, 1) != 1;
- boolean isChargingConditionMet = isCharging || allowBackupWhenNotCharging;
- return isNetworkConditionMet && isChargingConditionMet;
- }
-
- public boolean isBackupEnabled() {
- return Settings.Secure.getInt(getContentResolver(),
- Settings.Secure.DOWNLOADS_BACKUP_ENABLED, 0) != 0;
- }
-} \ No newline at end of file
diff --git a/src/com/android/storagemanager/overlay/DownloadsBackupJobProvider.java b/src/com/android/storagemanager/overlay/DownloadsBackupJobProvider.java
deleted file mode 100644
index d848295..0000000
--- a/src/com/android/storagemanager/overlay/DownloadsBackupJobProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.storagemanager.overlay;
-
-import android.app.job.JobParameters;
-import android.content.Context;
-
-/**
- * Feature provider for automatic backup jobs.
- */
-public interface DownloadsBackupJobProvider {
- /**
- * Starts asynchronous task to backup the Downloads folder.
- * @return If the job needs to process work on a separate thread.
- */
- boolean onStartJob(Context context, JobParameters jobParameters);
-
- /**
- * Stops the execution of the task.
- * @return If the job should be rescheduled.
- */
- boolean onStopJob(Context context, JobParameters jobParameters);
-}
diff --git a/src/com/android/storagemanager/overlay/FeatureFactory.java b/src/com/android/storagemanager/overlay/FeatureFactory.java
index c3cb993..59eaa20 100644
--- a/src/com/android/storagemanager/overlay/FeatureFactory.java
+++ b/src/com/android/storagemanager/overlay/FeatureFactory.java
@@ -69,11 +69,6 @@ public abstract class FeatureFactory {
*/
public abstract StorageManagementJobProvider getStorageManagementJobProvider();
- /**
- * Returns a provider which provides a periodic downloads backup job.
- */
- public abstract DownloadsBackupJobProvider getDownloadsBackupJobProvider();
-
public static class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) {
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
diff --git a/src/com/android/storagemanager/overlay/FeatureFactoryImpl.java b/src/com/android/storagemanager/overlay/FeatureFactoryImpl.java
index 9680262..b239ba0 100644
--- a/src/com/android/storagemanager/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/storagemanager/overlay/FeatureFactoryImpl.java
@@ -29,9 +29,4 @@ public class FeatureFactoryImpl extends FeatureFactory {
public StorageManagementJobProvider getStorageManagementJobProvider() {
return null;
}
-
- @Override
- public DownloadsBackupJobProvider getDownloadsBackupJobProvider() {
- return null;
- }
}