Refresh icon cache when icon shape path has changed

Bug: 120505990

$ adb shell cmd overlay enable --user 0 com.android.theme.icon.roundedrect
$ adb shell cmd overlay disable --user 0 com.android.theme.icon.roundedrect
$ adb shell cmd overlay enable --user 0 com.android.theme.icon.teardrop
$ adb shell cmd overlay disable --user 0 com.android.theme.icon.teardrop

Change-Id: I06663b9727f7434aae737d39977f1e6cf09bffbf
This commit is contained in:
Hyunyoung Song committed 2019-01-04 11:57:52 -08:00
1 parent e018711aac
commit c55a350da8
5 files changed
+74 -16

No files matched your search

@@ -29,6 +29,7 @@ import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.Utilities.Consumer;
@@ -40,6 +41,8 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener
private static final String TAG = "ConfigMonitor";
private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
private final Point mTmpPoint1 = new Point();
private final Point mTmpPoint2 = new Point();
@@ -72,7 +75,15 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener
mCallback = callback;
// Listen for configuration change
mContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
// Listen for {@link OverlayManager} change
IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED);
filter.addDataScheme("package");
mContext.registerReceiver(this, filter);
// Listen for display manager change
mContext.getSystemService(DisplayManager.class)
.registerDisplayListener(this, new Handler(UiThreadHelper.getBackgroundLooper()));
}
@@ -80,8 +91,14 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener
@Override
public void onReceive(Context context, Intent intent) {
Configuration config = context.getResources().getConfiguration();
// TODO: when overlay manager service encodes more information to the Uri such as category
// of the overlay, only listen to the ones that are of interest to launcher.
if (intent != null && ACTION_OVERLAY_CHANGED.equals(intent.getAction())) {
Log.d(TAG, "Overlay changed.");
notifyChange();
}
if (mFontScale != config.fontScale || mDensity != config.densityDpi) {
Log.d(TAG, "Configuration changed");
Log.d(TAG, "Configuration changed.");
notifyChange();
}
}