Skip to content
Commit edb7c22c authored by James O'Leary's avatar James O'Leary
Browse files

Fix WallpaperPicker not being able to assign colors

- ThemeOverlayController intentionally chooses transparent as the theme
color if there aren't any wallpaper colors (ex. a Live Wallpaper that
doesn't send WallpaperColors objects to WallpaperManagerService)
- Rather than refactor old code, we patched by ensuring any attempts to
use less-than-opaque colors for a theme are replaced by using a default
color (ag/15193364)
- However, WallpaperPicker sends transparent colors when setting a new
theme color
- WallpaperPicker's ColorUtils.toColorString turns a color into a 6
characters hex code when transmitting it to framework via JSON stored in
a setting.
- Six characters can only contain red, green, and blue channels, not
alpha.
- When the six character string is parsed by Integer.parseInt(), the
resulting color has 0 alpha, and the new theme color is rejected in
favor of the default color
- Using Color.parseColor ensures that alpha is correctly set, whether
callers use a 6 or 8 character hex code, and ensuring the input to
Color.parseColor starts with a # sign ensures it will work properly

Test: Add logs to WallpaperPicker, verifying points at which it
manipulates hex codes, ensuring WallpaperPicker is receiving colors
with a full alpha channel and merely losing it upon converting it to
a 6 digit string. Make this patch to framework. Check implementation of
Color.parseColor, ensure we meet its requirements for arguments by
sanitizing inputs from callers (i.e. add a # sign in front). Uninstall
patches wallpaper picker, reverting to system image, and verify theme
colors are assigned properly.
Bug: 193044118

Change-Id: Idcdf5d41ee422d5a1b12cec415da9198b8405a5a
parent 103bec65
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