Merge "Try-catching getColorHints in wallpapermanager compat." into ub-launcher3-dorval-polish2

This commit is contained in:
TreeHugger Robot 2017-09-06 21:25:54 +00:00 committed by Android (Google) Code Review
commit 9c1607886b
1 changed files with 10 additions and 6 deletions

View File

@ -33,11 +33,15 @@ public class WallpaperManagerCompatVOMR1 extends WallpaperManagerCompat {
private static final String TAG = "WMCompatVOMR1";
private final WallpaperManager mWm;
private final Method mWCColorHintsMethod;
private Method mWCColorHintsMethod;
WallpaperManagerCompatVOMR1(Context context) throws Exception {
mWm = context.getSystemService(WallpaperManager.class);
try {
mWCColorHintsMethod = WallpaperColors.class.getDeclaredMethod("getColorHints");
} catch (Exception exc) {
Log.e(TAG, "getColorHints not available", exc);
}
}
@Nullable
@ -49,12 +53,10 @@ public class WallpaperManagerCompatVOMR1 extends WallpaperManagerCompat {
@Override
public void addOnColorsChangedListener(final OnColorsChangedListenerCompat listener) {
OnColorsChangedListener onChangeListener = new OnColorsChangedListener() {
@Override
public void onColorsChanged(WallpaperColors colors, int which) {
listener.onColorsChanged(convertColorsObject(colors), which);
}
public void onColorsChanged(WallpaperColors colors, int which, int userId) {
onColorsChanged(colors, which);
}
};
mWm.addOnColorsChangedListener(onChangeListener, null);
}
@ -71,7 +73,9 @@ public class WallpaperManagerCompatVOMR1 extends WallpaperManagerCompat {
int tertiaryVal = tertiary != null ? tertiary.toArgb() : 0;
int colorHints = 0;
try {
if (mWCColorHintsMethod != null) {
colorHints = (Integer) mWCColorHintsMethod.invoke(colors);
}
} catch (Exception exc) {
Log.e(TAG, "error calling color hints", exc);
}