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

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

Merge "Fix copying null reference across themes"

parents c7513249 b85d9b2a
Loading
Loading
Loading
Loading
+26 −25
Original line number Diff line number Diff line
@@ -1186,8 +1186,32 @@ void Theme::SetTo(const Theme& o) {
            continue;
          }

          // The package id of the attribute needs to be rewritten to the package id of the value in
          // the destination
          // If the attribute value represents an attribute or reference, the package id of the
          // value needs to be rewritten to the package id of the value in the destination
          uint32_t attribue_data = entry.value.data;
          if ((entry.value.dataType == Res_value::TYPE_ATTRIBUTE
              || entry.value.dataType == Res_value::TYPE_REFERENCE
              || entry.value.dataType == Res_value::TYPE_DYNAMIC_ATTRIBUTE
              || entry.value.dataType == Res_value::TYPE_DYNAMIC_REFERENCE)
              && attribue_data != 0x0) {

            // Determine the package id of the reference in the destination AssetManager
            auto value_package_map = src_asset_cookie_id_map.find(entry.cookie);
            if (value_package_map == src_asset_cookie_id_map.end()) {
              continue;
            }

            auto value_dest_package = value_package_map->second.find(
                get_package_id(entry.value.data));
            if (value_dest_package == value_package_map->second.end()) {
              continue;
            }

            attribue_data = fix_package_id(entry.value.data, value_dest_package->second);
          }

          // The package id of the attribute needs to be rewritten to the package id of the
          // attribute in the destination
          int attribute_dest_package_id = p;
          if (attribute_dest_package_id != 0x01) {
            // Find the cookie of the attribute resource id
@@ -1209,29 +1233,6 @@ void Theme::SetTo(const Theme& o) {
            attribute_dest_package_id = attribute_dest_package->second;
          }

          // If the attribute value represents an attribute or reference, the package id of the
          // value needs to be rewritten to the package id of the value in the destination
          uint32_t attribue_data = entry.value.data;
          if (entry.value.dataType == Res_value::TYPE_DYNAMIC_ATTRIBUTE
              || entry.value.dataType == Res_value::TYPE_DYNAMIC_REFERENCE
              || entry.value.dataType == Res_value::TYPE_ATTRIBUTE
              || entry.value.dataType == Res_value::TYPE_REFERENCE) {

            // Determine the package id of the reference in the destination AssetManager
            auto value_package_map = src_asset_cookie_id_map.find(entry.cookie);
            if (value_package_map == src_asset_cookie_id_map.end()) {
              continue;
            }

            auto value_dest_package = value_package_map->second.find(
                get_package_id(entry.value.data));
            if (value_dest_package == value_package_map->second.end()) {
              continue;
            }

            attribue_data = fix_package_id(entry.value.data, value_dest_package->second);
          }

          // Lazily instantiate the destination package
          std::unique_ptr<Package>& dest_package = packages_[attribute_dest_package_id];
          if (dest_package == nullptr) {