Add genrule to fetch latest public/system api.txt

Bug: b/78034256
Test: m clean && m checkapi

Change-Id: I301eb9f6eae3069b8e23b5638b26707d28926bc8
diff --git a/Android.bp b/Android.bp
index 626fb4d..728f4fa 100644
--- a/Android.bp
+++ b/Android.bp
@@ -14,3 +14,25 @@
         "current/support-api.txt",
     ],
 }
+
+genrule {
+    name: "last-released-public-api",
+    srcs: [
+        "*/public/api/android.txt",
+    ],
+    cmd: "cp -f $$(echo $(in) | tr \" \" \"\\n\" | sort -n | tail -1) $(genDir)/last-released-api.txt",
+    out: [
+        "last-released-api.txt",
+    ],
+}
+
+genrule {
+    name: "last-released-system-api",
+    srcs: [
+        "*/system/api/android.txt",
+    ],
+    cmd: "cp -f $$(echo $(in) | tr \" \" \"\\n\" | sort -n | tail -1) $(genDir)/last-released-api.txt",
+    out: [
+        "last-released-api.txt",
+    ],
+}