VMOS Cloud API
  • 简体中文
  • English
  • 简体中文
  • English
  • Product Introduction
  • Product Type
  • Product Billing
  • OpenAPI
    • User Guide
    • API Documentation
    • Error Code
    • Instance Property List
    • Android device modification attribute list
    • Callback Task Business Type Codes
    • Changelog
  • Android SDK
    • Example Construction
    • API Documentation
    • Callback Functions
    • Error Code
    • Changelog
  • Web H5 SDK
    • Example Build
    • API Documentation
    • H5 SDK Callback Functions
    • Error Code
    • Change log
  • Windows PC SDK
    • Example Setup
    • API Documentation
    • Callback Functions
    • Changelog
  • Edge-Cloud Communication Development
    • AIDL Integration Method
    • System Service API (AIDL)
  • Similar to XP, LSP Hook framework

    • Xposed-like / LSPosed Framework
    • Sensor Data Dynamic Simulation
  • Related agreements

End-Side Communication with Cloud Phone (AIDL Method)

1. Enable AIDL in Project's app/build.gradle

Example with build.gradle.kts:

android {
    // ...
    // Enable AIDL
    buildFeatures {
        aidl = true
    }
}

2. Create AIDL Files

  1. Create an aidl folder under the app/src/main directory.
  2. Download the AIDL package and extract it to this directory (full path: aidl.cloud.api.server).

AIDL File Download:
Click to download aidl.zip

3. Connect to AIDL Service in App Project

Example in Kotlin:

// 1. Create ServiceConnection
private val mControl = object : ServiceConnection {
    override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
        LogUtils.d("Created Control AIDL")
        control = ControlInterface.Stub.asInterface(service)
        MyAidlManager.setControlAidl(control)
    }

    override fun onServiceDisconnected(name: ComponentName?) {
        LogUtils.d("Control AIDL disconnected")
        // Reconnect with delay after disconnection
        GlobalScope.launch {
            delay(3000)
            startMyService()
        }
    }
}

private val mRoot = object : ServiceConnection {
    override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
        LogUtils.d("Created Root AIDL")
        root = RootInterface.Stub.asInterface(service)
        MyAidlManager.setRootAidl(root)
    }

    override fun onServiceDisconnected(name: ComponentName?) {
        LogUtils.d("Root AIDL disconnected")
        // Reconnect with delay after disconnection
        GlobalScope.launch {
            delay(3000)
            startMyService()
        }
    }
}

// 2. Global Singleton for Managing AIDL Interfaces
object MyAidlManager {
    var control: ControlInterface? = null
    var root: RootInterface? = null

    fun setControlAidl(control: ControlInterface?) {
        this.control = control
    }

    fun setRootAidl(root: RootInterface?) {
        this.root = root
    }
}

// 3. Bind AIDL Services
private fun startMyService() {
    val intentControl = Intent("aidl.cloud.api.ControlServer").apply {
        setPackage("com.cloud.rtcgesture")
    }
    bindService(intentControl, mControl, BIND_AUTO_CREATE)

    val intentRoot = Intent("aidl.cloud.api.RootServer").apply {
        setPackage("com.cloud.rtcgesture")
    }
    bindService(intentRoot, mRoot, BIND_AUTO_CREATE)
}

// 4. Unbind Services (Recommended to call in Activity/Service onDestroy)
override fun onDestroy() {
    super.onDestroy()
    unbindService(mControl)
    unbindService(mRoot)
}

// 5. Start Services (Usually call at appropriate time, e.g., in Application or Activity onCreate)
startMyService()

4. Add Adaptation in App's AndroidManifest.xml

<manifest>
    <!-- ... -->

    <queries>
        <package android:name="com.cloud.rtcgesture" />
    </queries>

</manifest>

After completing the above steps, you can communicate with the cloud phone service via AIDL on the Android side.


### AIDL File Download
[Click to download (aidl.zip)](/vmoscloud/doc/aidl.zip)
Prev
Windows PC SDK