Commit e498edb0 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Revert "Save WebappActivity tab state to bundle, remove old stale file deletion"

This reverts commit 1c0ecd5d.

Reason for revert: Increases crash rate due to large bundles.

Original change's description:
> Save WebappActivity tab state to bundle, remove old stale file deletion
>
> Simplifies tab restore by copying from NoTouchActivity, which has the
> same persistence model (currently) as WebappActivity.
>
> This also simplifies the stale directory cleanup to only clean up more
> recent sources of stale directories. This could lead stale directories
> to stick around when updating from very old versions of Chrome, but
> these directories should be small regardless.
>
> Also deletes some unused webApk UMA constants, and deletes the unused
> histogram generation code in NoTouchActivity for tab restore.
>
> Bug: 525785
> Change-Id: I615542e2f28a147ecd5403b04b61b749f3e737ab
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769313
> Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
> Reviewed-by: Peter Kotwicz <pkotwicz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#690834}

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 525785
Change-Id: I47afd77f54e7c11574a5814fbdec50a1a3cf3d46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1926573
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717689}
parent cc78d7f3
......@@ -124,6 +124,11 @@ public class WebApkUma {
private static final String HISTOGRAM_LAUNCH_TO_SPLASHSCREEN_HIDDEN =
"WebApk.Startup.Cold.ShellLaunchToSplashscreenHidden";
private static final int WEBAPK_OPEN_MAX = 3;
public static final int WEBAPK_OPEN_LAUNCH_SUCCESS = 0;
// Obsolete: WEBAPK_OPEN_NO_LAUNCH_INTENT = 1;
public static final int WEBAPK_OPEN_ACTIVITY_NOT_FOUND = 2;
private static final long WEBAPK_EXTRA_INSTALLATION_SPACE_BYTES =
100 * (long) ConversionUtils.BYTES_PER_MEGABYTE; // 100 MB
......
......@@ -27,6 +27,7 @@ import org.chromium.base.ActivityState;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.Log;
import org.chromium.base.StrictModeContext;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.task.PostTask;
......@@ -69,6 +70,7 @@ import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.net.NetworkChangeNotifier;
import org.chromium.ui.base.PageTransition;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -85,6 +87,8 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen
protected static final String BUNDLE_TAB_ID = "tabId";
private final WebappDirectoryManager mDirectoryManager;
private WebappInfo mWebappInfo;
private WebappActivityTabController mTabController;
......@@ -148,6 +152,7 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen
*/
public WebappActivity() {
mWebappInfo = createWebappInfo(null);
mDirectoryManager = new WebappDirectoryManager();
mDisclosureSnackbarController = new WebappDisclosureSnackbarController();
}
......@@ -373,13 +378,14 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
saveTabState(outState);
mDirectoryManager.cancelCleanup();
saveState(outState);
}
@Override
public void onStartWithNative() {
super.onStartWithNative();
WebappDirectoryManager.cleanUpDirectories();
mDirectoryManager.cleanUpDirectories(this, getActivityId());
}
@Override
......@@ -391,21 +397,25 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen
/**
* Saves the tab data out to a file.
*/
private void saveTabState(Bundle outState) {
Tab tab = getActivityTab();
if (tab == null || tab.getUrl() == null || tab.getUrl().isEmpty()) return;
if (TabState.saveState(outState, TabState.from(tab))) {
outState.putInt(BUNDLE_TAB_ID, tab.getId());
private void saveState(Bundle outState) {
if (getActivityTab() == null || getActivityTab().getUrl() == null
|| getActivityTab().getUrl().isEmpty()) {
return;
}
outState.putInt(BUNDLE_TAB_ID, getActivityTab().getId());
String tabFileName = TabState.getTabStateFilename(getActivityTab().getId(), false);
File tabFile = new File(getActivityDirectory(), tabFileName);
// TODO(crbug.com/525785): Temporarily allowing disk access until more permanent fix is in.
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
TabState.saveState(tabFile, TabState.from(getActivityTab()), false);
}
}
/**
* Restore {@link TabState} from a given {@link Bundle} and tabId.
* @param saveInstanceState The saved bundle for the last recorded state.
* @param tabId ID of the tab restored from.
*/
private TabState restoreTabState(Bundle savedInstanceState, int tabId) {
return TabState.restoreTabState(savedInstanceState);
return TabState.restoreTabState(getActivityDirectory(), tabId);
}
@Override
......@@ -748,6 +758,15 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen
return mWebappInfo.id();
}
/**
* Get the active directory by this web app.
*
* @return The directory used for the current web app.
*/
private File getActivityDirectory() {
return mDirectoryManager.getWebappDirectory(this, getActivityId());
}
@VisibleForTesting
SplashController getSplashControllerForTests() {
return mSplashController;
......
......@@ -4,27 +4,46 @@
package org.chromium.chrome.browser.webapps;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.ActivityManager.AppTask;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.text.format.DateUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.FileUtils;
import org.chromium.base.Log;
import org.chromium.base.PackageUtils;
import org.chromium.base.PathUtils;
import org.chromium.base.StrictModeContext;
import org.chromium.base.task.AsyncTask;
import org.chromium.base.task.BackgroundOnlyAsyncTask;
import org.chromium.chrome.browser.metrics.WebApkUma;
import org.chromium.chrome.browser.util.AndroidTaskUtils;
import org.chromium.webapk.lib.common.WebApkConstants;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Manages directories created to store data for WebAPK updates, and cleans up stale state
* directories left behind under app_WebappActivity/.
* Manages directories created to store data for web apps.
*
* Directories managed by this class are all subdirectories of the app_WebappActivity/ directory,
* which each WebappActivity using a directory named either for its Webapp's ID in Document mode,
* or the index of the WebappActivity if it is a subclass of the WebappManagedActivity class (which
* are used in pre-L devices to allow multiple WebappActivities launching).
*
* Also records metrics about files in the "WebAPK update" directory.
*/
public class WebappDirectoryManager {
protected static final String DEPRECATED_WEBAPP_DIRECTORY_NAME = "WebappActivity";
protected static final String WEBAPP_DIRECTORY_NAME = "WebappActivity";
private static final String TAG = "WebappDirectoryManag";
/** Path of subdirectory within cache directory which contains data for pending updates. */
private static final String UPDATE_DIRECTORY_PATH = "webapk/update";
......@@ -32,30 +51,111 @@ public class WebappDirectoryManager {
/** Whether or not the class has already started trying to clean up obsolete directories. */
private static final AtomicBoolean sMustCleanUpOldDirectories = new AtomicBoolean(true);
/** AsyncTask that is used to clean up the web app directories. */
private AsyncTask<Void> mCleanupTask;
/**
* Deletes web app directories with stale data.
*
* This should be called by a {@link WebappActivity} after it has restored all the data it
* needs from its directory because the directory will be deleted during the process.
*
* @param context Context to pull info and Files from.
* @param currentWebappId ID for the currently running web app.
*/
public static void cleanUpDirectories() {
if (!sMustCleanUpOldDirectories.getAndSet(false)) return;
public void cleanUpDirectories(final Context context, final String currentWebappId) {
if (mCleanupTask != null) return;
new BackgroundOnlyAsyncTask<Void>() {
mCleanupTask = new BackgroundOnlyAsyncTask<Void>() {
@Override
protected final Void doInBackground() {
recordNumberOfStaleWebApkUpdateRequestFiles();
FileUtils.recursivelyDeleteFile(
getBaseWebappDirectory(ContextUtils.getApplicationContext()));
Set<File> directoriesToDelete = new HashSet<File>();
directoriesToDelete.add(getWebappDirectory(context, currentWebappId));
boolean shouldDeleteOldDirectories =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
if (shouldDeleteOldDirectories && sMustCleanUpOldDirectories.getAndSet(false)) {
findStaleWebappDirectories(context, directoriesToDelete);
}
for (File directory : directoriesToDelete) {
if (isCancelled()) return null;
FileUtils.recursivelyDeleteFile(directory);
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
};
mCleanupTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/** Cancels the cleanup task, if one exists. */
public void cancelCleanup() {
if (mCleanupTask != null) mCleanupTask.cancel(true);
}
/** Resets class' static state */
public static void resetForTesting() {
sMustCleanUpOldDirectories.set(true);
public void resetForTesting() {
sMustCleanUpOldDirectories.getAndSet(true);
}
/**
* Finds all directories for web apps containing stale data.
*
* This includes all directories using the old pre-L directory structure, which used directories
* named * app_WebappActivity*, as well as directories corresponding to WebappActivities that
* are no longer listed in Android's recents, since these will be unable to restore their data.
*
* @param directoriesToDelete Set to append directory names to.
*/
private void findStaleWebappDirectories(Context context, Set<File> directoriesToDelete) {
File webappBaseDirectory = getBaseWebappDirectory(context);
// Figure out what WebappActivities are still listed in Android's recents menu.
Set<String> liveWebapps = new HashSet<String>();
Set<Intent> baseIntents = getBaseIntentsForAllTasks();
for (Intent intent : baseIntents) {
Uri data = intent.getData();
if (data != null && TextUtils.equals(WebappActivity.WEBAPP_SCHEME, data.getScheme())) {
liveWebapps.add(data.getHost());
}
}
// Delete all web app directories in the main directory, which were for pre-L web apps.
File appDirectory = new File(context.getApplicationInfo().dataDir);
String webappDirectoryAppBaseName = webappBaseDirectory.getName();
File[] files = appDirectory.listFiles();
if (files != null) {
for (File file : files) {
String filename = file.getName();
if (!filename.startsWith(webappDirectoryAppBaseName)) continue;
if (filename.length() == webappDirectoryAppBaseName.length()) continue;
directoriesToDelete.add(file);
}
}
// Clean out web app directories which no longer correspond to a task in recents.
// Check if a WebAPK is installed to avoid an issue where
// {@link ActivityManager#getAppTasks()} does not return WebAPK tasks when
// WebApkActivity is not the root of the task (e.g. when the new-style splash screen
// is the root).
files = webappBaseDirectory.listFiles();
if (files != null) {
for (File file : files) {
String webApkPackageName = getWebApkPackageFromWebappDirectory(file);
if ((TextUtils.isEmpty(webApkPackageName)
|| !PackageUtils.isPackageInstalled(context, webApkPackageName))
&& !liveWebapps.contains(file.getName())) {
directoriesToDelete.add(file);
}
}
}
}
/** Records to UMA the count of old "WebAPK update request" files. */
private static void recordNumberOfStaleWebApkUpdateRequestFiles() {
private void recordNumberOfStaleWebApkUpdateRequestFiles() {
File updateDirectory = getWebApkUpdateDirectory();
int count = 0;
File[] children = updateDirectory.listFiles();
......@@ -77,9 +177,37 @@ public class WebappDirectoryManager {
WebApkUma.recordNumberOfStaleWebApkUpdateRequestFiles(count);
}
/**
* Returns the directory for a web app, creating it if necessary.
* @param webappId ID for the web app. Used as a subdirectory name.
* @return File for storing information about the web app.
*/
File getWebappDirectory(Context context, String webappId) {
// TODO(crbug.com/525785): Temporarily allowing disk access until more permanent fix is in.
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
File webappDirectory = new File(getBaseWebappDirectory(context), webappId);
if (!webappDirectory.exists() && !webappDirectory.mkdir()) {
Log.e(TAG, "Failed to create web app directory.");
}
return webappDirectory;
}
}
/**
* Returns the WebAPK package name if the passed-in directory is for a WebAPK. Returns null
* otherwise.
*/
private static String getWebApkPackageFromWebappDirectory(File directory) {
String name = directory.getName();
if (!name.startsWith(WebApkConstants.WEBAPK_ID_PREFIX)) {
return null;
}
return name.substring(WebApkConstants.WEBAPK_ID_PREFIX.length());
}
/** Returns the directory containing all of Chrome's web app data, creating it if needed. */
static final File getBaseWebappDirectory(Context context) {
return context.getDir(DEPRECATED_WEBAPP_DIRECTORY_NAME, Context.MODE_PRIVATE);
final File getBaseWebappDirectory(Context context) {
return context.getDir(WEBAPP_DIRECTORY_NAME, Context.MODE_PRIVATE);
}
/** Returns the directory for "WebAPK update" files. Does not create the directory. */
......@@ -91,4 +219,20 @@ public class WebappDirectoryManager {
static final File getWebApkUpdateFilePathForStorage(WebappDataStorage storage) {
return new File(getWebApkUpdateDirectory(), storage.getId());
}
/** Returns a Set of Intents for all Chrome tasks currently known by the ActivityManager. */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected Set<Intent> getBaseIntentsForAllTasks() {
Set<Intent> baseIntents = new HashSet<Intent>();
Context context = ContextUtils.getApplicationContext();
ActivityManager manager =
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (AppTask task : manager.getAppTasks()) {
Intent intent = AndroidTaskUtils.getBaseIntentFromTask(task);
if (intent != null) baseIntents.add(intent);
}
return baseIntents;
}
}
......@@ -5,7 +5,10 @@
package org.chromium.chrome.browser.webapps;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import org.junit.After;
import org.junit.Assert;
......@@ -18,7 +21,6 @@ import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.shadows.ShadowLooper;
import org.chromium.base.ContextUtils;
import org.chromium.base.FileUtils;
import org.chromium.base.PathUtils;
import org.chromium.base.ThreadUtils;
......@@ -28,8 +30,11 @@ import org.chromium.base.task.test.CustomShadowAsyncTask;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.webapk.lib.common.WebApkConstants;
import org.chromium.webapk.test.WebApkTestHelper;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
......@@ -42,12 +47,27 @@ public class WebappDirectoryManagerTest {
@Rule
public MockWebappDataStorageClockRule mClockRule = new MockWebappDataStorageClockRule();
private static final String WEBAPP_ID_1 = "webapp_1";
private static final String WEBAPP_ID_2 = "webapp_2";
private static final String WEBAPP_ID_3 = "webapp_3";
private static final String WEBAPK_PACKAGE_NAME_1 = "webapk_1";
private static final String WEBAPK_PACKAGE_NAME_2 = "webapk_2";
private static final String WEBAPK_PACKAGE_NAME_3 = "webapk_3";
private static final String WEBAPK_ID_1 =
WebApkConstants.WEBAPK_ID_PREFIX + WEBAPK_PACKAGE_NAME_1;
private static final String WEBAPK_ID_2 =
WebApkConstants.WEBAPK_ID_PREFIX + WEBAPK_PACKAGE_NAME_2;
private static final String WEBAPK_ID_3 =
WebApkConstants.WEBAPK_ID_PREFIX + WEBAPK_PACKAGE_NAME_3;
private static class TestWebappDirectoryManager extends WebappDirectoryManager {
private Set<Intent> mBaseIntents = new HashSet<Intent>();
@Override
protected Set<Intent> getBaseIntentsForAllTasks() {
return mBaseIntents;
}
}
/** Deletes directory and all of its children. Recreates empty directory in its place. */
private void deleteDirectoryAndRecreate(File f) {
......@@ -56,18 +76,19 @@ public class WebappDirectoryManagerTest {
}
private Context mContext;
private TestWebappDirectoryManager mWebappDirectoryManager;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
ContextUtils.initApplicationContext(mContext);
ThreadUtils.setThreadAssertsDisabledForTesting(true);
PathUtils.setPrivateDataDirectorySuffix("chrome");
WebappDirectoryManager.resetForTesting();
mWebappDirectoryManager = new TestWebappDirectoryManager();
mWebappDirectoryManager.resetForTesting();
// Set up directories.
deleteDirectoryAndRecreate(mContext.getDataDir());
FileUtils.recursivelyDeleteFile(WebappDirectoryManager.getBaseWebappDirectory(mContext));
FileUtils.recursivelyDeleteFile(mWebappDirectoryManager.getBaseWebappDirectory(mContext));
deleteDirectoryAndRecreate(mContext.getCodeCacheDir());
}
......@@ -75,7 +96,7 @@ public class WebappDirectoryManagerTest {
public void tearDown() {
FileUtils.recursivelyDeleteFile(mContext.getDataDir());
FileUtils.recursivelyDeleteFile(mContext.getCodeCacheDir());
FileUtils.recursivelyDeleteFile(WebappDirectoryManager.getBaseWebappDirectory(mContext));
FileUtils.recursivelyDeleteFile(mWebappDirectoryManager.getBaseWebappDirectory(mContext));
FileUtils.recursivelyDeleteFile(WebappDirectoryManager.getWebApkUpdateDirectory());
ThreadUtils.setThreadAssertsDisabledForTesting(false);
}
......@@ -91,25 +112,101 @@ public class WebappDirectoryManagerTest {
@Test
@Feature({"Webapps"})
public void testDeletesObsoleteDirectories() {
public void testDeletesOwnDirectory() throws Exception {
File webappDirectory =
new File(mWebappDirectoryManager.getBaseWebappDirectory(mContext), WEBAPP_ID_1);
Assert.assertTrue(webappDirectory.mkdirs());
Assert.assertTrue(webappDirectory.exists());
// Confirm that it deletes the current web app's directory.
runCleanup();
Assert.assertFalse(webappDirectory.exists());
}
/**
* On Lollipop and higher, the {@link WebappDirectoryManager} also deletes directories for web
* apps that no longer correspond to tasks in Recents.
*/
@Test
@Feature({"Webapps"})
public void testDeletesDirectoriesForDeadTasks() throws Exception {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
// Track the three web app directories.
File directory1 =
new File(mWebappDirectoryManager.getBaseWebappDirectory(mContext), WEBAPP_ID_1);
File directory2 =
new File(mWebappDirectoryManager.getBaseWebappDirectory(mContext), WEBAPP_ID_2);
File directory3 =
new File(mWebappDirectoryManager.getBaseWebappDirectory(mContext), WEBAPP_ID_3);
// Seed the directory with folders for web apps.
Assert.assertTrue(directory1.mkdirs());
Assert.assertTrue(directory2.mkdirs());
Assert.assertTrue(directory3.mkdirs());
// Indicate that another of the web apps is listed in Recents; in real usage this web app
// would not be in the foreground and would have persisted its state.
mWebappDirectoryManager.mBaseIntents = new HashSet<Intent>();
mWebappDirectoryManager.mBaseIntents.add(
new Intent(Intent.ACTION_VIEW, Uri.parse("webapp://webapp_2")));
// Only the directory for the background web app should survive.
runCleanup();
Assert.assertFalse(directory1.exists());
Assert.assertTrue(directory2.exists());
Assert.assertFalse(directory3.exists());
}
/**
* On Lollipop and higher, the {@link WebappDirectoryManager} also deletes directories for
* *WebApks* that are no longer installed.
*/
@Test
@Feature({"Webapps"})
public void testDeletesDirectoriesForUninstalledWebApks() throws Exception {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
WebApkTestHelper.registerWebApkWithMetaData(WEBAPK_PACKAGE_NAME_2, new Bundle(), null);
// Track the three web app directories.
File directory1 =
new File(mWebappDirectoryManager.getBaseWebappDirectory(mContext), WEBAPK_ID_1);
File directory2 =
new File(mWebappDirectoryManager.getBaseWebappDirectory(mContext), WEBAPK_ID_2);
File directory3 =
new File(mWebappDirectoryManager.getBaseWebappDirectory(mContext), WEBAPK_ID_3);
// Seed the directory with folders for web apps.
Assert.assertTrue(directory1.mkdirs());
Assert.assertTrue(directory2.mkdirs());
Assert.assertTrue(directory3.mkdirs());
// Only the directory for the still installed WebAPK should survive.
runCleanup();
Assert.assertFalse(directory1.exists());
Assert.assertTrue(directory2.exists());
Assert.assertFalse(directory3.exists());
}
@Test
@Feature({"Webapps"})
public void testDeletesObsoleteDirectories() throws Exception {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
// Seed the base directory with folders that correspond to pre-L web apps.
File baseDirectory = mContext.getDataDir();
File webappDirectory = new File(baseDirectory, "app_WebappActivity");
File webappDirectory1 = new File(baseDirectory, "app_WebappActivity1");
File webappDirectory6 = new File(baseDirectory, "app_WebappActivity6");
File nonWebappDirectory = new File(baseDirectory, "app_ChromeDocumentActivity");
Assert.assertTrue(webappDirectory.mkdirs());
Assert.assertTrue(webappDirectory1.mkdirs());
Assert.assertTrue(webappDirectory6.mkdirs());
Assert.assertTrue(nonWebappDirectory.mkdirs());
// Make sure only the web app folders are deleted.
runCleanup();
Assert.assertFalse(webappDirectory.exists());
Assert.assertTrue(nonWebappDirectory.exists());
Assert.assertTrue(webappDirectory.mkdirs());
// Make sure the second cleanup call no-ops.
runCleanup();
Assert.assertTrue(webappDirectory.exists());
Assert.assertFalse(webappDirectory1.exists());
Assert.assertFalse(webappDirectory6.exists());
Assert.assertTrue(nonWebappDirectory.exists());
}
......@@ -119,7 +216,7 @@ public class WebappDirectoryManagerTest {
*/
@Test
@Feature({"Webapps"})
public void testCountsUpdateFilesForUninstalledWebApks() {
public void testCountsUpdateFilesForUninstalledWebApks() throws Exception {
File directory1 = new File(WebappDirectoryManager.getWebApkUpdateDirectory(), WEBAPK_ID_1);
directory1.mkdirs();
File directory2 = new File(WebappDirectoryManager.getWebApkUpdateDirectory(), WEBAPK_ID_2);
......@@ -140,7 +237,7 @@ public class WebappDirectoryManagerTest {
*/
@Test
@Feature({"Webapps"})
public void testCountsOldWebApkUpdateFiles() {
public void testCountsOldWebApkUpdateFiles() throws Exception {
File directory = new File(WebappDirectoryManager.getWebApkUpdateDirectory(), WEBAPK_ID_1);
directory.mkdirs();
registerWebapp(WEBAPK_ID_1);
......@@ -161,7 +258,7 @@ public class WebappDirectoryManagerTest {
*/
@Test
@Feature({"Webapps"})
public void testDoesNotCountFilesForNewlyScheduledUpdates() {
public void testDoesNotCountFilesForNewlyScheduledUpdates() throws Exception {
File directory = new File(WebappDirectoryManager.getWebApkUpdateDirectory(), WEBAPK_ID_1);
directory.mkdirs();
registerWebapp(WEBAPK_ID_1);
......@@ -175,8 +272,8 @@ public class WebappDirectoryManagerTest {
"WebApk.Update.NumStaleUpdateRequestFiles", 1));
}
private void runCleanup() {
WebappDirectoryManager.cleanUpDirectories();
private void runCleanup() throws Exception {
mWebappDirectoryManager.cleanUpDirectories(mContext, WEBAPP_ID_1);
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment