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

Commit dfab7ad9 authored by Catherine Liang's avatar Catherine Liang Committed by Android Build Coastguard Worker
Browse files

Flag FRRO changes for Launcher preview color fix (2/3)

Flag changes in the topic:
https://googleplex-android-review.git.corp.google.com/q/topic:%22revert-30159224-revert-29910507-launcher-color-preview-fix-XVTAANIJBS-AWXALNHUNX%22

Even though this is a bug fix, the change needs to be behind a flag
because it involves CTS test changes. CTS test changes can only be
released along with API releases. Instead of a revert, which causes
merge conflicts, fix forward by flagging the changes.

Flag: android.content.res.self_targeting_android_resource_frro
Bug: 381170131
Test: atest OverlayManagerImplTest
Test: atest OverlayManagerTransactionTest
Test: atest ResourcesProviderTest
Test: manually verified with flags on and off
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8f450c864ffaee16879660649ee0017c92d987a7)
Merged-In: I89c0a3bd8089372925b652285093c32fd5fbec3b
Change-Id: I89c0a3bd8089372925b652285093c32fd5fbec3b
parent 64b938c9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -114,3 +114,11 @@ flag {
    bug: "373535266"
    is_fixed_read_only: true
}

flag {
    name: "self_targeting_android_resource_frro"
    is_exported: true
    namespace: "customization_picker"
    description: "Fixes bug in Launcher preview by enabling overlays targeting 'android'"
    bug: "377545987"
}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.om.OverlayManager;
import android.content.pm.ApplicationInfo;
import android.content.res.ApkAssets;
import android.content.res.AssetFileDescriptor;
import android.content.res.Flags;
import android.os.ParcelFileDescriptor;
import android.util.Log;

@@ -90,6 +91,10 @@ public class ResourcesProvider implements AutoCloseable, Closeable {
            throws IOException {
        Objects.requireNonNull(overlayInfo);
        Preconditions.checkArgument(overlayInfo.isFabricated(), "Not accepted overlay");
        if (!Flags.selfTargetingAndroidResourceFrro()) {
            Preconditions.checkStringNotEmpty(
                    overlayInfo.getTargetOverlayableName(), "Without overlayable name");
        }
        final String overlayName =
                OverlayManagerImpl.checkOverlayNameValid(overlayInfo.getOverlayName());
        final String path =
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.appwidget.flags.Flags.FLAG_DRAW_DATA_PARCEL;
import static android.appwidget.flags.Flags.FLAG_REMOTE_VIEWS_PROTO;
import static android.appwidget.flags.Flags.drawDataParcel;
import static android.appwidget.flags.Flags.remoteAdapterConversion;
import static android.content.res.Flags.FLAG_SELF_TARGETING_ANDROID_RESOURCE_FRRO;
import static android.util.TypedValue.TYPE_INT_COLOR_ARGB8;
import static android.util.proto.ProtoInputStream.NO_MORE_FIELDS;
import static android.view.inputmethod.Flags.FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR;
@@ -8698,6 +8699,7 @@ public class RemoteViews implements Parcelable, Filter {
         *
         * @hide
         */
        @FlaggedApi(FLAG_SELF_TARGETING_ANDROID_RESOURCE_FRRO)
        @Nullable
        public static ColorResources createWithOverlay(Context context,
                SparseIntArray colorMapping) {
+11 −3
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.parsing.FrameworkParsingPackageUtils;
import android.content.res.AssetManager;
import android.content.res.Flags;
import android.os.FabricatedOverlayInfo;
import android.os.FabricatedOverlayInternal;
import android.os.FabricatedOverlayInternalEntry;
@@ -235,17 +236,24 @@ public class OverlayManagerImpl {
        Preconditions.checkArgument(!entryList.isEmpty(), "overlay entries shouldn't be empty");
        final String overlayName = checkOverlayNameValid(overlayInternal.overlayName);
        checkPackageName(overlayInternal.packageName);
        if (Flags.selfTargetingAndroidResourceFrro()) {
            Preconditions.checkStringNotEmpty(overlayInternal.targetPackageName);
        } else {
            checkPackageName(overlayInternal.targetPackageName);
            Preconditions.checkStringNotEmpty(
                    overlayInternal.targetOverlayable,
                    "Target overlayable should be neither null nor empty string.");
        }

        final ApplicationInfo applicationInfo = mContext.getApplicationInfo();
        String targetPackage = null;
        if (TextUtils.equals(overlayInternal.targetPackageName, "android")) {
        if (Flags.selfTargetingAndroidResourceFrro() && TextUtils.equals(
                overlayInternal.targetPackageName, "android")) {
            targetPackage = AssetManager.FRAMEWORK_APK_PATH;
        } else {
            targetPackage = Preconditions.checkStringNotEmpty(
                    applicationInfo.getBaseCodePath());
        }

        final Path frroPath = mBasePath.resolve(overlayName + FRRO_EXTENSION);
        final Path idmapPath = mBasePath.resolve(overlayName + IDMAP_EXTENSION);

+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ android_test {
        "androidx.test.ext.junit",
        "mockito-target-minus-junit4",
        "truth",
        "flag-junit",
    ],

    optimize: {
Loading