Commit f106a4c8 authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

Remove WebApk.LaunchInterval2 histogram

Removing the histogram because we have historically not looked at it
and we now have UKM which will give us more accurate data

BUG=1042133

Change-Id: Ib8d05040b017586bd7ef653d505d9d6e0a8e4dd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001853
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarGlenn Hartmann <hartmanng@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732576}
parent d1e87aab
......@@ -117,14 +117,6 @@ public class WebApkActivity extends WebappActivity {
});
}
@Override
protected void onUpdatedLastUsedTime(
WebappDataStorage storage, boolean previouslyLaunched, long previousUsageTimestamp) {
if (previouslyLaunched) {
WebApkUma.recordLaunchInterval(storage.getLastUsedTimeMs() - previousUsageTimestamp);
}
}
@Override
public void onPauseWithNative() {
WebApkInfo info = getWebApkInfo();
......
......@@ -490,26 +490,13 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen
// app is not directly launched from the home screen, as this interferes
// with the heuristic.
if (mWebappInfo.isLaunchedFromHomescreen()) {
boolean previouslyLaunched = storage.hasBeenLaunched();
long previousUsageTimestamp = storage.getLastUsedTimeMs();
storage.setHasBeenLaunched();
// TODO(yusufo): WebappRegistry#unregisterOldWebapps uses this information to delete
// WebappDataStorage objects for legacy webapps which haven't been used in a while.
// That will need to be updated to not delete anything for a TWA which remains installed
storage.updateLastUsedTime();
onUpdatedLastUsedTime(storage, previouslyLaunched, previousUsageTimestamp);
}
}
/**
* Called after updating the last used time in {@link WebappDataStorage}.
* @param previouslyLaunched Whether the webapp has been previously launched from the home
* screen.
* @param previousUsageTimestamp The previous time that the webapp was used.
*/
protected void onUpdatedLastUsedTime(
WebappDataStorage storage, boolean previouslyLaunched, long previousUsageTimestamp) {}
protected CustomTabTabObserver createTabObserver() {
return new CustomTabTabObserver() {
@Override
......
......@@ -38,7 +38,6 @@ public class WebappDataStorage {
static final String SHARED_PREFS_FILE_PREFIX = "webapp_";
static final String KEY_SPLASH_ICON = "splash_icon";
static final String KEY_LAST_USED = "last_used";
static final String KEY_HAS_BEEN_LAUNCHED = "has_been_launched";
static final String KEY_URL = "url";
static final String KEY_SCOPE = "scope";
static final String KEY_ICON = "icon";
......@@ -317,7 +316,6 @@ public class WebappDataStorage {
SharedPreferences.Editor editor = mPreferences.edit();
editor.remove(KEY_LAST_USED);
editor.remove(KEY_HAS_BEEN_LAUNCHED);
editor.remove(KEY_URL);
editor.remove(KEY_SCOPE);
editor.remove(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME);
......@@ -394,16 +392,6 @@ public class WebappDataStorage {
mPreferences.edit().putLong(KEY_LAST_USED, sClock.currentTimeMillis()).apply();
}
/** Returns true if the web app has been launched at least once from the home screen. */
boolean hasBeenLaunched() {
return mPreferences.getBoolean(KEY_HAS_BEEN_LAUNCHED, false);
}
/** Sets whether the web app was launched at least once from the home screen. */
void setHasBeenLaunched() {
mPreferences.edit().putBoolean(KEY_HAS_BEEN_LAUNCHED, true).apply();
}
/**
* Returns the package name if the data is for a WebAPK, null otherwise.
*/
......
......@@ -19,13 +19,11 @@ import org.junit.runner.RunWith;
import org.chromium.base.ActivityState;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.DeferredStartupHandler;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider;
import org.chromium.chrome.browser.tab.TabTestUtils;
......@@ -37,8 +35,6 @@ import org.chromium.chrome.test.util.ApplicationTestUtils;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.browser.webapps.WebApkInfoBuilder;
import org.chromium.content_public.browser.test.NativeLibraryTestRule;
import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.JavaScriptUtils;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.webapk.lib.common.WebApkConstants;
......@@ -138,62 +134,6 @@ public final class WebApkActivityTest {
ChromeTabUtils.waitForTabPageLoaded(customTabActivity.getActivityTab(), inScopeUrl);
}
/**
* Test that on first launch:
* - the "WebApk.LaunchInterval" histogram is not recorded (because there is no previous launch
* to compute the interval from).
* - the "last used" time is updated (to compute future "launch intervals").
*/
@Test
@LargeTest
@Feature({"WebApk"})
public void testLaunchIntervalHistogramNotRecordedOnFirstLaunch() {
final String histogramName = "WebApk.LaunchInterval";
WebApkActivity webApkActivity = mActivityTestRule.startWebApkActivity(createWebApkInfo(
getTestServerUrl("manifest_test_page.html"), getTestServerUrl("/")));
CriteriaHelper.pollUiThread(new Criteria("Deferred startup never completed") {
@Override
public boolean isSatisfied() {
return DeferredStartupHandler.getInstance().isDeferredStartupCompleteForApp()
&& WebappRegistry.getInstance().getWebappDataStorage(TEST_WEBAPK_ID)
!= null;
}
});
Assert.assertEquals(0, RecordHistogram.getHistogramTotalCountForTesting(histogramName));
WebappDataStorage storage =
WebappRegistry.getInstance().getWebappDataStorage(TEST_WEBAPK_ID);
Assert.assertNotEquals(WebappDataStorage.TIMESTAMP_INVALID, storage.getLastUsedTimeMs());
}
/** Test that the "WebApk.LaunchInterval" histogram is recorded on susbequent launches. */
@Test
@LargeTest
@Feature({"WebApk"})
public void testLaunchIntervalHistogramRecordedOnSecondLaunch() throws Exception {
mNativeLibraryTestRule.loadNativeLibraryNoBrowserProcess();
final String histogramName = "WebApk.LaunchInterval2";
final String packageName = "org.chromium.webapk.test";
WebappDataStorage storage = registerWithStorage(TEST_WEBAPK_ID);
storage.setHasBeenLaunched();
storage.updateLastUsedTime();
Assert.assertEquals(0, RecordHistogram.getHistogramTotalCountForTesting(histogramName));
WebApkActivity webApkActivity = mActivityTestRule.startWebApkActivity(createWebApkInfo(
getTestServerUrl("manifest_test_page.html"), getTestServerUrl("/")));
CriteriaHelper.pollUiThread(new Criteria("Deferred startup never completed") {
@Override
public boolean isSatisfied() {
return DeferredStartupHandler.getInstance().isDeferredStartupCompleteForApp();
}
});
Assert.assertEquals(1, RecordHistogram.getHistogramTotalCountForTesting(histogramName));
}
/**
* Test the L+ logic in {@link TabWebContentsDelegateAndroid#activateContents} for bringing
* WebAPK to the foreground.
......
......@@ -26,7 +26,6 @@ import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.DeferredStartupHandler;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.document.ChromeIntentUtil;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
......@@ -284,30 +283,6 @@ public class WebappModeTest {
Assert.assertTrue(lastWebappActivity.getWebappInfo().url().equals(WEBAPP_2_URL));
}
/** Test that on first launch {@link WebappDataStorage#hasBeenLaunched()} is set. */
// Flaky even with RetryOnFailure: http://crbug.com/749375
@DisabledTest
@Test
// @MediumTest
// @Feature({"Webapps"})
public void testSetsHasBeenLaunchedOnFirstLaunch() {
WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataStorage(WEBAPP_1_ID);
Assert.assertFalse(storage.hasBeenLaunched());
startWebappActivity(WEBAPP_1_ID, WEBAPP_1_URL, WEBAPP_1_TITLE, WEBAPP_ICON);
// Use a longer timeout because the DeferredStartupHandler is called after the page has
// finished loading.
CriteriaHelper.pollUiThread(new Criteria("Deferred startup never completed") {
@Override
public boolean isSatisfied() {
return DeferredStartupHandler.getInstance().isDeferredStartupCompleteForApp();
}
}, 5000L, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
Assert.assertTrue(storage.hasBeenLaunched());
}
/**
* Starts a WebappActivity for the given data and waits for it to be initialized. We can't use
* ActivityUtils.waitForActivity() because of the way WebappActivity is instanced on pre-L
......
......@@ -166165,6 +166165,9 @@ regressions. -->
</histogram>
<histogram name="WebApk.LaunchInterval2" units="minutes" expires_after="M81">
<obsolete>
Removed 2020-01.
</obsolete>
<owner>hanxi@chromium.org</owner>
<owner>pkotwicz@chromium.org</owner>
<owner>yfriedman@chromium.org</owner>
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