Error on duplicate resource with same disabled flag

Also realized I hadn't handled flag negation so added that as well.

Test: Automated
Bug: 329436914
Flag: EXEMPT Aconfig not supported on host tools
Change-Id: If90ae71070306f8e0c367be7e652da9c7bd0bb22
diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h
index a1b1839..e000c65 100644
--- a/tools/aapt2/ResourceValues.h
+++ b/tools/aapt2/ResourceValues.h
@@ -65,10 +65,21 @@
     return translatable_;
   }
 
+  void SetFlag(std::optional<FeatureFlagAttribute> val) {
+    flag_ = val;
+  }
+
+  std::optional<FeatureFlagAttribute> GetFlag() const {
+    return flag_;
+  }
+
   void SetFlagStatus(FlagStatus val) {
     flag_status_ = val;
   }
 
+  // If the value is behind a flag this returns whether that flag was enabled when the value was
+  // parsed by comparing it to the flags passed on the command line to aapt2 (taking into account
+  // negation if necessary). If there was no flag, FlagStatus::NoFlag is returned instead.
   FlagStatus GetFlagStatus() const {
     return flag_status_;
   }
@@ -128,6 +139,7 @@
   std::string comment_;
   bool weak_ = false;
   bool translatable_ = true;
+  std::optional<FeatureFlagAttribute> flag_;
   FlagStatus flag_status_ = FlagStatus::NoFlag;
 
  private: