GithubHelp home page GithubHelp logo

binder_rs's Introduction

binder_rs

The stub libbinder_ndk.so in ndk's sysroot hides some apis, so that we cannot link our libbiner_rs to it. However, we can rebuild a stub so to make linker happy. The stub source is generated from symbols.txt, whose contents are extracted from prebuilt libbinder_ndk.so from aosp-mainline.

The libbinder_ndk.so is introduced in api-29, you need to compile it with specified target api level. The compilation won't failed if api is lower than 29, because we build the dynamic library on ourselves.

We use ndk-build to build the stub so, ANDROID_NDK_HOME must be set in your env !

sys/src/include_* from platform/frameworks/native/libs/binder/ndk

Example

  1. Build

    cargo ndk -t arm64-v8a --platform=29 --bindgen build
    
  2. Push file to phone

    adb push target/aarch64-linux-android/debug/binder-example /data/local/tmp
    
  3. Run 2 adb shell

    Run server:

    adb shell
    su -c /data/local/tmp/binder-example server
    

    Run client:

    adb shell
    su -c /data/local/tmp/binder-example client
    

Test

  1. Build

    cargo ndk -t arm64-v8a --platform=29 --bindgen build
    
  2. Push files to phone

    adb push target/aarch64-linux-android/debug/binder-tests /data/local/tmp
    
  3. Build unittest binary

    cargo ndk -t arm64-v8a --platform=29 --bindgen test --bin binder-tests --no-run
    
  4. Push files to phone

    adb push target/aarch64-linux-android/debug/deps/binder_tests-acf830ec15b8864e /data/local/tmp
    
  5. Run test

    adb shell
    cd /data/local/tmp/ && su -c ./binder_tests-acf830ec15b8864e
    

    if you see error like this

    CANNOT LINK EXECUTABLE "/data/local/tmp/binder_tests-acf830ec15b8864e": cannot locate symbol "AIBinder_DeathRecipient_setOnUnlinked" referenced by "/data/local/tmp/binder_tests-acf830ec15b8864e"...
    

    This is because your android version is too low, the source is from android-mainline. You can try in avd, with Android U

binder_rs's People

Contributors

ylarod avatar tiann avatar 5ec1cff avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.