Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
androidfw: Squash of declare and load lineage sdk resource package w/ id
Browse files Browse the repository at this point in the history
Author: Adnan Begovic <[email protected]>
Date:   Mon Jul 6 20:06:36 2015 -0700
    androidfw: Declare and load cmsdk resource package w/ id.
    Change-Id: I63b8f3e4a938896dd21999c5b4470573a1da2e52

Author: Steve Kondik <[email protected]>
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
  • Loading branch information
Adnan Begovic authored and sam3000 committed Feb 10, 2018
1 parent 874200f commit 583ddb9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/java/android/app/LoadedApk.java
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ public Application makeApplication(boolean forceDefaultAppClass,
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;
}

Expand Down
12 changes: 11 additions & 1 deletion libs/androidfw/AssetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions libs/androidfw/ResourceTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions libs/androidfw/include/androidfw/AttributeFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions tools/aapt/ResourceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
Expand Down

0 comments on commit 583ddb9

Please sign in to comment.