Reorder styleable attributes in shared libraries

This is a similar fix to
https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/base/+/10109386
but deals with styleable attributes instead of style items.

Bug: 147674078
Test: JavaClassGeneratorTest.SortsDynamicAttributesAfterFrameworkAttributes
Change-Id: Ida6572cf07e2b5987e9d8941cf169a37c43578c4
diff --git a/tools/aapt2/java/JavaClassGenerator.cpp b/tools/aapt2/java/JavaClassGenerator.cpp
index bb541fe..0869c57 100644
--- a/tools/aapt2/java/JavaClassGenerator.cpp
+++ b/tools/aapt2/java/JavaClassGenerator.cpp
@@ -218,13 +218,10 @@
 static bool operator<(const StyleableAttr& lhs, const StyleableAttr& rhs) {
   const ResourceId lhs_id = lhs.attr_ref->id.value_or_default(ResourceId(0));
   const ResourceId rhs_id = rhs.attr_ref->id.value_or_default(ResourceId(0));
-  if (lhs_id < rhs_id) {
-    return true;
-  } else if (lhs_id > rhs_id) {
-    return false;
-  } else {
+  if (lhs_id == rhs_id) {
     return lhs.attr_ref->name.value() < rhs.attr_ref->name.value();
   }
+  return cmp_ids_dynamic_after_framework(lhs_id, rhs_id);
 }
 
 void JavaClassGenerator::ProcessStyleable(const ResourceNameRef& name, const ResourceId& id,