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

Commit 583ddb98 authored by Adnan Begovic's avatar Adnan Begovic Committed by Sam Mortimer
Browse files

androidfw: Squash of declare and load lineage sdk resource package w/ id

Author: Adnan Begovic <adnan@cyngn.com>
Date:   Mon Jul 6 20:06:36 2015 -0700
    androidfw: Declare and load cmsdk resource package w/ id.
    Change-Id: I63b8f3e4a938896dd21999c5b4470573a1da2e52

Author: Steve Kondik <steve@cyngn.com>
Date:   Wed Aug 31 01:32:13 2016 -0700
    androidfw: Fix CMSDK resource handling on N
     * Consider the CMSDK package identifier in the new dynamic resource
       conditions.
    Change-Id: I3e84d12ac86a6eb1d3407aa64234f80a0e945e70

Change-Id: I383ff3eb35cd8d94bd1aebc5b811948d63da621d
parent 874200fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1012,7 +1012,7 @@ public final class LoadedApk {
        final int N = packageIdentifiers.size();
        for (int i = 0; i < N; i++) {
            final int id = packageIdentifiers.keyAt(i);
            if (id == 0x01 || id == 0x7f) {
            if (id == 0x01 || id == 0x7f || id == 0x3f) {
                continue;
            }

+11 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ static const bool kIsDebug = false;
static const char* kAssetsRoot = "assets";
static const char* kAppZipName = NULL; //"classes.jar";
static const char* kSystemAssets = "framework/framework-res.apk";
static const char* kLineageAssets = "framework/org.lineageos.platform-res.apk";
static const char* kResourceCache = "resource-cache";

static const char* kExcludeExtension = ".EXCLUDE";
@@ -325,7 +326,16 @@ bool AssetManager::addDefaultAssets()
    String8 path(root);
    path.appendPath(kSystemAssets);

    return addAssetPath(path, NULL, false /* appAsLib */, true /* isSystemAsset */);
    bool ret = addAssetPath(path, NULL, false /* appAsLib */, true /* isSystemAsset */);
    if (ret) {
        String8 pathLineage(root);
        pathLineage.appendPath(kLineageAssets);

        if (!addAssetPath(pathLineage, NULL, false /* appAsLib */, false /* isSystemAsset */)) {
            ALOGE("Failed to load Lineage SDK resources!");
        }
    }
    return ret;
}

int32_t AssetManager::nextAssetPath(const int32_t cookie) const
+10 −4
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ namespace android {
#define IDMAP_CURRENT_VERSION   0x00000001

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

static const bool kDebugStringPoolNoisy = false;
@@ -5305,7 +5306,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;
@@ -5326,7 +5328,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;
@@ -5472,7 +5475,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;
@@ -5487,7 +5491,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;
@@ -6591,6 +6596,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
@@ -73,6 +73,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.
@@ -99,6 +100,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;
@@ -133,6 +137,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
@@ -2917,8 +2917,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)));
        }
    }