Merge "Use a presingleton to create hiddenapi singleton paths early"
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 96de755..d43e276 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -19,6 +19,7 @@
 )
 
 func init() {
+	android.RegisterPreSingletonType("pre-hiddenapi", hiddenAPIPreSingletonFactory)
 	android.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory)
 }
 
@@ -43,6 +44,18 @@
 	}).(hiddenAPISingletonPathsStruct)
 }
 
+func hiddenAPIPreSingletonFactory() android.Singleton {
+	return hiddenAPIPreSingleton{}
+}
+
+type hiddenAPIPreSingleton struct{}
+
+// hiddenAPI pre-singleton rules to ensure paths are always generated before
+// makevars
+func (hiddenAPIPreSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+	hiddenAPISingletonPaths(ctx)
+}
+
 func hiddenAPISingletonFactory() android.Singleton {
 	return hiddenAPISingleton{}
 }