Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c836f193 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Move OM calls to the background" into sc-dev

parents df1fcdad 9274be53
Loading
Loading
Loading
Loading
+39 −33
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.systemui.theme;

import android.annotation.AnyThread;
import android.content.om.FabricatedOverlay;
import android.content.om.OverlayIdentifier;
import android.content.om.OverlayInfo;
@@ -159,6 +160,8 @@ public class ThemeOverlayApplier implements Dumpable {
            FabricatedOverlay[] pendingCreation,
            int currentUser,
            Set<UserHandle> managedProfiles) {
        mExecutor.execute(() -> {

            // Disable all overlays that have not been specified in the user setting.
            final Set<String> overlayCategoriesToDisable = new HashSet<>(THEME_CATEGORIES);
            final Set<String> targetPackagesToQuery = overlayCategoriesToDisable.stream()
@@ -169,9 +172,11 @@ public class ThemeOverlayApplier implements Dumpable {
                    .getOverlayInfosForTarget(targetPackage, UserHandle.SYSTEM)));
            final List<Pair<String, String>> overlaysToDisable = overlays.stream()
                    .filter(o ->
                        mTargetPackageToCategories.get(o.targetPackageName).contains(o.category))
                            mTargetPackageToCategories.get(o.targetPackageName).contains(
                                    o.category))
                    .filter(o -> overlayCategoriesToDisable.contains(o.category))
                .filter(o -> !categoryToPackage.containsValue(new OverlayIdentifier(o.packageName)))
                    .filter(o -> !categoryToPackage.containsValue(
                            new OverlayIdentifier(o.packageName)))
                    .filter(o -> o.isEnabled())
                    .map(o -> new Pair<>(o.category, o.packageName))
                    .collect(Collectors.toList());
@@ -192,11 +197,11 @@ public class ThemeOverlayApplier implements Dumpable {
            for (String category : THEME_CATEGORIES) {
                if (categoryToPackage.containsKey(category)) {
                    OverlayIdentifier overlayInfo = categoryToPackage.get(category);
                setEnabled(transaction, overlayInfo, category, currentUser, managedProfiles, true);
                    setEnabled(transaction, overlayInfo, category, currentUser, managedProfiles,
                            true);
                }
            }

        mExecutor.execute(() -> {
            try {
                mOverlayManager.commit(transaction.build());
            } catch (SecurityException | IllegalStateException e) {
@@ -210,6 +215,7 @@ public class ThemeOverlayApplier implements Dumpable {
        return new OverlayManagerTransaction.Builder();
    }

    @AnyThread
    private void setEnabled(OverlayManagerTransaction.Builder transaction,
            OverlayIdentifier identifier, String category, int currentUser,
            Set<UserHandle> managedProfiles, boolean enabled) {