| CLASS info |
| public final class GameManager |
| Represents an abstract class that provides a public static method for obtaining a GameManager instance. |
| Return type | Method name |
| GameManager | getGameManager () |
| boolean | registerGame(String packageName, GameCallBack gameCallback) |
| void | updateGameAppInfo(String gameInfoJson) () |
| String | getPhoneInfo() |
| Method |
| public static GameManager getGameManager() |
| Obtains a GameManager instance. |
Return
| type | desc |
| GameManager | Returns an instance that inherits and implements the GameManager abstract class. This API uses the singleton pattern. That is, it returns the same instance each time when it is called. |
| Method |
| public boolean registerGame(String packageName, GameCallBack gameCallback) |
| Registers an app with a device. After the registration is successful, the device can call the API provided by GameManager. |
Parameters
| Parameter name | Parameter desc |
| String packageName | Indicates the app package name. |
| GameCallBack gameCallback | Indicates the callback used to obtain device information such as the temperature from the device. This parameter can be set to null, indicating that the app does not obtain the information reported by the device through callback. |
| type | desc |
| boolean | Indicates a registration result. true: The registration is successful. false: The registration fails. |
| Method |
| public void updateGameAppInfo(String gameInfoJson) |
| Sends game information to a device. After your app is registered with a device using the registerGame method, you can then use this method to send game information to the device. Otherwise, the device cannot receive game information. |
Parameters
| Parameter name | Parameter desc |
| String gameInfoJson | Indicates the game information sent to the device. |
| Global game message: A message containing global parameters of a game, which is sent during game initialization. These parameters remain unchanged during the entire game process. Example in the JSON format: { “MessageType”:0, “PackageName”:”xxx.xxx.xxxx.xxx”, “AppVersion”:”1.0”, “ResourceVersion”:”1.0”, “EngineType”:2, “EngineVersion”:”1.0”, “GameType”:2, “VulkanSupport”:true } [Type] int. [Field] MessageType. [Description] Mandatory. The value 0 indicates a global game message. [Type] string. [Field] PackageName. [Description] Mandatory. Indicates the name of a game package. [Type] string. [Field] AppVersion. [Description] Mandatory. Indicates the game app version number. [Type] string. [Field] ResourceVersion. [Description] Optional. Indicates the game resource version number. [Type] byte. [Field] EngineType. 1 - UNITY, 2 – UNREAL4, 3 – MESSIAH, 4 - COCOS 200 – OTHERS [Description] Optional. Indicates the game engine type. [Type] string. [Field] EngineVersion. [Description] Optional. Indicates the version number of the game engine. If EngineType is not set, this parameter can be left null. [Type] byte. [Field] GameType. [Description] Optional. Indicates the game type. 1 - MOBA (multi-player online battle arena), 2 - RPG (role playing games), 3 - FPS (first-person shooter), 4 - FTG (fight technology games), 5 - RAC (racing games), 200 - OTHERS. [Type] boolean. [Field] VulkanSupport. [Description] Optional. Indicates whether Vulkan is supported. | |
| Game setting message: A message containing default game settings, which is sent during game initialization. Or, a message containing an updated setting, which is sent when a game setting changes (for example, when a user changes a parameter). Example in the JSON format: { “MessageType”:1, “PictureQualityMaxLevel”:3, “PictureQualityCurLevel”:3, “FrameRateMaxValue”:60, “FrameRateCurValue”:50, “ResolutionMaxValue”:”1920x1080”, “ResolutionCurValue”:”1280x720”, “AntiAliasing”:true, “Shadow”:true, “MultiThread”:true, “Particle”:true, “HDMode”:true } [Type] int. [Field] MessageType. [Description] Mandatory. The value 1 indicates a game setting message. [Type] byte. [Field] PictureQualityMaxLevel. [Description] Mandatory. Indicates the highest image quality level that is supported. For example, if HD is the highest image quality level, the value is 3. The value ranges from 1 to 5. The greater the value, the higher the image quality. [Type] byte. [Field] PictureQualityCurLevel. [Description] Mandatory. Indicates the current image quality level. For example, if the current image quality level is HD, the value is 3. [Type] float. [Field] FrameRateMaxValue. [Description] Mandatory. Indicates the maximum frame rate that is supported. For example, if up to 60 FPS is supported, the value is 60. [Type] float. [Field] FrameRateCurValue. [Description] Mandatory. Indicates the frame rate that is set. For example, if the current frame rate is 50 FPS, the value is 50. [Type] string. [Field] ResolutionMaxValue. [Description] Mandatory. Indicates the highest resolution that is supported. For example, “1920 x 1080”. [Type] string. [Field] ResolutionCurValue. [Description] Mandatory. Indicates the current resolution. For example, “1280 x 720”. [Type] boolean. [Field] AntiAliasing. [Description] Mandatory. Indicates whether anti-aliasing is enabled. [Type] boolean. [Field] Shadow. [Description] Mandatory. Indicates whether the shadow function is enabled. [Type] boolean. [Field] MultiThread. [Description] Mandatory. Indicates whether multiple threads are enabled. [Type] boolean. [Field] Particle. [Description] Mandatory. Indicates whether the particle effect is enabled. [Type] boolean. [Field] HDMode. [Description] Mandatory. Indicates whether the HD mode is enabled. | |
| Game matching message, which is sent at the beginning and end of a game. Example in the JSON format: {“MessageType”:2,”Status”:1} [Type] int. [Field] MessageType. [Description] Mandatory. The value 2 indicates a game matching message. [Type] byte. [Field] Status. [Description] Mandatory. Indicates the start and end of a game. 1: start; 0: end. | |
| Game scene message: A message sent when a game scene begins, when the game scene is in progress, or when the game scene ends. The message contains parameters related to scene importance and optimization of performance and power consumption. { “MessageType”:3, “SceneID”:1, “Description”:”driving”, “ImportantLevel”:5, “SceneFreq”:3, “SceneTime”:1000, “RecommendCpuLevel”:5, “RecommendGpuLevel”:5, “RecommendDdrLevel”:5, “RecommendFps”:60, “MaxFps”:60, “CurrentFps”:56.6, “KeyThread”:”render|5006|render|5007|logic|6008|logic|6009|logic|6010|net|7009”, “DrawCallNum”:5000, “VertexNum”:60000, “TriangleNum”:30000, “ShaderNum”:500, “TextureNum”:1000, “MeshNum”:100, “PassNum”:5, “PeopleNum”:6 } [Type] int. [Field] MessageType. [Description] Mandatory. The value 3 indicates a game scene message. [Type] int. [Field] SceneID. [Description] Mandatory. Indicates the game scene ID. For details about the ID, see the following. Special game scene code is customized starting from 100. [Type] string. [Field] Description. [Description] Optional. Indicates the game scene description, for example, driving. [Type] byte. [Field] ImportantLevel. [Description] Mandatory. Indicates the importance of a scene. The value ranges from 1 to 5. The greater the value, the higher the importance. [Type] int. [Field] SceneFreq. [Description] Optional. Indicates the number of times a scene occurs in a game. The number is provided based on the game big data. [Type] int. [Field] SceneTime. [Description] Optional. Indicates the duration of a scene, in milliseconds. The number is provided based on the game big data. [Type] byte. [Field] RecommendCpuLevel. [Description] Optional. Indicates the recommended CPU level in the scene. [Type] byte. [Field] RecommendGpuLevel. [Description] Optional. Indicates the recommended GPU level in the scene. [Type] byte. [Field] RecommendDdrLevel. [Description] Optional. Indicates the recommended DDR level in the scene. [Type] float. [Field] RecommendFps. [Description] Optional. Indicates the recommended frame rate in the scene. [Type] float. [Field] MaxFps. [Description] Optional. Indicates the maximum frame rate in the scene. [Type] float. [Field] MeanFps. [Description] Optional. Indicates the average number of frames during a period of time in the game. [Type] string. [Field] KeyThread. [Description] Optional. Indicates the key thread in the scene. render - Rendering thread, logic - Logic thread, net - Network thread. [Type] int. [Field] DrawCallNum. [Description] Optional. Indicates the average number of Drawcalls per frame in the scene. [Type] int. [Field] VertexNum. [Description] Optional. Indicates the average number of model vertices per frame in the scene. [Type] int. [Field] TriangleNum. [Description] Optional. Indicates the average number of triangles per frame in the scene. [Type] int. [Field] ShaderNum. [Description] Optional. Indicates the average number of shaders per frame in the scene. [Type] int. [Field] TextureNum. [Description] Optional. Indicates the average number of textures per frame in the scene. [Type] string. [Field] MeshNum. [Description] Optional. Indicates the average number of meshes per frame in the scene. [Type] int. [Field] PassNum. [Description] Optional. Indicates the number of rendering channels per frame in the scene. [Type] int. [Field] PeopleNum. [Description] Optional. Indicates the number of users playing on the same screen in the scene. 0 - Default scene (switchback scene or other scene). After the current scene ends, the switchback scene can be sent to indicate an end. 1 - Game startup, 2 - In-game update, 3 - Login process, 4 - Main interface, 5 - Game loading (player loading), 6 - Game loading (player loading finished; waiting for others loading), 7 - Game in progress, 8 - Onlooker mode. | |
| Game touch area message: A message indicating valid touch area, which is sent to the system when the game scene begins. If the valid touch area changes in the game scene, the change should also be sent to the phone system. Example in the JSON format: { “MessageType”:4, “ValidRegion”: “direct:3:(10,10,30,30)|op:2:(200,200,210,210)|set:1:(500,500,510,510)”, “HandleTime”:10 } [Type] int. [Field] MessageType. [Description] Mandatory. The value 4 indicates a game touch area message. [Type] string. [Field] ValidRegion. [Description] Mandatory. Identifies the valid touch area in the game scene, including the attributes, usage frequency, and area attribute definition. direct - Direction, op - Operation, set- Setting. The frequency ranges from 1 to 3, which are defined as low, medium, and high levels. Example of using the coordinates in the upper left and lower right corners to represent the rectangle: direct:3:(10,10,30,30)|op:2:(200,200,210,210)|set:1:(500,500,510,510) [Type] int. [Field] HandleTime. [Description] Optional. Indicates the duration from the time when the game app receives the input event to the time when the app responds, in milliseconds. | |
| Game network status message: A message indicating the network status, which is sent to the device when the game scene begins. The message should also be sent when network delay or load jump occurs. Example in the JSON format: { “MessageType”:5, “NetLatency”:”total:50|up:20|server:10|down:20”, “NetServerIP”:”10.111.65.22”, “NetLoad”:2 } [Type] int. [Field] MessageType. [Description] Mandatory. The value 5 indicates a game network status message. [Type] string. [Field] NetLatency . [Description] Mandatory. Indicates the network delay in the game scene, in milliseconds. 0-50-100-150-200… When the total delay changes, the delay is sent once. When sending the delay message, the upstream, downstream, and server processing time should be included, for example: format:total:50|up:20|server:10|down:20 [Type] string. [Field] NetServerIP. [Description] Mandatory. Indicates the address of the game server in the scene. [Type] byte. [Field] NetLoad. [Description] Optional. Indicates the game network load level, ranging from 1 to 3. The three levels are: 1 - Light load, 2 - Medium load, 3 - Heavy load. |
| Method |
| public String getPhoneInfo() |
| Obtains device information proactively, for example, temperature information. The device information obtained using this method is in the same format as that obtained by using the onPhoneInfoUpdated() method of the GameManager.GameCallback API. |
Return
| type | desc |
| String | Indicates the device information, for example, temperature information. If there is no device information, the value may be null or empty. |