Fix attribute names in generated permissions.xml

Previously it would write min_device_sdk whereas the correct name should
be min-device-sdk. This happened for all shared libs attributes.

Test: m nothing
Test: manually installed an apex with a shared lib and made sure PM used
the attributes as expected

Bug: 191978330

Change-Id: Iecf7edd6bae98c7af908d3f320f10ae4973d0396
Merged-In: Iecf7edd6bae98c7af908d3f320f10ae4973d0396
(cherry picked from commit bde653e5fd)
This commit is contained in:
Pedro Loureiro
2021-10-29 09:32:32 +00:00
committed by satayev
parent c362142438
commit ba6682fabf
2 changed files with 14 additions and 13 deletions

View File

@@ -2522,7 +2522,8 @@ func formattedOptionalSdkLevelAttribute(ctx android.ModuleContext, attrName stri
}
apiLevel, err := android.ApiLevelFromUser(ctx, *value)
if err != nil {
ctx.PropertyErrorf(attrName, err.Error())
// attributes in bp files have underscores but in the xml have dashes.
ctx.PropertyErrorf(strings.ReplaceAll(attrName, "-", "_"), err.Error())
return ""
}
intStr := strconv.Itoa(apiLevel.FinalOrPreviewInt())
@@ -2543,10 +2544,10 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri
libNameAttr := formattedOptionalAttribute("name", &libName)
filePath := module.implPath(ctx)
filePathAttr := formattedOptionalAttribute("file", &filePath)
implicitFromAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_since", module.properties.On_bootclasspath_since)
implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_before", module.properties.On_bootclasspath_before)
minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min_device_sdk", module.properties.Min_device_sdk)
maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max_device_sdk", module.properties.Max_device_sdk)
implicitFromAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-since", module.properties.On_bootclasspath_since)
implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-before", module.properties.On_bootclasspath_before)
minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min-device-sdk", module.properties.Min_device_sdk)
maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max-device-sdk", module.properties.Max_device_sdk)
// <library> is understood in all android versions whereas <updatable-library> is only understood from API T (and ignored before that).
// similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the updatable-library to make sure this library is not loaded before T
var libraryTag string