• Pavel Shmakov's avatar
    Use Context#createPackageContext to work around Samsung's issue with small icons · 798f4740
    Pavel Shmakov authored
    The issue is related to the crashes http://crbug/829367 on Samsung (also, Lenovo
    and Yulong) Marshmallow devices. Because of those crashes we prohibit setting
    small notification icons as Bitmaps.
    
    The icon coming from a web page shown in a TWA comes in a form of a Bitmap, so
    we can't use that. A reasonable fallback would be to use the icon specified by
    its resource id in meta-data for TWAService or by extending TWAService.
    
    Unfortunately, there is a problem with that fallback as well. For M+ the small
    icon has to be from the resources of the app whose context is passed to the
    Notification.Builder constructor. Normally we would use the bitmap decoded (on
    the client's side) from resource id. But then again, on Samsung M we can't set
    that bitmap due to the crashes.
    
    In this CL we create the context of client's app using Context#createForPackage,
    pass that into NotificationBuilder, and that way we can use the icon id.
    
    Since this approach is quite unusual and seems risky, it is used only in the
    cases we're fixing, and protected by a feature flag.
    
    Bug: 864786
    Change-Id: Ia401f56b446e7dcc684697faea77ae2a3a402e67
    Reviewed-on: https://chromium-review.googlesource.com/c/1228075
    Commit-Queue: Pavel Shmakov <pshmakov@chromium.org>
    Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
    Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#608516}
    798f4740
chrome_feature_list.cc 20.3 KB