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

Commit dcbd1820 authored by Biswarup Pal's avatar Biswarup Pal Committed by Android (Google) Code Review
Browse files

Merge "Add support for dimensions in FRRO" into main

parents 7da02517 9bb30b25
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -12114,6 +12114,7 @@ package android.content.om {
    method @NonNull public void setResourceValue(@NonNull String, int, @NonNull String, @Nullable String);
    method @NonNull public void setResourceValue(@NonNull String, int, @NonNull String, @Nullable String);
    method @NonNull public void setResourceValue(@NonNull String, @NonNull android.os.ParcelFileDescriptor, @Nullable String);
    method @NonNull public void setResourceValue(@NonNull String, @NonNull android.os.ParcelFileDescriptor, @Nullable String);
    method @FlaggedApi("android.content.res.asset_file_descriptor_frro") @NonNull public void setResourceValue(@NonNull String, @NonNull android.content.res.AssetFileDescriptor, @Nullable String);
    method @FlaggedApi("android.content.res.asset_file_descriptor_frro") @NonNull public void setResourceValue(@NonNull String, @NonNull android.content.res.AssetFileDescriptor, @Nullable String);
    method @FlaggedApi("android.content.res.dimension_frro") public void setResourceValue(@NonNull String, float, int, @Nullable String);
    method public void setTargetOverlayable(@Nullable String);
    method public void setTargetOverlayable(@Nullable String);
  }
  }
+35 −0
Original line number Original line Diff line number Diff line
@@ -476,6 +476,20 @@ public class FabricatedOverlay {
        return entry;
        return entry;
    }
    }


    @NonNull
    private static FabricatedOverlayInternalEntry generateFabricatedOverlayInternalEntry(
            @NonNull String resourceName, float dimensionValue,
            @TypedValue.ComplexDimensionUnit int dimensionUnit, @Nullable String configuration) {
        final FabricatedOverlayInternalEntry entry = new FabricatedOverlayInternalEntry();
        entry.resourceName = resourceName;
        entry.dataType = TypedValue.TYPE_DIMENSION;
        Preconditions.checkArgumentInRange(dimensionUnit,
                TypedValue.COMPLEX_UNIT_PX, TypedValue.COMPLEX_UNIT_MM, "dimensionUnit");
        entry.data = TypedValue.createComplexDimension(dimensionValue, dimensionUnit);
        entry.configuration = configuration;
        return entry;
    }

    /**
    /**
     * Sets the resource value in the fabricated overlay for the integer-like types with the
     * Sets the resource value in the fabricated overlay for the integer-like types with the
     * configuration.
     * configuration.
@@ -586,4 +600,25 @@ public class FabricatedOverlay {
        mOverlay.entries.add(
        mOverlay.entries.add(
                generateFabricatedOverlayInternalEntry(resourceName, value, configuration));
                generateFabricatedOverlayInternalEntry(resourceName, value, configuration));
    }
    }

    /**
     * Sets the resource value in the fabricated overlay for the dimension type with the
     * configuration.
     *
     * @param resourceName name of the target resource to overlay (in the form
     *     [package]:type/entry)
     * @param dimensionValue the float representing the dimension value
     * @param dimensionUnit the integer representing the dimension unit
     * @param configuration The string representation of the config this overlay is enabled for
     */
    @FlaggedApi(android.content.res.Flags.FLAG_DIMENSION_FRRO)
    public void setResourceValue(
            @NonNull String resourceName,
            float dimensionValue,
            @TypedValue.ComplexDimensionUnit int dimensionUnit,
            @Nullable String configuration) {
        ensureValidResourceName(resourceName);
        mOverlay.entries.add(generateFabricatedOverlayInternalEntry(resourceName, dimensionValue,
                dimensionUnit, configuration));
    }
}
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -66,3 +66,11 @@ flag {
    # This flag is read at boot time.
    # This flag is read at boot time.
    is_fixed_read_only: true
    is_fixed_read_only: true
}
}

flag {
    name: "dimension_frro"
    is_exported: true
    namespace: "resource_manager"
    description: "Feature flag for passing a dimension to create an frro"
    bug: "369672322"
}