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

Commit bfcc40b3 authored by Brandon Liu's avatar Brandon Liu
Browse files

Resources.registerResourcePaths() API and flag.

This API is designed to load the resources and of a shared library
while app is running. It will add these resources to all existing
and future contexts.

Bug: b/306202569
Test: Verified affected tests pass.
Change-Id: I5b86a65907ee0a85c6aa9018f38c25fb472e3f54
parent a4865c33
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13837,6 +13837,7 @@ package android.content.res {
    method public android.content.res.AssetFileDescriptor openRawResourceFd(@RawRes int) throws android.content.res.Resources.NotFoundException;
    method public void parseBundleExtra(String, android.util.AttributeSet, android.os.Bundle) throws org.xmlpull.v1.XmlPullParserException;
    method public void parseBundleExtras(android.content.res.XmlResourceParser, android.os.Bundle) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method @FlaggedApi("android.content.res.register_resource_paths") public static void registerResourcePaths(@NonNull String, @NonNull android.content.pm.ApplicationInfo);
    method public void removeLoaders(@NonNull android.content.res.loader.ResourcesLoader...);
    method @Deprecated public void updateConfiguration(android.content.res.Configuration, android.util.DisplayMetrics);
    field @AnyRes public static final int ID_NULL = 0; // 0x0
+20 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.annotation.ColorRes;
import android.annotation.DimenRes;
import android.annotation.Discouraged;
import android.annotation.DrawableRes;
import android.annotation.FlaggedApi;
import android.annotation.FontRes;
import android.annotation.FractionRes;
import android.annotation.IntegerRes;
@@ -46,6 +47,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo.Config;
import android.content.pm.ApplicationInfo;
import android.content.res.loader.ResourcesLoader;
import android.graphics.Movie;
import android.graphics.Typeface;
@@ -2825,4 +2827,22 @@ public class Resources {
            }
        }
    }

    /**
     * Register the resources paths of a package (e.g. a shared library). This will collect the
     * package resources' paths from its ApplicationInfo and add them to all existing and future
     * contexts while the application is running.
     * A second call with the same uniqueId is a no-op.
     * The paths are not persisted during application restarts. The application is responsible for
     * calling the API again if this happens.
     *
     * @param uniqueId The unique id for the ApplicationInfo object, to detect and ignore repeated
     *                 API calls.
     * @param appInfo The ApplicationInfo that contains resources paths of the package.
     */
    @FlaggedApi(android.content.res.Flags.FLAG_REGISTER_RESOURCE_PATHS)
    public static void registerResourcePaths(@NonNull String uniqueId,
            @NonNull ApplicationInfo appInfo) {
        throw new UnsupportedOperationException("The implementation has not been done yet.");
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -40,3 +40,12 @@ flag {
    description: "Feature flag for creating an frro from a 9-patch"
    bug: "309232726"
}

flag {
    name: "register_resource_paths"
    namespace: "resource_manager"
    description: "Feature flag for register resource paths for shared library"
    bug: "306202569"
    # This flag is read in ResourcesImpl at boot time.
    is_fixed_read_only: true
}