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

Commit 48c24cf1 authored by Mårten Kongstad's avatar Mårten Kongstad Committed by Todd Kennedy
Browse files

Add support for /odm/overlay

Add support for runtime resource overlay (RRO) APKs in /odm/overlay.

Bug: 121033532
Test: manual (adb push apk to /odm/overlay, reboot, cmd overlay list)
Change-Id: I0918d276dfa6a43054068d3f84ecd0d1639f1d0b
parent d5c80f29
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -687,6 +687,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_ALLOW_EXTERNAL_STORAGE_SANDBOX = 1 << 29;

    /**
     * Value for {@link #privateFlags}: whether this app is pre-installed on the
     * ODM partition of the system image.
     * @hide
     */
    public static final int PRIVATE_FLAG_ODM = 1 << 30;

    /** @hide */
    @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
            PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
@@ -717,6 +724,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
            PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE,
            PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE,
            PRIVATE_FLAG_ALLOW_EXTERNAL_STORAGE_SANDBOX,
            PRIVATE_FLAG_ODM,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ApplicationInfoPrivateFlags {}
@@ -1969,6 +1977,11 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
    }

    /** @hide */
    public boolean isOdm() {
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ODM) != 0;
    }

    /** @hide */
    public boolean isPartiallyDirectBootAware() {
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
+5 −0
Original line number Diff line number Diff line
@@ -6919,6 +6919,11 @@ public class PackageParser {
            return applicationInfo.isProductServices();
        }

        /** @hide */
        public boolean isOdm() {
            return applicationInfo.isOdm();
        }

        /** @hide */
        public boolean isPrivileged() {
            return applicationInfo.isPrivilegedApp();
+9 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ static void NativeVerifySystemIdmaps(JNIEnv* /*env*/, jclass /*clazz*/) {
      }

      // Generic idmap parameters
      const char* argv[8];
      const char* argv[9];
      int argc = 0;
      struct stat st;

@@ -199,6 +199,10 @@ static void NativeVerifySystemIdmaps(JNIEnv* /*env*/, jclass /*clazz*/) {
        argv[argc++] = AssetManager::PRODUCT_SERVICES_OVERLAY_DIR;
      }

      if (stat(AssetManager::ODM_OVERLAY_DIR, &st) == 0) {
        argv[argc++] = AssetManager::ODM_OVERLAY_DIR;
      }

      // Finally, invoke idmap (if any overlay directory exists)
      if (argc > 5) {
        execv(AssetManager::IDMAP_BIN, (char* const*)argv);
@@ -233,6 +237,10 @@ static jobjectArray NativeCreateIdmapsForStaticOverlaysTargetingAndroid(JNIEnv*
    input_dirs.push_back(AssetManager::PRODUCT_SERVICES_OVERLAY_DIR);
  }

  if (stat(AssetManager::ODM_OVERLAY_DIR, &st) == 0) {
    input_dirs.push_back(AssetManager::ODM_OVERLAY_DIR);
  }

  if (input_dirs.empty()) {
    LOG(WARNING) << "no directories for idmap2 to scan";
    return env->NewObjectArray(0, g_stringClass, nullptr);
+5 −1
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ bool FileDescriptorWhitelist::IsAllowed(const std::string& path) const {
  static const char* kProductOverlayDir = "/product/overlay";
  static const char* kSystemProductServicesOverlayDir = "/system/product_services/overlay/";
  static const char* kProductServicesOverlayDir = "/product_services/overlay";
  static const char* kSystemOdmOverlayDir = "/system/odm/overlay";
  static const char* kOdmOverlayDir = "/odm/overlay";
  static const char* kApkSuffix = ".apk";

  if ((android::base::StartsWith(path, kOverlayDir)
@@ -110,7 +112,9 @@ bool FileDescriptorWhitelist::IsAllowed(const std::string& path) const {
       || android::base::StartsWith(path, kSystemProductOverlayDir)
       || android::base::StartsWith(path, kProductOverlayDir)
       || android::base::StartsWith(path, kSystemProductServicesOverlayDir)
       || android::base::StartsWith(path, kProductServicesOverlayDir))
       || android::base::StartsWith(path, kProductServicesOverlayDir)
       || android::base::StartsWith(path, kSystemOdmOverlayDir)
       || android::base::StartsWith(path, kOdmOverlayDir))
      && android::base::EndsWith(path, kApkSuffix)
      && path.find("/../") == std::string::npos) {
    return true;
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ const char* AssetManager::IDMAP_BIN = "/system/bin/idmap";
const char* AssetManager::VENDOR_OVERLAY_DIR = "/vendor/overlay";
const char* AssetManager::PRODUCT_OVERLAY_DIR = "/product/overlay";
const char* AssetManager::PRODUCT_SERVICES_OVERLAY_DIR = "/product_services/overlay";
const char* AssetManager::ODM_OVERLAY_DIR = "/odm/overlay";
const char* AssetManager::OVERLAY_THEME_DIR_PROPERTY = "ro.boot.vendor.overlay.theme";
const char* AssetManager::TARGET_PACKAGE_NAME = "android";
const char* AssetManager::TARGET_APK_PATH = "/system/framework/framework-res.apk";
Loading