Updated on 2026-08-27 GMT+08:00

Presetting Files

Scenarios

You need to preset files on all cloud phones of a cloud phone server, such as keepalive scripts and application behavior monitoring files.

Procedure

  1. Select a cloud phone from the list and save the files to a directory of the cloud phone. For details, see Querying Cloud Phones.

    For example, save the test.txt and test.sh files in the /data/local/huawei/ and /data/local/tmp/ directories respectively on the cloud phone.

  2. Pack the files into a TAR package and upload it to an OBS bucket.

    Example API:

    POST https://${CPH Endpoint}/v1/${project_id}/cloud-phone/phones/batch-storage 
    Header: 
    Content-Type: application/json 
    X-Auth-Token: ${token} 
    Body: 
    { 
        "storage_infos": [{ 
            "phone_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
            "include_files": [ 
                "/data/local/huawei/test.txt", 
                "/data/local/tmp/test.sh" 
            ], 
            "bucket_name": "${bucket_name}", 
            "object_path": "apk/${package_name}_${version_name}.tar" 
        }] 
    }

    Parameter descriptions:

    • The elements in include_files is the absolute paths of the files to be packed on the cloud phone.
    • ${package_name} in object_path supports only one of com.cph.config, com.cph.config.level1, and com.cph.config.level2. ${version_name} is used to identify the configuration package version and can be customized.
  3. Push the TAR package of the configuration file to the target cloud phone server. For details, see Pushing the TAR Package of an Application to the Shared Space.

    Example API

    POST https://${CPH Endpoint}/v1/${projectId}/cloud-phone/phones/share-apps
    Header: 
    Content-Type: application/json 
    X-Auth-Token: ${token} 
    Body:
    { 
        "package_name": "${package_name}", 
        "bucket_name": "${bucket_name}",  
        "object_path": "apk/${package_name}_${version_name}.tar",
        "pre_install_app": 1, 
        "server_ids": [
            "${server_id1}",
            "${server_id2}"
        ] 
    }

    Set pre_install_app to 1 during push.

  4. Reset or restart cloud phones to deploy all the files in the package to the corresponding directories of the phones.
    1. Deploying a configuration file package on a cloud phone will occupy the storage space of the cloud phone. Ensure that the configuration file package is not too large.
    2. You are advised to store the required files in a fixed directory on the cloud phone for easier file management. Then, pack these files into the com.cph.config package.
    3. If all the three configuration packages com.cph.config, com.cph.config.level1, and com.cph.config.level2 need to be preset, they will be deployed in the sequence of com.cph.config, com.cph.config.level1, and com.cph.config.level2 when cloud phones are reset or restarted. The files with the same name will be overwritten in the same sequence.