Merge "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." into main
diff --git a/core/api/current.txt b/core/api/current.txt
index 04f907a..f4a9bd1 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -13841,6 +13841,7 @@
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
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 1b37092..3671980 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -29,6 +29,7 @@
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.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 @@
}
}
}
+
+ /**
+ * 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.");
+ }
}
diff --git a/core/java/android/content/res/flags.aconfig b/core/java/android/content/res/flags.aconfig
index db81e84..f660770 100644
--- a/core/java/android/content/res/flags.aconfig
+++ b/core/java/android/content/res/flags.aconfig
@@ -40,3 +40,12 @@
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
+}