ARMCLOUD Documentation Center
  • 简体中文
  • English
  • 简体中文
  • English
  • Product introduction
  • Product billing
  • Server OpenAPI
    • Usage Guide
    • API Signature v1.0
    • API Reference
    • Error Codes
    • Callback Business Type Codes
    • Instance List
    • Android Instance Property List
    • Changelog
  • Android SDK
    • Example Setup
    • Interface Description
    • Callback Function
    • Error Code
    • Changelog
  • Web H5 SDK
    • Example Setup
    • Interface Description
    • Callback Function
    • Error Code
    • Changelog
  • Windows PC SDK
    • Example Setup
    • Interface Description
    • Callback Function
    • Changelog
  • Edge-Cloud Communication Development
    • AIDL Access Method
    • System Service API (AIIDL)
  • Scenario solutions
    • XP-like LSP Hook framework
    • Dynamic simulation of sensor data
  • ADI Collection Tool
  • FAQ
    • Platform Basics
    • Storage
    • Network Connectivity
    • Application Management
    • Development and Integration
    • Performance Optimization
    • Billing
    • Technical Support
  • Related agreements
    • Cloud Phone SDK Privacy Policy

1. Open AIDL in build.gradle under the project app directory

Taking build.gradle.kts as an example

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

2. Create the AID file

1. Create an AIDEL folder in app/src/main, download the AIDL compressed file, and extract it into the AIDL directory (full path is AIDL.cloud.API.server)

3. Connect the AID service in the app project

Using kotiln code as an example

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

     override fun onServiceDisconnected(p0: ComponentName?) {
         LogUtils.d("Disconnect the connection")
         //After disconnecting, it reconnects
         GlobalScope.launch {
             delay(3000)
                startMyService()
            }
        }
    }

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

        override fun onServiceDisconnected(p0: ComponentName?) {
           LogUtils.d("Disconnect the connection")
           //After disconnecting, it reconnects
           GlobalScope.launch {
               delay(3000)
               startMyService()
           }
        }
    }

    2.Set up a globally available utility
    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 the AID service
    fun startMyService(){
     val intent = Intent("aidl.cloud.api.ControlServer")
     intent.setPackage("com.cloud.rtcgesture")
     bindService(intent, mControl, BIND_AUTO_CREATE)

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

    4.Service shutdown
    override fun onDestroy() {
       super.onDestroy()
       unbindService(mControl)
       unbindService(mRoot)
    }

 5.Launch service
    startMyService()

4. Add adaptation under the AndroidManifest.xml in the app directory

    <manifest>

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

    </manifest>

AIDL File Download

[Click to download (aidl.zip)] (/aidl.zip)

Prev
Windows PC SDK
Next
Scenario solutions