Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac919fcf authored by Ryan Mitchell's avatar Ryan Mitchell Committed by Android (Google) Code Review
Browse files

Merge changes from topic "aapt2-attr" into qt-dev

* changes:
  Add formats for declare-styleable attributes
  No new attributes in declare-styleables when format is not provided
parents e4be3cdb a1c5eae2
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -2380,6 +2380,12 @@
    <!-- ============================= -->
    <eat-comment />

    <!-- Removed View attributes without a specified format (b/131100106) -->
    <attr name="__removed3" />
    <attr name="__removed4" />
    <attr name="__removed5" />
    <attr name="__removed6" />

    <!-- Attributes that can be used with {@link android.view.View} or
         any of its subclasses.  Also see {@link #ViewGroup_Layout} for
         attributes that are processed by the view's parent. -->
@@ -4722,7 +4728,7 @@
        <!-- Style (normal, bold, italic, bold|italic) for the text. -->
        <attr name="textStyle" />
        <!-- Weight for the font used in the TextView. -->
        <attr name="textFontWeight" />
        <attr name="textFontWeight" format="integer"/>
        <!-- Font family (named by string or as a font resource reference) for the text. -->
        <attr name="fontFamily" />
        <!-- Specifies the {@link android.os.LocaleList} for the text in this TextView.
@@ -8018,7 +8024,7 @@
        <attr name="supportsAmbientMode" format="boolean" />

        <!-- Uri that specifies a settings Slice for this wallpaper. -->
        <attr name="settingsSliceUri" />
        <attr name="settingsSliceUri" format="string"/>

        <!-- Indicates that this wallpaper service can support multiple engines to render on each
             surface independently. An example use case is a multi-display set-up where the
@@ -8242,7 +8248,7 @@
        <!-- The activity to launch when the setting is clicked on. -->
        <attr name="settingsActivity"/>
        <!-- The user restriction for this preference. -->
        <attr name="userRestriction"/>
        <attr name="userRestriction" format="string"/>
    </declare-styleable>

    <!-- =============================== -->
@@ -8900,7 +8906,7 @@
        <attr name="layout_ignoreOffset" format="boolean" />
        <attr name="layout_gravity" />
        <attr name="layout_hasNestedScrollIndicator" format="boolean" />
        <attr name="layout_maxHeight" />
        <attr name="layout_maxHeight" format="dimension"/>
    </declare-styleable>

    <!-- @hide -->
@@ -9110,4 +9116,6 @@
        <attr name="magnifierHorizontalOffset" format="dimension" />
        <attr name="magnifierColorOverlay" format="color" />
    </declare-styleable>

    <attr name="autoSizePresetSizes" />
</resources>
+8 −8
Original line number Diff line number Diff line
@@ -1690,14 +1690,14 @@
        <attr name="usesNonSdkApi" />

        <!-- If {@code true} the user is prompted to keep the app's data on uninstall -->
        <attr name="hasFragileUserData" />
        <attr name="hasFragileUserData" format="boolean"/>

        <attr name="zygotePreloadName" />

        <!-- If {@code true} the system will clear app's data if a restore operation fails.
             This flag is turned on by default. <em>This attribute is usable only by system apps.
             </em> -->
        <attr name="allowClearUserDataOnFailedRestore"/>
        <attr name="allowClearUserDataOnFailedRestore" format="boolean"/>
        <!-- If {@code true} the app's non sensitive audio can be captured by other apps with
             {@link android.media.AudioPlaybackCaptureConfiguration} and a
             {@link android.media.projection.MediaProjection}.
@@ -1755,7 +1755,7 @@
        <attr name="banner" />
        <attr name="logo" />
        <attr name="permissionGroup" />
        <attr name="backgroundPermission" />
        <attr name="backgroundPermission" format="string"/>
        <attr name="description" />
        <attr name="request" />
        <attr name="protectionLevel" />
@@ -1785,10 +1785,10 @@
        <attr name="banner" />
        <attr name="logo" />
        <attr name="description" />
        <attr name="request" />
        <attr name="requestDetail" />
        <attr name="backgroundRequest" />
        <attr name="backgroundRequestDetail" />
        <attr name="request" format="string"/>
        <attr name="requestDetail" format="string"/>
        <attr name="backgroundRequest" format="string"/>
        <attr name="backgroundRequestDetail" format="string"/>
        <attr name="permissionGroupFlags" />
        <attr name="priority" />
    </declare-styleable>
@@ -2254,7 +2254,7 @@
        <attr name="path" />
        <attr name="pathPrefix" />
        <attr name="pathPattern" />
        <attr name="pathAdvancedPattern" />
        <attr name="pathAdvancedPattern" format="string"/>
        <attr name="permission" />
        <attr name="readPermission" />
        <attr name="writePermission" />
+8 −1
Original line number Diff line number Diff line
@@ -1712,7 +1712,14 @@ bool ResourceParser::ParseDeclareStyleable(xml::XmlPullParser* parser,
      child_ref.SetSource(item_source);
      styleable->entries.push_back(std::move(child_ref));

      // Do not add referenced attributes that do not define a format to the table.
      CHECK(child_resource.value != nullptr);
      Attribute* attr = ValueCast<Attribute>(child_resource.value.get());

      CHECK(attr != nullptr);
      if (attr->type_mask != android::ResTable_map::TYPE_ANY) {
        out_resource->child_resources.push_back(std::move(child_resource));
      }

    } else if (!ShouldIgnoreElement(element_namespace, element_name)) {
      diag_->Error(DiagMessage(item_source) << "unknown tag <"
+2 −3
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ TEST_F(ResourceParserTest, ParseAttrAndDeclareStyleableUnderConfigButRecordAsNoC
  std::string input = R"(
      <attr name="foo" />
      <declare-styleable name="bar">
        <attr name="baz" />
        <attr name="baz" format="reference"/>
      </declare-styleable>)";
  ASSERT_TRUE(TestParse(input, watch_config));

@@ -589,8 +589,7 @@ TEST_F(ResourceParserTest, ParseAttributesDeclareStyleable) {
  EXPECT_THAT(result.value().entry->visibility.level, Eq(Visibility::Level::kPublic));

  Attribute* attr = test::GetValue<Attribute>(&table_, "attr/bar");
  ASSERT_THAT(attr, NotNull());
  EXPECT_TRUE(attr->IsWeak());
  ASSERT_THAT(attr, IsNull());

  attr = test::GetValue<Attribute>(&table_, "attr/bat");
  ASSERT_THAT(attr, NotNull());