activity_sdk_device_prepare.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. #include <algorithm>
  2. #include <limits>
  3. #include "../../middleware/bap/activity_message/damage_monitor_auth.h"
  4. #include "../../middleware/bap/activity_message/darkness_zone_auth.h"
  5. #include "../../middleware/bap/activity_message/ghost_link_auth.h"
  6. #include "../../middleware/bap/activity_message/interactable_object_auth.h"
  7. #include "../../middleware/bap/activity_message/mission_effect_auth.h"
  8. #include "../../middleware/bap/activity_message/music_section_auth.h"
  9. #include "../../middleware/bap/activity_message/scene_events_auth.h"
  10. #include "../../middleware/bap/activity_message/sensor_auth_update.h"
  11. #include "../../middleware/bap/activity_message/squad_objective_auth.h"
  12. #include "../../middleware/content/packages/tables/region_reader.h"
  13. #include "../../state/activity/runtime.h"
  14. #include "activity_sdk_device_internal.h"
  15. namespace sunrise::server::activity::activity_sdk_devices::detail {
  16. namespace auth = middleware::bap::activity_message::scriptable_auth;
  17. namespace format = state::activity_sdk::format;
  18. namespace layouts = state::build_data::scenarios;
  19. namespace sdk = state::activity_sdk;
  20. namespace tables = middleware::content::packages::tables;
  21. static_assert(format::kDeviceSlotType == auth::kType23SlotType);
  22. static_assert(format::kDeviceAuthSchema == auth::kType23Schema);
  23. static_assert(format::kObjectSlotType == auth::kType4SlotType);
  24. static_assert(format::kObjectAuthSchema == auth::kType4Schema);
  25. namespace {
  26. /** @return True when both complete groups have the same key and compressed wire layout. */
  27. [[nodiscard]] bool same_roster_layout(const layouts::RosterGroup& left,
  28. const layouts::RosterGroup& right) noexcept {
  29. if (!layouts::valid_roster_group(left) || !layouts::valid_roster_group(right)
  30. || left.registryKey != right.registryKey || left.slotCount != right.slotCount) {
  31. return false;
  32. }
  33. for (std::size_t index = 0; index < left.slotCount; ++index) {
  34. if (left.slotTypes[index] != right.slotTypes[index]
  35. || left.slotFlags[index] != right.slotFlags[index]
  36. || left.slotIndices[index] != right.slotIndices[index]) {
  37. return false;
  38. }
  39. }
  40. return true;
  41. }
  42. /** Finds the selected Auth slot in one materialized group's compressed order. */
  43. [[nodiscard]] bool selected_slot_offset(const layouts::RosterGroup& group,
  44. const format::Slot& slot,
  45. std::uint16_t& output) noexcept {
  46. output = 0;
  47. if (!layouts::valid_roster_group(group)
  48. || slot.slotIndex > (std::numeric_limits<std::uint16_t>::max)()) {
  49. return false;
  50. }
  51. std::size_t matches = 0;
  52. for (std::size_t index = 0; index < group.slotCount; ++index) {
  53. if (group.slotIndices[index] != slot.slotIndex || group.slotTypes[index] != slot.slotType
  54. || (group.slotFlags[index] & layouts::kSlotAuthFlag) == 0) {
  55. continue;
  56. }
  57. output = static_cast<std::uint16_t>(index);
  58. ++matches;
  59. }
  60. return matches == 1;
  61. }
  62. /** Resolves a materialized occurrence group to at most one canonical roster row. */
  63. [[nodiscard]] Status canonical_target(const sdk::BoundView& view,
  64. const format::Scenario& scenario,
  65. const format::Slot& slot,
  66. const layouts::RosterGroup& generatedGroup,
  67. std::int32_t effectiveRegion,
  68. host::ScriptableTarget& output,
  69. bool& found) noexcept {
  70. output = {};
  71. found = false;
  72. if (view.binding.destination.packageNameLength == 0
  73. || view.binding.destination.packageNameLength
  74. > view.binding.destination.packageName.size()) {
  75. return Status::invalidView;
  76. }
  77. const std::string_view destination(
  78. reinterpret_cast<const char*>(view.binding.destination.packageName.data()),
  79. view.binding.destination.packageNameLength);
  80. layouts::Definition layout{};
  81. if (!state::build_data::find_scenario_layout(destination, layout) || layout.tag != scenario.tag
  82. || layout.rosterGroupCount > layout.rosterGroups.size()
  83. || layout.bubbleGroupCount > layout.bubbleGroups.size()) {
  84. return Status::targetUnavailable;
  85. }
  86. const std::uint32_t activeBubble =
  87. static_cast<std::uint32_t>(effectiveRegion) / tables::kSliceSetIndexFactor;
  88. std::size_t activeMatches = 0;
  89. std::uint16_t selectedTable = 0;
  90. layouts::RosterGroup selectedGroup{};
  91. const auto consider = [&](std::uint16_t tableIndex, bool active) noexcept {
  92. layouts::RosterGroup candidate{};
  93. if (!state::build_data::find_roster_group(tableIndex, candidate)) {
  94. return false;
  95. }
  96. if (!same_roster_layout(generatedGroup, candidate)) {
  97. return true;
  98. }
  99. if (active) {
  100. if (activeMatches == 0) {
  101. activeMatches = 1;
  102. selectedTable = tableIndex;
  103. selectedGroup = candidate;
  104. } else if (tableIndex != selectedTable) {
  105. // The same canonical table may be published in both the always-active and bubble
  106. // lanes. That is one target; only a distinct active table is ambiguous.
  107. activeMatches = 2;
  108. }
  109. }
  110. return true;
  111. };
  112. for (std::size_t index = 0; index < layout.rosterGroupCount; ++index) {
  113. if (!consider(layout.rosterGroups[index], true)) {
  114. return Status::targetUnavailable;
  115. }
  116. }
  117. for (std::size_t index = 0; index < layout.bubbleGroupCount; ++index) {
  118. const bool active =
  119. activeBubble < layouts::kBubbleCapacity
  120. && (layout.bubbleGroupMasks[index] & (std::uint64_t{1} << activeBubble)) != 0;
  121. if (!consider(layout.bubbleGroups[index], active)) {
  122. return Status::targetUnavailable;
  123. }
  124. }
  125. if (activeMatches > 1) {
  126. return Status::ambiguousTarget;
  127. }
  128. if (activeMatches == 0) {
  129. return Status::ready;
  130. }
  131. std::uint16_t slotOffset = 0;
  132. if (!selected_slot_offset(selectedGroup, slot, slotOffset)) {
  133. return Status::invalidSlot;
  134. }
  135. output.objectTag = selectedGroup.objectTag;
  136. output.registryKey = selectedGroup.registryKey;
  137. output.authSchema = slot.authSchema;
  138. output.rosterGroupIndex = selectedTable;
  139. output.rosterSlotOffset = slotOffset;
  140. output.slotIndex = static_cast<std::uint16_t>(slot.slotIndex);
  141. output.slotType = static_cast<std::uint8_t>(slot.slotType);
  142. found = true;
  143. return Status::ready;
  144. }
  145. /** Finishes the exact canonical or state-local route resolved from the bound SDK. */
  146. [[nodiscard]] Status finish_prepared(const sdk::BoundView& view,
  147. const server::bap::ActivityLinkView& link,
  148. PreparedDevice& output) noexcept {
  149. output.activityClientGeneration = link.activityClientGeneration;
  150. output.scenarioRow = view.scenarioRow;
  151. output.effectiveRegion = link.effectiveRegion;
  152. return Status::ready;
  153. }
  154. } // namespace
  155. /** Maps the SDK binding validator to this API's stable refusal surface. */
  156. [[nodiscard]] Status binding_status(const sdk::BoundView& view,
  157. server::bap::ActivityLinkView& link) noexcept {
  158. if (view.catalog == nullptr || sdk::bound_activity(view) == nullptr
  159. || sdk::bound_scenario(view) == nullptr) {
  160. return Status::invalidView;
  161. }
  162. if (!state::activity::binding_matches(view.binding)) {
  163. return Status::staleBinding;
  164. }
  165. (void)server::bap::activity_link_view(view.binding, link);
  166. switch (
  167. sdk::revalidate(view, view.binding, link.matchingLinks, link.activityClientGeneration)) {
  168. case sdk::Status::ready:
  169. return link.effectiveRegion >= 0 ? Status::ready : Status::noActivityLink;
  170. case sdk::Status::missingClient:
  171. case sdk::Status::ambiguousClient:
  172. return Status::noActivityLink;
  173. case sdk::Status::staleSession:
  174. return Status::staleBinding;
  175. case sdk::Status::staleActivityClient:
  176. return Status::staleActivityClient;
  177. case sdk::Status::notReady:
  178. case sdk::Status::missing:
  179. case sdk::Status::wrongSdkBuild:
  180. case sdk::Status::catalogInvalid:
  181. case sdk::Status::wrongActivity:
  182. case sdk::Status::activityJoinNotExact:
  183. case sdk::Status::missingScenarioLink:
  184. return Status::invalidView;
  185. }
  186. return Status::invalidView;
  187. }
  188. /** Resolves one SDK slot through a published canonical group or its exact live occurrence. */
  189. [[nodiscard]] Status
  190. prepare_slot(const sdk::BoundView& view, std::uint32_t slotRow, PreparedDevice& output) noexcept {
  191. output = {};
  192. server::bap::ActivityLinkView link{};
  193. const Status live = binding_status(view, link);
  194. if (live != Status::ready) {
  195. return live;
  196. }
  197. const sdk::Catalog& catalog = *view.catalog;
  198. const format::Scenario* const scenario = sdk::bound_scenario(view);
  199. const auto slots = catalog.slots();
  200. const auto objects = catalog.objects();
  201. const auto occurrences = catalog.occurrences();
  202. const auto states = catalog.states();
  203. const auto bubbles = catalog.bubbles();
  204. if (scenario == nullptr || slotRow >= slots.size()) {
  205. return Status::invalidSlot;
  206. }
  207. const format::Slot& slot = slots[slotRow];
  208. if (slot.objectIndex >= objects.size()
  209. || slot.slotIndex > middleware::bap::activity_message::sensor_auth_update::kMaximumSlotIndex
  210. || slot.slotType > middleware::bap::activity_message::sensor_auth_update::kMaximumSlotType
  211. || slot.authSchema == 0 || slot.authSchema == format::kAbsentIndex) {
  212. return Status::invalidSlot;
  213. }
  214. if ((slot.flags & format::kSlotSchemaJoinExact) == 0) {
  215. return Status::schemaJoinNotExact;
  216. }
  217. const format::Object& object = objects[slot.objectIndex];
  218. if (object.objectTag == 0 || object.objectKey == 0
  219. || !sdk::materialize_roster_group(catalog, object, output.generatedRosterGroup)) {
  220. return Status::invalidSlot;
  221. }
  222. std::uint16_t slotOffset = 0;
  223. if (!selected_slot_offset(output.generatedRosterGroup, slot, slotOffset)) {
  224. return Status::invalidSlot;
  225. }
  226. bool canonical = false;
  227. const Status canonicalStatus = canonical_target(view,
  228. *scenario,
  229. slot,
  230. output.generatedRosterGroup,
  231. link.effectiveRegion,
  232. output.target,
  233. canonical);
  234. if (canonicalStatus != Status::ready) {
  235. output = {};
  236. return canonicalStatus;
  237. }
  238. if (canonical) {
  239. return finish_prepared(view, link, output);
  240. }
  241. const format::Occurrence* selected = nullptr;
  242. std::uint32_t selectedState = format::kAbsentIndex;
  243. for (const format::Occurrence& occurrence : sdk::scenario_occurrences(catalog, *scenario)) {
  244. if (occurrence.scenarioIndex != view.scenarioRow || &occurrence < occurrences.data()
  245. || &occurrence >= occurrences.data() + occurrences.size()) {
  246. return Status::invalidView;
  247. }
  248. if (occurrence.objectIndex != slot.objectIndex) {
  249. continue;
  250. }
  251. if (occurrence.stateIndex >= states.size() || occurrence.bubbleIndex >= bubbles.size()) {
  252. return Status::invalidView;
  253. }
  254. const format::State& candidateState = states[occurrence.stateIndex];
  255. const format::Bubble& candidateBubble = bubbles[occurrence.bubbleIndex];
  256. if (candidateState.scenarioIndex != view.scenarioRow
  257. || candidateBubble.scenarioIndex != view.scenarioRow
  258. || candidateState.bubbleIndex != occurrence.bubbleIndex
  259. || candidateState.stateOrdinal >= tables::kSliceSetIndexFactor
  260. || candidateBubble.bubbleOrdinal >= layouts::kBubbleCapacity) {
  261. return Status::invalidView;
  262. }
  263. const std::uint64_t candidateRegion =
  264. static_cast<std::uint64_t>(candidateState.sliceSetIndex) + candidateState.stateOrdinal;
  265. if (candidateRegion != static_cast<std::uint64_t>(link.effectiveRegion)) {
  266. continue;
  267. }
  268. if (selected == nullptr) {
  269. selected = &occurrence;
  270. selectedState = occurrence.stateIndex;
  271. } else if (occurrence.stateIndex != selectedState) {
  272. return Status::ambiguousTarget;
  273. }
  274. }
  275. if (selected == nullptr) {
  276. return Status::targetUnavailable;
  277. }
  278. if (selected->stateIndex >= states.size() || selected->bubbleIndex >= bubbles.size()
  279. || selected->objectIndex >= objects.size()) {
  280. return Status::invalidView;
  281. }
  282. const format::State& state = states[selected->stateIndex];
  283. const format::Bubble& bubble = bubbles[selected->bubbleIndex];
  284. if (state.scenarioIndex != view.scenarioRow || bubble.scenarioIndex != view.scenarioRow
  285. || state.bubbleIndex != selected->bubbleIndex || object.objectTag == 0
  286. || object.objectKey == 0 || state.stateOrdinal >= tables::kSliceSetIndexFactor
  287. || bubble.bubbleOrdinal >= layouts::kBubbleCapacity) {
  288. return Status::invalidView;
  289. }
  290. output.target.objectTag = output.generatedRosterGroup.objectTag;
  291. output.target.registryKey = output.generatedRosterGroup.registryKey;
  292. output.target.authSchema = slot.authSchema;
  293. output.target.rosterGroupIndex = host::kGeneratedRosterGroupIndex;
  294. output.target.rosterSlotOffset = slotOffset;
  295. output.target.slotIndex = static_cast<std::uint16_t>(slot.slotIndex);
  296. output.target.sdkObjectIndex = selected->objectIndex;
  297. output.target.stateLocalRegion = link.effectiveRegion;
  298. output.target.slotType = static_cast<std::uint8_t>(slot.slotType);
  299. output.target.stateLocalRoster = true;
  300. output.stateRow = selected->stateIndex;
  301. return finish_prepared(view, link, output);
  302. }
  303. /** Resolves the legacy type-23 device facade through the shared typed SDK Auth slot route. */
  304. [[nodiscard]] Status prepare(const sdk::BoundView& view,
  305. std::uint32_t slotRow,
  306. auth::Type23Channel channel,
  307. float value,
  308. PreparedDevice& output) noexcept {
  309. (void)value;
  310. const auto channelIndex = static_cast<std::size_t>(channel);
  311. if (channelIndex >= auth::kType23ChannelCount) {
  312. return Status::invalidChannel;
  313. }
  314. if (view.catalog == nullptr || slotRow >= view.catalog->slots().size()) {
  315. return Status::invalidSlot;
  316. }
  317. const format::Slot& slot = view.catalog->slots()[slotRow];
  318. if (slot.slotType != format::kDeviceSlotType
  319. || slot.componentClass != format::kDeviceComponentClass
  320. || slot.senseSchema != format::kDeviceSenseSchema
  321. || slot.authSchema != format::kDeviceAuthSchema) {
  322. return Status::invalidSlot;
  323. }
  324. return prepare_slot(view, slotRow, output);
  325. }
  326. /**
  327. * Resolves one exact type-31 trigger slot. Type 31 carries no caller value, so unlike the device
  328. * path there is no channel or range to check first.
  329. * @param view Pinned SDK view whose binding is revalidated.
  330. * @param slotRow Catalog row the pulse targets.
  331. * @param output Cleared, then receives the resolved target.
  332. * @return ready only for an exact type-31 slot on a live owned binding.
  333. */
  334. [[nodiscard]] Status prepare_trigger(const sdk::BoundView& view,
  335. std::uint32_t slotRow,
  336. PreparedDevice& output) noexcept {
  337. if (view.catalog == nullptr || slotRow >= view.catalog->slots().size()) {
  338. return Status::invalidSlot;
  339. }
  340. const format::Slot& slot = view.catalog->slots()[slotRow];
  341. if (slot.slotType != auth::kType31SlotType || slot.authSchema != auth::kType31Schema) {
  342. return Status::invalidSlot;
  343. }
  344. return prepare_slot(view, slotRow, output);
  345. }
  346. /** Resolves one package-owned object entry without accepting a caller transform. */
  347. [[nodiscard]] Status prepare_object(const sdk::BoundView& view,
  348. std::uint32_t slotRow,
  349. std::int32_t entryIndex,
  350. PreparedDevice& output) noexcept {
  351. if (view.catalog == nullptr || slotRow >= view.catalog->slots().size() || entryIndex < 0) {
  352. return Status::invalidSlot;
  353. }
  354. const format::Slot& slot = view.catalog->slots()[slotRow];
  355. if (slot.slotType != format::kObjectSlotType
  356. || slot.componentClass != format::kObjectComponentClass
  357. || slot.senseSchema != format::kObjectSenseSchema
  358. || slot.authSchema != format::kObjectAuthSchema) {
  359. return Status::invalidSlot;
  360. }
  361. return prepare_slot(view, slotRow, output);
  362. }
  363. /** Resolves one exact actor channel bridge. */
  364. [[nodiscard]] Status prepare_combatant(const sdk::BoundView& view,
  365. std::uint32_t slotRow,
  366. PreparedDevice& output) noexcept {
  367. if (view.catalog == nullptr || slotRow >= view.catalog->slots().size()) {
  368. return Status::invalidSlot;
  369. }
  370. const format::Slot& slot = view.catalog->slots()[slotRow];
  371. if (slot.slotType != auth::kType2SlotType || slot.componentClass != auth::kType2ComponentClass
  372. || slot.senseSchema != auth::kType2SenseSchema || slot.authSchema != auth::kType2Schema) {
  373. return Status::invalidSlot;
  374. }
  375. return prepare_slot(view, slotRow, output);
  376. }
  377. /** Verifies exact SDK identity and schema-decodes one retained Auth body. */
  378. [[nodiscard]] Status validate_auth(const sdk::BoundView& view,
  379. std::uint32_t slotRow,
  380. std::uint32_t objectTag,
  381. std::uint32_t registryKey,
  382. std::uint32_t authSchema,
  383. std::uint16_t slotIndex,
  384. std::uint8_t slotType,
  385. std::span<const std::byte> body,
  386. std::uint16_t bitCount,
  387. std::span<const std::byte> sdkBuildSha256) noexcept {
  388. if (view.catalog == nullptr || sdkBuildSha256.size() != 32U
  389. || view.catalog->sdk_build_sha256().size() != sdkBuildSha256.size()
  390. || !std::equal(sdkBuildSha256.begin(),
  391. sdkBuildSha256.end(),
  392. view.catalog->sdk_build_sha256().begin())) {
  393. return Status::wrongSdkBuild;
  394. }
  395. const auto slots = view.catalog->slots();
  396. const auto objects = view.catalog->objects();
  397. if (slotRow >= slots.size()) {
  398. return Status::invalidSlot;
  399. }
  400. const format::Slot& slot = slots[slotRow];
  401. if (slot.objectIndex >= objects.size() || objectTag == 0 || registryKey == 0 || authSchema == 0
  402. || slotType > middleware::bap::activity_message::sensor_auth_update::kMaximumSlotType
  403. || slotIndex > middleware::bap::activity_message::sensor_auth_update::kMaximumSlotIndex
  404. || objects[slot.objectIndex].objectTag != objectTag
  405. || objects[slot.objectIndex].objectKey != registryKey || slot.authSchema != authSchema
  406. || slot.slotIndex != slotIndex || slot.slotType != slotType) {
  407. return Status::invalidSlot;
  408. }
  409. if ((slot.flags & format::kSlotSchemaJoinExact) == 0) {
  410. return Status::schemaJoinNotExact;
  411. }
  412. if (body.empty()
  413. || body.size()
  414. > middleware::bap::activity_message::sensor_auth_update::kAuthOverrideByteCapacity
  415. || bitCount > body.size() * 8U || bitCount + 7U < body.size() * 8U) {
  416. return Status::invalidBody;
  417. }
  418. const std::size_t trailingBits = bitCount % 8U;
  419. if (trailingBits != 0) {
  420. const std::uint8_t paddingMask =
  421. static_cast<std::uint8_t>((std::uint16_t{1} << (8U - trailingBits)) - 1U);
  422. if ((std::to_integer<std::uint8_t>(body.back()) & paddingMask) != 0) {
  423. return Status::invalidBody;
  424. }
  425. }
  426. // An occupancy Auth body is exactly 87 bits, which the wire pads to 11 bytes.
  427. constexpr std::size_t kOccupancyAuthBits = 87;
  428. constexpr std::size_t kOccupancyAuthBytes = 11;
  429. // Bodies this tree encodes are admitted by slot identity. Their shape belongs to the encoder.
  430. namespace message = middleware::bap::activity_message;
  431. const auto typed = [&](std::uint32_t type, std::uint32_t componentClass, std::uint32_t schema) {
  432. return slotType == type && slot.componentClass == componentClass && authSchema == schema;
  433. };
  434. const bool typedSdkBody =
  435. typed(auth::kType34SlotType, auth::kType34ComponentClass, auth::kType34Schema)
  436. || typed(message::mission_effect::kSlotType,
  437. message::mission_effect::kComponentClass,
  438. message::mission_effect::kSchema)
  439. || typed(message::music_section::kSlotType,
  440. message::music_section::kComponentClass,
  441. message::music_section::kSchema)
  442. || typed(message::scene_events::kSlotType,
  443. message::scene_events::kComponentClass,
  444. message::scene_events::kSchema)
  445. || typed(message::damage_monitor::kSlotType,
  446. message::damage_monitor::kComponentClass,
  447. message::damage_monitor::kAuthSchema)
  448. || typed(message::darkness_zone::kSlotType,
  449. message::darkness_zone::kComponentClass,
  450. message::darkness_zone::kSchema)
  451. || typed(format::kObjectSlotType,
  452. format::kObjectComponentClass,
  453. message::interactable_object::kSchema)
  454. || typed(message::ghost_link::kSlotType,
  455. message::ghost_link::kComponentClass,
  456. message::ghost_link::kAuthSchema)
  457. || typed(
  458. format::kSquadSlotType, format::kSquadComponentClass, message::squad_objective::kSchema)
  459. || typed(auth::kType2SlotType, auth::kType2ComponentClass, auth::kType2Schema);
  460. const bool occupancy = slotType == format::kOccupancySlotType
  461. && authSchema == format::kOccupancyAuthSchema
  462. && bitCount == kOccupancyAuthBits && body.size() == kOccupancyAuthBytes;
  463. const bool directive =
  464. slotType == middleware::bap::activity_message::scriptable_auth::kType68SlotType
  465. && authSchema == middleware::bap::activity_message::scriptable_auth::kType68Schema
  466. && middleware::bap::activity_message::scriptable_auth::validate_type68_body(body, bitCount);
  467. const bool engagement =
  468. slotType == middleware::bap::activity_message::scriptable_auth::kType70SlotType
  469. && authSchema == middleware::bap::activity_message::scriptable_auth::kType70Schema
  470. && middleware::bap::activity_message::scriptable_auth::validate_type70_body(body, bitCount);
  471. const bool publicEvent =
  472. slotType == middleware::bap::activity_message::scriptable_auth::kType71SlotType
  473. && authSchema == middleware::bap::activity_message::scriptable_auth::kType71Schema
  474. && middleware::bap::activity_message::scriptable_auth::validate_type71_body(body, bitCount);
  475. const bool performance =
  476. slotType == middleware::bap::activity_message::scriptable_auth::kType42SlotType
  477. && authSchema == middleware::bap::activity_message::scriptable_auth::kType42Schema
  478. && middleware::bap::activity_message::scriptable_auth::validate_type42_body(body, bitCount);
  479. const bool combatant =
  480. slotType == middleware::bap::activity_message::scriptable_auth::kType2SlotType
  481. && authSchema == middleware::bap::activity_message::scriptable_auth::kType2Schema
  482. && middleware::bap::activity_message::scriptable_auth::validate_type2_body(body, bitCount);
  483. if (!typedSdkBody && !occupancy && !directive && !engagement && !publicEvent && !performance
  484. && !combatant) {
  485. return Status::invalidBody;
  486. }
  487. return Status::ready;
  488. }
  489. } // namespace sunrise::server::activity::activity_sdk_devices::detail