Convert checkapi and update-api to Soong

By converting the phony generation logic from Make to Soong.

This change also leads to some differences in the dependencies of
`checkapi` and `droidcore` phony targets. `checkapi` and `droidcore`
currently depend on `<droidstubs name>-api-lint` and `checkapi` phony
targets respectively, but this change modifies the behavior by making
`checkapi` and `droidcore` depend on the api lint timestamp and the
checkapi timestamps directly.

Test: diff aninja query of checkapi
Bug: 389719475
Change-Id: I46aa2de03e54b121ac7627c0a752026e65dc6933
diff --git a/java/droidstubs.go b/java/droidstubs.go
index e0c2e63..91be7a4 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -1187,6 +1187,40 @@
 	rule.Build(fmt.Sprintf("metalava_%s", params.stubConfig.stubsType.String()), "metalava merged")
 }
 
+func (d *Droidstubs) setPhonyRules(ctx android.ModuleContext) {
+	if d.apiFile != nil {
+		ctx.Phony(d.Name(), d.apiFile)
+		ctx.Phony(fmt.Sprintf("%s.txt", d.Name()), d.apiFile)
+	}
+	if d.removedApiFile != nil {
+		ctx.Phony(d.Name(), d.removedApiFile)
+		ctx.Phony(fmt.Sprintf("%s.txt", d.Name()), d.removedApiFile)
+	}
+	if d.checkCurrentApiTimestamp != nil {
+		ctx.Phony(fmt.Sprintf("%s-check-current-api", d.Name()), d.checkCurrentApiTimestamp)
+		ctx.Phony("checkapi", d.checkCurrentApiTimestamp)
+		ctx.Phony("droidcore", d.checkCurrentApiTimestamp)
+	}
+	if d.updateCurrentApiTimestamp != nil {
+		ctx.Phony(fmt.Sprintf("%s-update-current-api", d.Name()), d.updateCurrentApiTimestamp)
+		ctx.Phony("update-api", d.updateCurrentApiTimestamp)
+	}
+	if d.checkLastReleasedApiTimestamp != nil {
+		ctx.Phony(fmt.Sprintf("%s-check-last-released-api", d.Name()), d.checkLastReleasedApiTimestamp)
+		ctx.Phony("checkapi", d.checkLastReleasedApiTimestamp)
+		ctx.Phony("droidcore", d.checkLastReleasedApiTimestamp)
+	}
+	if d.apiLintTimestamp != nil {
+		ctx.Phony(fmt.Sprintf("%s-api-lint", d.Name()), d.apiLintTimestamp)
+		ctx.Phony("checkapi", d.apiLintTimestamp)
+		ctx.Phony("droidcore", d.apiLintTimestamp)
+	}
+	if d.checkNullabilityWarningsTimestamp != nil {
+		ctx.Phony(fmt.Sprintf("%s-check-nullability-warnings", d.Name()), d.checkNullabilityWarningsTimestamp)
+		ctx.Phony("droidcore", d.checkNullabilityWarningsTimestamp)
+	}
+}
+
 func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	deps := d.Javadoc.collectDeps(ctx)
 
@@ -1361,6 +1395,8 @@
 	})
 
 	d.setOutputFiles(ctx)
+
+	d.setPhonyRules(ctx)
 }
 
 // This method sets the outputFiles property, which is used to set the