From 218308284342a97cbf7e14f5069effeee3d8eb83 Mon Sep 17 00:00:00 2001 From: Metin Kaya Date: Wed, 7 May 2025 16:32:20 +0100 Subject: [PATCH] workloads: Add support for Honor of Kings game Introduce a new workload for automating match replays in Honor of Kings. This workload leverages ApkReventWorkload to launch the game and play back a specified replay file. Allow customization through parameters: - `activity`: Specifies the activity string of the game. - `replay_file`: Designates the replay file to be uploaded. The game can be replayed via `wa replay` command as well, but this plugin makes data collection (`fps`, `trace-cmd` like augmentations) a lot easier. Signed-off-by: Metin Kaya --- wa/workloads/honorofkings/__init__.py | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 wa/workloads/honorofkings/__init__.py diff --git a/wa/workloads/honorofkings/__init__.py b/wa/workloads/honorofkings/__init__.py new file mode 100644 index 00000000..93d404b2 --- /dev/null +++ b/wa/workloads/honorofkings/__init__.py @@ -0,0 +1,61 @@ +# Copyright 2025 ARM Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import os + +from wa import ApkReventWorkload, Parameter + + +class HoK(ApkReventWorkload): + name = 'honorofkings' + uninstall = False + clear_data_on_reset = False # Don't clear assets on exit + requires_network = True # The game requires network connection + description = ( + 'Launch a match replay in Honor of Kings.\n\n' + 'The game must already have a user logged in and the plugins downloaded.' + ) + package_names = [ + 'com.levelinfinite.sgameGlobal', + 'com.tencent.tmgp.sgame', + ] + + parameters = [ + Parameter( + 'activity', + kind=str, + default='.SGameGlobalActivity', + description='Activity name of Honor of Kings game.', + ), + Parameter( + 'replay_file', + kind=str, + default='replay.abc', + description='Honor of Kings Replay file name.', + ), + ] + + def setup(self, context): + upload_dir = self.target.path.join( + self.target.external_storage_app_dir, + self.apk.apk_info.package, + 'files', + 'Replay' + ) + replay_file = os.path.join(self.dependencies_directory, self.replay_file) + self.logger.debug('Uploading "%s" to "%s"...', replay_file, upload_dir) + self.target.push(replay_file, upload_dir) + + super().setup(context)