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

Commit f0719074 authored by Paul Duffin's avatar Paul Duffin
Browse files

Replace use of legacyInitialValue() with constantValue

`FieldItem.legacyInitialValue()` is being removed and replaced with
`FieldItem.constantValue`. This change updates the systemfeatures
tool to use the latter.

Note: The checks for `isStatic()` and `isFinal()` were removed as
`constantValue` is only non-null on `static final` fields anyway.

Flag: EXEMPT updating new build tool
Bug: 354633349
Test: ./gradlew
Change-Id: I949de20d59526c2f3b45d7f1c4d9df8d15b2f51c
parent 6e9da31e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemfeatures

import com.android.tools.metalava.model.text.ApiFile
import com.android.tools.metalava.model.value.asString
import com.squareup.javapoet.ClassName
import com.squareup.javapoet.JavaFile
import com.squareup.javapoet.MethodSpec
@@ -106,11 +107,9 @@ object SystemFeaturesLookupGenerator {
            ?.fields()
            ?.filter { field ->
                field.type().isString() &&
                    field.modifiers.isStatic() &&
                    field.modifiers.isFinal() &&
                    field.name().startsWith("FEATURE_") &&
                    field.legacyInitialValue() != null
                    field.constantValue != null
            }
            ?.associateBy({ it.legacyInitialValue()!!.toString() }, { it.name() }) ?: emptyMap()
            ?.associateBy({ it.constantValue?.asString()!! }, { it.name() }) ?: emptyMap()
    }
}