[Android WebAPK] Clear cached data when identity service selects different host
This CL fixes IdentityService#getRuntimeHostBrowserPackageName(). In some
scenarios (like the default browser supporting WebAPKs for an unbound WebAPK),
calling HostBrowserUtils#getHostBrowserPackageName() updates the host browser
in shared preferences. This CL changes the call so that when the
IdentityService changes the host browser in Shared Preferences the identity
service also clears that WebAPK's shared preferences and data directory.
This CL:
- Splits HostBrowserUtils#getHostBrowserPackageName() into 2 functions:
HostBrowserUtils#getCachedHostBrowserPackage()
which returns the host browser cached in shared preferences if it is still
installed. HostBrowserUtils#getCachedHostBrowserPackage() does not update any
state.
HostBrowserUtils#computeHostBrowserPackageClearCachedDataOnChange()
which computes the new host browser. If the computed host browser is
different than the cached host browser in shared preferences, the WebAPK's
shared preferences and data directory are cleared.
- Reduces the number of functions with hidden calls to
HostBrowserUtils#getHostBrowserPackageName().
HostBrowserUtils#getHostBrowserContext() and
HostBrowserUtils#getHostBrowserUid() are changed to take a package name
parameter and are moved to WebApkUtils.
BUG=900464
TEST=HostBrowserUtilsTest.*
Change-Id: Ie6dea7de5eaca770d8a1261c2742308bc1165419
Reviewed-on: https://chromium-review.googlesource.com/c/1310569
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by:
Xi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608834}
Showing
This diff is collapsed.
Please register or sign in to comment