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

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

AAPT2: optionally keep resources without default value

Teach "aapt2 link" about a new flag --no-resource-removal. When given,
aapt2 will not filter out resources that lack default values. This is
useful mostly when building overlay packages that define resources for
non-default configurations, such as only for values-sv.

Test: manual: build package with resource only in values-vs, verify apk with aapt2 dump
Change-Id: Idc513bcb3f43bbff7f073163562c3dfccdb9bc9b
parent ec5c04f4
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,4 +20,6 @@ LOCAL_PACKAGE_NAME := OverlayDeviceTests_AppOverlayOne
LOCAL_SDK_VERSION := current
LOCAL_SDK_VERSION := current
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_CERTIFICATE := platform
LOCAL_CERTIFICATE := platform
LOCAL_USE_AAPT2 := true
LOCAL_AAPT_FLAGS := --no-resource-removal
include $(BUILD_PACKAGE)
include $(BUILD_PACKAGE)
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,4 +20,6 @@ LOCAL_PACKAGE_NAME := OverlayDeviceTests_AppOverlayTwo
LOCAL_SDK_VERSION := current
LOCAL_SDK_VERSION := current
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_CERTIFICATE := platform
LOCAL_CERTIFICATE := platform
LOCAL_USE_AAPT2 := true
LOCAL_AAPT_FLAGS := --no-resource-removal
include $(BUILD_PACKAGE)
include $(BUILD_PACKAGE)
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,4 +20,6 @@ LOCAL_PACKAGE_NAME := OverlayDeviceTests_FrameworkOverlay
LOCAL_SDK_VERSION := current
LOCAL_SDK_VERSION := current
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_CERTIFICATE := platform
LOCAL_CERTIFICATE := platform
LOCAL_USE_AAPT2 := true
LOCAL_AAPT_FLAGS := --no-resource-removal
include $(BUILD_PACKAGE)
include $(BUILD_PACKAGE)
+2 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,8 @@ LOCAL_PACKAGE_NAME := OverlayHostTests_UpdateOverlay
LOCAL_SDK_VERSION := current
LOCAL_SDK_VERSION := current
LOCAL_COMPATIBILITY_SUITE := general-tests
LOCAL_COMPATIBILITY_SUITE := general-tests
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
LOCAL_USE_AAPT2 := true
LOCAL_AAPT_FLAGS := --no-resource-removal
include $(BUILD_PACKAGE)
include $(BUILD_PACKAGE)


my_package_prefix := com.android.server.om.hosttest.framework_overlay
my_package_prefix := com.android.server.om.hosttest.framework_overlay
+6 −4
Original line number Original line Diff line number Diff line
@@ -1775,11 +1775,13 @@ class Linker {


    // Before we process anything, remove the resources whose default values don't exist.
    // Before we process anything, remove the resources whose default values don't exist.
    // We want to force any references to these to fail the build.
    // We want to force any references to these to fail the build.
    if (!options_.no_resource_removal) {
      if (!NoDefaultResourceRemover{}.Consume(context_, &final_table_)) {
      if (!NoDefaultResourceRemover{}.Consume(context_, &final_table_)) {
        context_->GetDiagnostics()->Error(DiagMessage()
        context_->GetDiagnostics()->Error(DiagMessage()
                                          << "failed removing resources with no defaults");
                                          << "failed removing resources with no defaults");
        return 1;
        return 1;
      }
      }
    }


    ReferenceLinker linker;
    ReferenceLinker linker;
    if (!linker.Consume(context_, &final_table_)) {
    if (!linker.Consume(context_, &final_table_)) {
Loading