Commit 743d97bb authored by Calder Kitagawa's avatar Calder Kitagawa Committed by Commit Bot

[WebAPKs] Larger Splash Icon: Remainder of client side changes

This constitutes the remainder of the changes required for the
client to show a larger splash screen icon. The server still needs
a few more changes before the larger icons can be shipped but this
gets the client to a point where the larger icons can be used.

Updates will occur automatically when the new Shell APK version is
pushed. Otherwise apps will continue to use the small icons.
Because larger splash icons are just app icons, all that is needed
to trigger an update is changing the icons in the WebappManifest to
update the splash screen icons.

Tested on mdpi, hdpi, xhdpi, and xxhdpi devices running L, N, O, P.

There is a known issue on P Beta builds where xxhdpi devices don't
use the large layout due to Bitmap#getWidth() and Bitmap#getHeight()
returning incorrect values for aliased resources. However, this is
not something we can solve in Chrome and requires Android changes.
See b/111687946

Bug: 819755
Change-Id: I033dba20b766f875b6fc3d7515f24636aa5b0d4a
Reviewed-on: https://chromium-review.googlesource.com/1142475Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarXi Han <hanxi@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577248}
parent a966ad97
...@@ -39,6 +39,7 @@ public class WebApkInfo extends WebappInfo { ...@@ -39,6 +39,7 @@ public class WebApkInfo extends WebappInfo {
private static final String TAG = "WebApkInfo"; private static final String TAG = "WebApkInfo";
private Icon mBadgeIcon; private Icon mBadgeIcon;
private Icon mSplashIcon;
private String mApkPackageName; private String mApkPackageName;
private int mShellApkVersion; private int mShellApkVersion;
private String mManifestUrl; private String mManifestUrl;
...@@ -145,9 +146,12 @@ public class WebApkInfo extends WebappInfo { ...@@ -145,9 +146,12 @@ public class WebApkInfo extends WebappInfo {
int badgeIconId = IntentUtils.safeGetInt(bundle, WebApkMetaDataKeys.BADGE_ICON_ID, 0); int badgeIconId = IntentUtils.safeGetInt(bundle, WebApkMetaDataKeys.BADGE_ICON_ID, 0);
Bitmap badgeIcon = decodeBitmapFromDrawable(res, badgeIconId); Bitmap badgeIcon = decodeBitmapFromDrawable(res, badgeIconId);
int splashIconId = IntentUtils.safeGetInt(bundle, WebApkMetaDataKeys.SPLASH_ID, 0);
Bitmap splashIcon = decodeBitmapFromDrawable(res, splashIconId);
return create(WebApkConstants.WEBAPK_ID_PREFIX + webApkPackageName, url, scope, return create(WebApkConstants.WEBAPK_ID_PREFIX + webApkPackageName, url, scope,
new Icon(primaryIcon), new Icon(badgeIcon), name, shortName, displayMode, new Icon(primaryIcon), new Icon(badgeIcon), new Icon(splashIcon), name, shortName,
orientation, source, themeColor, backgroundColor, webApkPackageName, displayMode, orientation, source, themeColor, backgroundColor, webApkPackageName,
shellApkVersion, manifestUrl, manifestStartUrl, iconUrlToMurmur2HashMap, shellApkVersion, manifestUrl, manifestStartUrl, iconUrlToMurmur2HashMap,
forceNavigation); forceNavigation);
} }
...@@ -160,6 +164,7 @@ public class WebApkInfo extends WebappInfo { ...@@ -160,6 +164,7 @@ public class WebApkInfo extends WebappInfo {
* @param scope Scope for the WebAPK. * @param scope Scope for the WebAPK.
* @param primaryIcon Primary icon to show for the WebAPK. * @param primaryIcon Primary icon to show for the WebAPK.
* @param badgeIcon Badge icon to use for notifications. * @param badgeIcon Badge icon to use for notifications.
* @param splashIcon Splash icon to use for the splash screen.
* @param name Name of the WebAPK. * @param name Name of the WebAPK.
* @param shortName The short name of the WebAPK. * @param shortName The short name of the WebAPK.
* @param displayMode Display mode of the WebAPK. * @param displayMode Display mode of the WebAPK.
...@@ -179,9 +184,9 @@ public class WebApkInfo extends WebappInfo { ...@@ -179,9 +184,9 @@ public class WebApkInfo extends WebappInfo {
* WebAPK is already open. * WebAPK is already open.
*/ */
public static WebApkInfo create(String id, String url, String scope, Icon primaryIcon, public static WebApkInfo create(String id, String url, String scope, Icon primaryIcon,
Icon badgeIcon, String name, String shortName, @WebDisplayMode int displayMode, Icon badgeIcon, Icon splashIcon, String name, String shortName,
int orientation, int source, long themeColor, long backgroundColor, @WebDisplayMode int displayMode, int orientation, int source, long themeColor,
String webApkPackageName, int shellApkVersion, String manifestUrl, long backgroundColor, String webApkPackageName, int shellApkVersion, String manifestUrl,
String manifestStartUrl, Map<String, String> iconUrlToMurmur2HashMap, String manifestStartUrl, Map<String, String> iconUrlToMurmur2HashMap,
boolean forceNavigation) { boolean forceNavigation) {
if (id == null || url == null || manifestStartUrl == null || webApkPackageName == null) { if (id == null || url == null || manifestStartUrl == null || webApkPackageName == null) {
...@@ -198,21 +203,23 @@ public class WebApkInfo extends WebappInfo { ...@@ -198,21 +203,23 @@ public class WebApkInfo extends WebappInfo {
scope = ShortcutHelper.getScopeFromUrl(manifestStartUrl); scope = ShortcutHelper.getScopeFromUrl(manifestStartUrl);
} }
return new WebApkInfo(id, url, scope, primaryIcon, badgeIcon, name, shortName, displayMode, return new WebApkInfo(id, url, scope, primaryIcon, badgeIcon, splashIcon, name, shortName,
orientation, source, themeColor, backgroundColor, webApkPackageName, displayMode, orientation, source, themeColor, backgroundColor, webApkPackageName,
shellApkVersion, manifestUrl, manifestStartUrl, iconUrlToMurmur2HashMap, shellApkVersion, manifestUrl, manifestStartUrl, iconUrlToMurmur2HashMap,
forceNavigation); forceNavigation);
} }
protected WebApkInfo(String id, String url, String scope, Icon primaryIcon, Icon badgeIcon, protected WebApkInfo(String id, String url, String scope, Icon primaryIcon, Icon badgeIcon,
String name, String shortName, @WebDisplayMode int displayMode, int orientation, Icon splashIcon, String name, String shortName, @WebDisplayMode int displayMode,
int source, long themeColor, long backgroundColor, String webApkPackageName, int orientation, int source, long themeColor, long backgroundColor,
int shellApkVersion, String manifestUrl, String manifestStartUrl, String webApkPackageName, int shellApkVersion, String manifestUrl,
Map<String, String> iconUrlToMurmur2HashMap, boolean forceNavigation) { String manifestStartUrl, Map<String, String> iconUrlToMurmur2HashMap,
boolean forceNavigation) {
super(id, url, scope, primaryIcon, name, shortName, displayMode, orientation, source, super(id, url, scope, primaryIcon, name, shortName, displayMode, orientation, source,
themeColor, backgroundColor, null /* splash_screen_url */, themeColor, backgroundColor, null /* splash_screen_url */,
false /* isIconGenerated */, forceNavigation); false /* isIconGenerated */, forceNavigation);
mBadgeIcon = badgeIcon; mBadgeIcon = badgeIcon;
mSplashIcon = splashIcon;
mApkPackageName = webApkPackageName; mApkPackageName = webApkPackageName;
mShellApkVersion = shellApkVersion; mShellApkVersion = shellApkVersion;
mManifestUrl = manifestUrl; mManifestUrl = manifestUrl;
...@@ -229,6 +236,13 @@ public class WebApkInfo extends WebappInfo { ...@@ -229,6 +236,13 @@ public class WebApkInfo extends WebappInfo {
return (mBadgeIcon == null) ? null : mBadgeIcon.decoded(); return (mBadgeIcon == null) ? null : mBadgeIcon.decoded();
} }
/**
* Returns the splash icon in Bitmap form.
*/
public Bitmap splashIcon() {
return (mSplashIcon == null) ? null : mSplashIcon.decoded();
}
@Override @Override
public String apkPackageName() { public String apkPackageName() {
return mApkPackageName; return mApkPackageName;
......
...@@ -112,10 +112,11 @@ public class WebApkUpdateDataFetcher extends EmptyTabObserver { ...@@ -112,10 +112,11 @@ public class WebApkUpdateDataFetcher extends EmptyTabObserver {
} }
WebApkInfo info = WebApkInfo.create(mOldInfo.id(), mOldInfo.uri().toString(), scopeUrl, WebApkInfo info = WebApkInfo.create(mOldInfo.id(), mOldInfo.uri().toString(), scopeUrl,
new WebApkInfo.Icon(primaryIconBitmap), new WebApkInfo.Icon(badgeIconBitmap), name, new WebApkInfo.Icon(primaryIconBitmap), new WebApkInfo.Icon(badgeIconBitmap), null,
shortName, displayMode, orientation, mOldInfo.source(), themeColor, backgroundColor, name, shortName, displayMode, orientation, mOldInfo.source(), themeColor,
mOldInfo.apkPackageName(), mOldInfo.shellApkVersion(), mOldInfo.manifestUrl(), backgroundColor, mOldInfo.apkPackageName(), mOldInfo.shellApkVersion(),
manifestStartUrl, iconUrlToMurmur2HashMap, mOldInfo.shouldForceNavigation()); mOldInfo.manifestUrl(), manifestStartUrl, iconUrlToMurmur2HashMap,
mOldInfo.shouldForceNavigation());
mObserver.onGotManifestData(info, primaryIconUrl, badgeIconUrl); mObserver.onGotManifestData(info, primaryIconUrl, badgeIconUrl);
} }
......
...@@ -96,6 +96,11 @@ class WebappSplashScreenController extends EmptyTabObserver { ...@@ -96,6 +96,11 @@ class WebappSplashScreenController extends EmptyTabObserver {
? WebappUma.SplashScreenColorStatus.CUSTOM ? WebappUma.SplashScreenColorStatus.CUSTOM
: WebappUma.SplashScreenColorStatus.DEFAULT); : WebappUma.SplashScreenColorStatus.DEFAULT);
if (activityType == WebappActivity.ActivityType.WEBAPK) {
initializeLayout(webappInfo, backgroundColor, ((WebApkInfo) webappInfo).splashIcon());
return;
}
WebappDataStorage storage = WebappDataStorage storage =
WebappRegistry.getInstance().getWebappDataStorage(webappInfo.id()); WebappRegistry.getInstance().getWebappDataStorage(webappInfo.id());
if (storage == null) { if (storage == null) {
......
...@@ -103,8 +103,8 @@ public class WebApkUpdateDataFetcherTest { ...@@ -103,8 +103,8 @@ public class WebApkUpdateDataFetcherTest {
ThreadUtils.runOnUiThread(new Runnable() { ThreadUtils.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
WebApkInfo oldInfo = WebApkInfo.create("", "", scopeUrl, null, null, null, null, -1, WebApkInfo oldInfo = WebApkInfo.create("", "", scopeUrl, null, null, null, null,
-1, -1, -1, -1, "random.package", -1, manifestUrl, "", null, -1, -1, -1, -1, -1, "random.package", -1, manifestUrl, "",
new HashMap<String, String>(), false /* forceNavigation */); new HashMap<String, String>(), false /* forceNavigation */);
fetcher.start(mTab, oldInfo, observer); fetcher.start(mTab, oldInfo, observer);
} }
......
...@@ -154,7 +154,7 @@ public class WebApkUpdateManagerTest { ...@@ -154,7 +154,7 @@ public class WebApkUpdateManagerTest {
@Override @Override
public void run() { public void run() {
WebApkInfo info = WebApkInfo.create(WEBAPK_ID, "", creationData.scope, null, null, WebApkInfo info = WebApkInfo.create(WEBAPK_ID, "", creationData.scope, null, null,
creationData.name, creationData.shortName, creationData.displayMode, null, creationData.name, creationData.shortName, creationData.displayMode,
creationData.orientation, 0, creationData.themeColor, creationData.orientation, 0, creationData.themeColor,
creationData.backgroundColor, "", WebApkVersion.CURRENT_SHELL_APK_VERSION, creationData.backgroundColor, "", WebApkVersion.CURRENT_SHELL_APK_VERSION,
creationData.manifestUrl, creationData.startUrl, creationData.manifestUrl, creationData.startUrl,
......
...@@ -130,7 +130,7 @@ public class WebappVisibilityTest { ...@@ -130,7 +130,7 @@ public class WebappVisibilityTest {
? WebappInfo.create("", webappStartUrlOrScopeUrl, null, null, null, null, ? WebappInfo.create("", webappStartUrlOrScopeUrl, null, null, null, null,
displayMode, 0, 0, 0, 0, null, false /* isIconGenerated */, displayMode, 0, 0, 0, 0, null, false /* isIconGenerated */,
false /* forceNavigation */) false /* forceNavigation */)
: WebApkInfo.create("", "", webappStartUrlOrScopeUrl, null, null, null, null, : WebApkInfo.create("", "", webappStartUrlOrScopeUrl, null, null, null, null, null,
displayMode, 0, 0, 0, 0, "", 0, null, "", null, displayMode, 0, 0, 0, 0, "", 0, null, "", null,
false /* forceNavigation */); false /* forceNavigation */);
} }
......
...@@ -148,6 +148,7 @@ public class WebApkInfoTest { ...@@ -148,6 +148,7 @@ public class WebApkInfoTest {
Assert.assertEquals(null, info.icon()); Assert.assertEquals(null, info.icon());
Assert.assertEquals(null, info.badgeIcon()); Assert.assertEquals(null, info.badgeIcon());
Assert.assertEquals(null, info.splashIcon());
} }
/** /**
......
...@@ -253,7 +253,7 @@ public class WebApkUpdateManagerUnitTest { ...@@ -253,7 +253,7 @@ public class WebApkUpdateManagerUnitTest {
final String kPackageName = "org.random.webapk"; final String kPackageName = "org.random.webapk";
return WebApkInfo.create(getWebApkId(kPackageName), "", manifestData.scopeUrl, return WebApkInfo.create(getWebApkId(kPackageName), "", manifestData.scopeUrl,
new WebApkInfo.Icon(manifestData.primaryIcon), new WebApkInfo.Icon(manifestData.primaryIcon),
new WebApkInfo.Icon(manifestData.badgeIcon), manifestData.name, new WebApkInfo.Icon(manifestData.badgeIcon), null, manifestData.name,
manifestData.shortName, manifestData.displayMode, manifestData.orientation, -1, manifestData.shortName, manifestData.displayMode, manifestData.orientation, -1,
manifestData.themeColor, manifestData.backgroundColor, kPackageName, -1, manifestData.themeColor, manifestData.backgroundColor, kPackageName, -1,
WEB_MANIFEST_URL, manifestData.startUrl, manifestData.iconUrlToMurmur2HashMap, WEB_MANIFEST_URL, manifestData.startUrl, manifestData.iconUrlToMurmur2HashMap,
......
...@@ -23,6 +23,7 @@ public final class WebApkMetaDataKeys { ...@@ -23,6 +23,7 @@ public final class WebApkMetaDataKeys {
public static final String THEME_COLOR = "org.chromium.webapk.shell_apk.themeColor"; public static final String THEME_COLOR = "org.chromium.webapk.shell_apk.themeColor";
public static final String BACKGROUND_COLOR = "org.chromium.webapk.shell_apk.backgroundColor"; public static final String BACKGROUND_COLOR = "org.chromium.webapk.shell_apk.backgroundColor";
public static final String ICON_ID = "org.chromium.webapk.shell_apk.iconId"; public static final String ICON_ID = "org.chromium.webapk.shell_apk.iconId";
public static final String SPLASH_ID = "org.chromium.webapk.shell_apk.splashId";
public static final String ICON_URLS_AND_ICON_MURMUR2_HASHES = public static final String ICON_URLS_AND_ICON_MURMUR2_HASHES =
"org.chromium.webapk.shell_apk.iconUrlsAndIconMurmur2Hashes"; "org.chromium.webapk.shell_apk.iconUrlsAndIconMurmur2Hashes";
......
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