summaryrefslogtreecommitdiff
path: root/java/hiddenapi.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/hiddenapi.go')
-rw-r--r--java/hiddenapi.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index 04b8fc689..1e838247b 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -43,6 +43,10 @@ type hiddenAPI struct {
// the UnsupportedAppUsage annotation that need to be extracted as part of the hidden API
// processing.
classesJarPaths android.Paths
+
+ // The compressed state of the dex file being encoded. This is used to ensure that the encoded
+ // dex file has the same state.
+ uncompressDexState *bool
}
func (h *hiddenAPI) bootDexJar() android.Path {
@@ -53,6 +57,10 @@ func (h *hiddenAPI) classesJars() android.Paths {
return h.classesJarPaths
}
+func (h *hiddenAPI) uncompressDex() *bool {
+ return h.uncompressDexState
+}
+
// hiddenAPIModule is the interface a module that embeds the hiddenAPI structure must implement.
type hiddenAPIModule interface {
android.Module
@@ -62,12 +70,16 @@ type hiddenAPIModule interface {
type hiddenAPIIntf interface {
bootDexJar() android.Path
classesJars() android.Paths
+ uncompressDex() *bool
}
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
// Initialize the hiddenapi structure
-func (h *hiddenAPI) initHiddenAPI(ctx android.ModuleContext, dexJar, classesJar android.Path) {
+//
+// uncompressedDexState should be nil when the module is a prebuilt and so does not require hidden
+// API encoding.
+func (h *hiddenAPI) initHiddenAPI(ctx android.ModuleContext, dexJar, classesJar android.Path, uncompressedDexState *bool) {
// Save the classes jars even if this is not active as they may be used by modular hidden API
// processing.
@@ -82,6 +94,8 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.ModuleContext, dexJar, classesJar
// hiddenAPISingletonPathsStruct.stubFlags file.
h.bootDexJarPath = dexJar
+ h.uncompressDexState = uncompressedDexState
+
// If hiddenapi processing is disabled treat this as inactive.
if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
return
@@ -119,12 +133,18 @@ func isModuleInBootClassPath(ctx android.BaseModuleContext, module android.Modul
//
// Otherwise, it creates a copy of the supplied dex file into which it has encoded the hiddenapi
// flags and returns this instead of the supplied dex jar.
-func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android.OutputPath, uncompressDex bool) android.OutputPath {
+func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android.OutputPath) android.OutputPath {
if !h.active {
return dexJar
}
+ // A nil uncompressDexState prevents the dex file from being encoded.
+ if h.uncompressDexState == nil {
+ ctx.ModuleErrorf("cannot encode dex file %s when uncompressDexState is nil", dexJar)
+ }
+ uncompressDex := *h.uncompressDexState
+
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", dexJar.Base()).OutputPath
// Create a copy of the dex jar which has been encoded with hiddenapi flags.