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

Unverified Commit aa4fa513 authored by Adnan Begovic's avatar Adnan Begovic Committed by Michael Bestas
Browse files

androidfw: Declare and load lineage sdk resource package w/ id



Co-authored-by: default avatarEthan Chen <intervigil@gmail.com>
Co-authored-by: default avatarLuca Stefani <luca.stefani.ge1@gmail.com>
Co-authored-by: default avatarSam Mortimer <sam@mortimer.me.uk>
Co-authored-by: default avatarSteve Kondik <steve@cyngn.com>
Change-Id: I383ff3eb35cd8d94bd1aebc5b811948d63da621d
parent e14fdffa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1536,7 +1536,7 @@ public final class LoadedApk {
                        false, false);
                for (int i = 0, n = packageIdentifiers.size(); i < n; i++) {
                    final int id = packageIdentifiers.keyAt(i);
                    if (id == 0x01 || id == 0x7f) {
                    if (id == 0x01 || id == 0x7f || id == 0x3f) {
                        continue;
                    }

+2 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ public final class AssetManager implements AutoCloseable {
    public static final String FRAMEWORK_APK_PATH = getFrameworkApkPath();
    private static final String FRAMEWORK_APK_PATH_DEVICE = "/system/framework/framework-res.apk";
    private static final String FRAMEWORK_APK_PATH_RAVENWOOD = "ravenwood-data/framework-res.apk";
    private static final String LINEAGE_APK_PATH = "/system/framework/org.lineageos.platform-res.apk";

    private static final Object sSync = new Object();

@@ -291,6 +292,7 @@ public final class AssetManager implements AutoCloseable {
            for (String idmapPath : systemIdmapPaths) {
                apkAssets.add(ApkAssets.loadOverlayFromPath(idmapPath, ApkAssets.PROPERTY_SYSTEM));
            }
            apkAssets.add(ApkAssets.loadFromPath(LINEAGE_APK_PATH, ApkAssets.PROPERTY_SYSTEM));

            sSystemApkAssetsSet = new ArraySet<>(apkAssets);
            sSystemApkAssets = apkAssets.toArray(new ApkAssets[0]);
+10 −4
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ namespace android {
#define IDMAP_MAGIC             0x504D4449

#define APP_PACKAGE_ID      0x7f
#define LINEAGESDK_PACKAGE_ID    0x3f
#define SYS_PACKAGE_ID      0x01

static const bool kDebugStringPoolNoisy = false;
@@ -5824,7 +5825,8 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
                }

                uint32_t packageId = Res_GETPACKAGE(rid) + 1;
                if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID) {
                if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID &&
                        packageId != LINEAGESDK_PACKAGE_ID) {
                    outValue->dataType = Res_value::TYPE_DYNAMIC_REFERENCE;
                }
                outValue->data = rid;
@@ -5845,7 +5847,8 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
                        outValue->data = rid;
                        outValue->dataType = Res_value::TYPE_DYNAMIC_REFERENCE;
                        return true;
                    } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID) {
                    } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID ||
                            packageId == LINEAGESDK_PACKAGE_ID) {
                        // We accept packageId's generated as 0x01 in order to support
                        // building the android system resources
                        outValue->data = rid;
@@ -5991,7 +5994,8 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
            }

            uint32_t packageId = Res_GETPACKAGE(rid) + 1;
            if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID) {
            if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID &&
                    packageId != LINEAGESDK_PACKAGE_ID) {
                outValue->dataType = Res_value::TYPE_DYNAMIC_ATTRIBUTE;
            }
            outValue->data = rid;
@@ -6006,7 +6010,8 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
                    outValue->data = rid;
                    outValue->dataType = Res_value::TYPE_DYNAMIC_ATTRIBUTE;
                    return true;
                } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID) {
                } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID ||
                        packageId == LINEAGESDK_PACKAGE_ID) {
                    // We accept packageId's generated as 0x01 in order to support
                    // building the android system resources
                    outValue->data = rid;
@@ -7219,6 +7224,7 @@ DynamicRefTable::DynamicRefTable(uint8_t packageId, bool appAsLib)
    // Reserved package ids
    mLookupTable[APP_PACKAGE_ID] = APP_PACKAGE_ID;
    mLookupTable[SYS_PACKAGE_ID] = SYS_PACKAGE_ID;
    mLookupTable[LINEAGESDK_PACKAGE_ID] = LINEAGESDK_PACKAGE_ID;
}

status_t DynamicRefTable::load(const ResTable_lib_header* const header)
+7 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ class BackTrackingAttributeFinder {

  // Package offsets (best-case, fast look-up).
  Iterator framework_start_;
  Iterator lineage_framework_start_;
  Iterator app_start_;

  // Worst case, we have shared-library resources.
@@ -100,6 +101,9 @@ void BackTrackingAttributeFinder<Derived, Iterator>::JumpToClosestAttribute(
    case 0x01u:
      current_ = framework_start_;
      break;
    case 0x3fu:
      current_ = lineage_framework_start_;
      break;
    case 0x7fu:
      current_ = app_start_;
      break;
@@ -134,6 +138,9 @@ void BackTrackingAttributeFinder<Derived, Iterator>::MarkCurrentPackageId(
    case 0x01u:
      framework_start_ = current_;
      break;
    case 0x3fu:
      lineage_framework_start_ = current_;
      break;
    case 0x7fu:
      app_start_ = current_;
      break;
+3 −2
Original line number Diff line number Diff line
@@ -2894,8 +2894,9 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>&
    for (size_t i = 0; i < basePackageCount; i++) {
        size_t packageId = table.getBasePackageId(i);
        String16 packageName(table.getBasePackageName(i));
        if (packageId > 0x01 && packageId != 0x7f &&
                packageName != String16("android")) {
        if (packageId > 0x01 && packageId != 0x7f && packageId != 0x3f &&
                packageName != String16("android") &&
                packageName != String16("lineageos.platform")) {
            libraryPackages.add(sp<Package>(new Package(packageName, packageId)));
        }
    }