Remove the Deletion Helper and Automatic Storage Management jobs.
The automatic storage management settings have been left in place and updated to use the intent to get into the deletion helper. Bug: 28965462 Change-Id: I736c8e741b519eceb89075b74d42b38c3aa5d0f4
This commit is contained in:
@@ -1,90 +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.settings.deletionhelper;
|
||||
|
||||
import com.android.settings.deletionhelper.FetchDownloadsLoader.DownloadsResult;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class FetchDownloadsLoaderTest {
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void testEmptyDirectory() throws Exception {
|
||||
DownloadsResult result =
|
||||
FetchDownloadsLoader.collectFiles(temporaryFolder.getRoot());
|
||||
assertNotNull(result);
|
||||
assertEquals(0, result.totalSize);
|
||||
assertEquals(0, result.files.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilesInDirectory() throws Exception {
|
||||
temporaryFolder.newFile();
|
||||
temporaryFolder.newFile();
|
||||
|
||||
DownloadsResult result =
|
||||
FetchDownloadsLoader.collectFiles(temporaryFolder.getRoot());
|
||||
assertNotNull(result);
|
||||
assertEquals(0, result.totalSize);
|
||||
assertEquals(2, result.files.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedDirectories() throws Exception {
|
||||
File tempDir = temporaryFolder.newFolder();
|
||||
|
||||
File testFile = File.createTempFile("test", null, tempDir);
|
||||
testFile.deleteOnExit();
|
||||
DownloadsResult result =
|
||||
FetchDownloadsLoader.collectFiles(temporaryFolder.getRoot());
|
||||
assertNotNull(result);
|
||||
assertEquals(0, result.totalSize);
|
||||
assertEquals(1, result.files.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSumFileSizes() throws Exception {
|
||||
File first = temporaryFolder.newFile();
|
||||
FileWriter fileWriter = new FileWriter(first);
|
||||
fileWriter.write("test");
|
||||
fileWriter.close();
|
||||
|
||||
File second = temporaryFolder.newFile();
|
||||
fileWriter = new FileWriter(second);
|
||||
fileWriter.write("test2");
|
||||
fileWriter.close();
|
||||
|
||||
DownloadsResult result =
|
||||
FetchDownloadsLoader.collectFiles(temporaryFolder.getRoot());
|
||||
assertNotNull(result);
|
||||
assertEquals(9, result.totalSize);
|
||||
assertEquals(2, result.files.size());
|
||||
}
|
||||
}
|
@@ -1,120 +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.settings.deletionhelper;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import android.content.pm.IPackageDeleteObserver;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.RemoteException;
|
||||
import android.test.mock.MockPackageManager;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.android.settings.deletionhelper.PackageDeletionTask;
|
||||
import com.android.settings.deletionhelper.PackageDeletionTask.Callback;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PackageDeletionTaskTest extends AndroidTestCase {
|
||||
private FakePackageManager mPackageManager;
|
||||
private Set<String> mDeletedApps;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
mPackageManager = new FakePackageManager();
|
||||
mDeletedApps = new HashSet<String>();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testDeleteNoApps() throws Exception {
|
||||
runTask(new HashSet<String>(), false);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testDeleteOneApp() throws Exception {
|
||||
HashSet<String> appsToDelete = new HashSet<String>();
|
||||
appsToDelete.add("app.test1");
|
||||
runTask(appsToDelete, false);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testDeleteManyApps() throws Exception {
|
||||
HashSet<String> appsToDelete = new HashSet<String>();
|
||||
appsToDelete.add("app.test1");
|
||||
appsToDelete.add("app.test2");
|
||||
runTask(appsToDelete, false);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testDeleteFails() throws Exception {
|
||||
HashSet<String> appsToDelete = new HashSet<String>();
|
||||
appsToDelete.add("app.test1");
|
||||
mPackageManager.deletionSucceeds = false;
|
||||
runTask(appsToDelete, true);
|
||||
}
|
||||
|
||||
private void runTask(HashSet<String> appsToDelete, boolean shouldFail) {
|
||||
PackageDeletionTask task = new PackageDeletionTask(mPackageManager, appsToDelete,
|
||||
new VerifierCallback(appsToDelete, shouldFail));
|
||||
task.run();
|
||||
}
|
||||
|
||||
class FakePackageManager extends MockPackageManager {
|
||||
public boolean deletionSucceeds = true;
|
||||
|
||||
@Override
|
||||
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
|
||||
int flags, int userId) {
|
||||
int resultCode;
|
||||
if (deletionSucceeds) {
|
||||
resultCode = PackageManager.DELETE_SUCCEEDED;
|
||||
mDeletedApps.add(packageName);
|
||||
} else {
|
||||
resultCode = PackageManager.DELETE_FAILED_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
try {
|
||||
observer.packageDeleted(packageName, resultCode);
|
||||
} catch (RemoteException e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VerifierCallback extends Callback {
|
||||
private Set<String> mExpectedDeletedApps;
|
||||
private boolean mShouldFail;
|
||||
|
||||
public VerifierCallback(HashSet<String> expectedDeletedApps, boolean shouldFail) {
|
||||
mExpectedDeletedApps = expectedDeletedApps;
|
||||
mShouldFail = shouldFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
System.out.println("lol");
|
||||
assertFalse(mShouldFail);
|
||||
assertEquals(mExpectedDeletedApps, mDeletedApps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
assertTrue(mShouldFail);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user