Installing an Application on Cloud Phones in a Batch
After you install an application on a cloud phone, you can share and install the application on other cloud phones by calling an API.
The cloud phone that has the application installed is regarded as a seed cloud phone.
Constraints and Limitations
- This solution applies only to cloud phones whose specifications name does not contain qemu. Figure 1 Specifications
- You can identify whether a server is using storage 1.0 or 2.0 on its details page. Figure 2 Server details
- The seed cloud phone must be a cloud phone that has not been operated on. Otherwise, reset it.
Procedure
- Log in to the OBS console, create an OBS bucket by referring to Managing Cloud Phones in Batches, and set access permissions for the bucket.
To successfully upload files to the bucket, select Directory read and write when configuring the bucket policy.
Figure 3 Creating a bucket policy
- Connect to the seed cloud phone in ADB mode and install the required application on it.
For details, see How Do I Install Applications on a Cloud Phone?
- Call an API to export data of the seed cloud phone, pack the data, and upload the data package to the OBS bucket created in 1.
curl command
curl -i -k -X POST "https://${CPH Endpoint}/v1/${projectId}/cloud-phone/phones/batch-storage" -H "Content-Type: application/json" -H "X-Auth-Token: $token" -d ' { "storage_infos": [ { "phone_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "include_files": [ "/data/app/${package-name}-1", "/data/data/${package-name}", "/data/media/0/Android/data/${package-name}" ], "bucket_name": "${bucket_name}", "object_path": "${your_dir}/${package-name}.tar" } ] }'Parameters:
- phone_id: ID of the seed cloud phone
- bucket_name: name of the OBS bucket for storing the data exported
- object_path: OBS path for storing the data exported
If you want to pack all data of applications on the seed cloud phone, the following three paths must be included:
- /data/app/${package-name}-1
${package-name} may not be followed by -1. Configure this parameter as required.
- /data/data/${package-name}
- /data/media/0/Android/data/${package-name}
Example
curl -i -k -X POST "https://${CPH Endpoint}/v1/${projectId}/cloud-phone/phones/batch-storage" -H "Content-Type: application/json" -H "X-Auth-Token: $token" -d ' { "storage_infos": [ { "phone_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "include_files": [ "/data/app/com.taptap-1", "/data/data/com.taptap", "/data/media/0/Android/data/com.taptap" ], "bucket_name": "your-bucket-name", "object_path": "your/dir/taptap.tar" } ] }' - View the OBS bucket created in 1 and check whether the file packed and uploaded in 3 is successfully uploaded. If yes, go to the next step.
- Call an API to push files from an OBS bucket to the server.
- Servers with storage 2.0 (recommended)
curl -i -k -X POST "https://${CPH Endpoint}/v1/${projectId}/cloud-phone/phones/share-apps" -H "Content-Type: application/json" -H "X-Auth-Token: $token" -d ' { "package_name": "com.miniteck.miniworld", "pre_install_app": 0, "bucket_name": "your-bucket-name", "object_path": "your/dir/miniworld.tar", "server_ids": ["1678567b8bab40f93711234cb8","1234567b8bab40ffb711234cb"] }'Parameter:
- bucket_name and object_path are the same as those in 3.
- pre_install_app (optional): whether to pre-install an application. 0 indicates it will not be pre-installed and you need to manually install it. 1 indicates the application will be pre-installed after the cloud phones are reset.
- server_ids: IDs of servers that receive the file pushed. If multiple server IDs are specified, the application can be installed on cloud phones on multiple servers.
- Servers with storage 1.0
curl -i -k -X POST "https://${CPH Endpoint}/v1/${projectId}/cloud-phone/phones/share-files" -H "Content-Type: application/json" -H "X-Auth-Token: $token" -d ' { "bucket_name": "your-bucket-name", "object_path": "your/dir/taptap.tar", "server_ids": ["1678567b8bab40f93711234cb8","1234567b8bab40ffb711234cb"] }'Parameters:
- bucket_name and object_path are the same as those in 3.
- server_ids: IDs of servers that receive the file pushed. If multiple server IDs are specified, the application can be installed on cloud phones on multiple servers.
- Servers with storage 2.0 (recommended)
- Install the application.
- Servers with storage 2.0 (recommended)
If you set pre_install_app to 1 in the previous step, the application will be installed automatically after you reset the cloud phones. If pre_install_app is set to 0, run appctrl install package-name on the cloud phones to install the application. package-name is the value of package_name in 5, for example, com.miniteck.miniworld.
If an application is pre-installed, after it is uninstalled, it will be installed automatically again after the cloud phones are reset.
- Servers with storage 1.0
- Servers with storage 2.0 (recommended)
Execution Results
For servers that use storage 1.0, the applications have been installed after the cloud phones are reset.
For servers that use storage 2.0, the applications can be started by running appctrl start package_name.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot