Commit Graph

18 Commits

Author SHA1 Message Date
Ming-Chuan d6bb391449 [Build] Migrate Android NDK, android rules and platforms (#36116)
This commit does the following 3 things for Android bazel rules, which depends on each other

1. Update NDK to 26.2.11394342 (and a few other Android things)
2. Use rules_android_ndk instead of builtin `native.android_ndk_repository`
    * `third_party/android/android_configure.bzl` was a workaround for users who don't set `$ANDROID_NDK_HOME` env var. Now with rules_android_ndk, we can declare repo without registering the toolchain. Instead users who need NDK toolchain should use `--extra_toolchains` to manually register the toolchain, as shown in README.md.
3. Migrate to platforms. See https://bazel.build/concepts/platforms
    * Currently we declares android platforms that is needed for binder transport APK. Later gRPC repo can gradually migrate to platforms for other platforms.
    * The value of `crosstool_top` will still be `//external:android/crosstool` (which is the default value), so existings android `config_settings` will still work. We should migrate them to match with `@platforms//os:android` constraint later.

The platforms migration needs Bazel 7.0 to work so we also override bazel version in testing scripts.

Closes #36116

PiperOrigin-RevId: 617244655
2024-03-19 11:46:15 -07:00
Ming-Chuan 08181286e3
Add a ChannelArguments option for sepcify custom binder intent (#28723)
User can use
`grpc::ChannelArguments::SetString("grpc.binder.custom_android_intent_action_name", "...")`
to set custom binder intent.
2022-02-09 13:54:27 +08:00
Ming-Chuan 93733de253
Add SameSignatureSecurityPolicy for binder transport (#27816)
Tested signing example server and example client APKs with different
debug key, worked as intended.
2022-01-18 15:01:01 +08:00
Ming-Chuan 1777ddf3c3
Add an experimental binder transport API for pre-finding Java class (#27939)
Due to limitation of JVM, when user want to create binder channel in
threads created in unmanaged native code, they will need to call this
new API first to make sure Java helper classes can correctly be found.

Unused code in jni_utils.cc are also cleaned up in this commit
2021-11-05 16:01:02 +08:00
Ming-Chuan 5c0df85ea8
[BinderTransport] Avoid depending on NdkBinder at compile time (#27912)
* [BinderTransport] Avoid depending on NdkBinder at compile time

We would like to make it possible to use BinderTransport in a APK that
has min sdk version lower than 29 (NdkBinder was introduced at 29)

We copies constants and type definitions from Ndk headers, creates a
same name wrapper for every NdkBinder API we use in
grpc_binder::ndk_util namespace.

We will try to load libbinder_ndk.so and resolve the symbol when the
NdkBinder API wrappers are invoked.

* regenerate projects

* Add GRPC_NO_BINDER guard
2021-11-05 01:40:49 +08:00
Ming-Chuan d92baa99d6
Expose grpc++_binder through grpc++ (#27891)
A config option is provided so user can pass --define=grpc_no_binder=true to bazel, or passing `-DGRPC_NO_BINDER` to compiler to disable the dependency.
2021-11-03 23:30:17 +08:00
Ming-Chuan e0f793b3d3
Expose experimental binder transport API (#27632)
* Expose experimental binder transport API

New headers are added
`grpcpp/create_channel_binder.h `: interfaces for creating client
channel
`grpcpp/security/binder_credentials.h`: interfaces for binder server
credentials
`grpcpp/security/binder_security_policy.h`: interfaces for binder
security policy, which is used by both server and client. Individual
security policies are merged into this single header.

Users can now depend on the `grpc++_binder` target to use the headers
listed above.

* Regenerate projects
2021-11-01 20:25:22 +08:00
Ming-Chuan dcabe420cc
[BinderTransport] Create client channel instead of direct channel (#27790)
* [BinderTransport] Create client channel instead of direct channel

In this commit we create a client channel instead of direct channel.

BinderConnector is added to connect subchannel when the user actually
make RPC call using the channel.

BindToOnDeviceServerService() is not required anymore since now the
actual connection is delay until the channel is used.

* Regenerate projects.
2021-10-28 15:52:21 +08:00
Ming-Chuan 66d4e0ccb1
Consolidate binder targets into a single target in top-level BUILD file (#27719)
* Move binder targets into a single target in top-level BUILD file

* Regenerate projects
2021-10-18 17:29:27 +08:00
Ming-Chuan f58f903a4f
Add helper function for getting endpoint binder in Java (#27598)
Also update the server side URI scheme to use path instead of authority

See gRFC L85-core-binder-transport.md for more details
2021-10-08 10:54:22 +08:00
Ming-Chuan 332713a35a
Implement BinderTransport SecurityPolicies that requires no JNI (#27573)
This commit

1. Implements the security policies that does not require JNI. This
includes a security policy that always allow connection and a security
policy that allows connection when remote UID is the same us local UID.
2. Add security policy as an argument in our interfaces. Old interfaces
are temporarily preserved so compilation will not suddenly break when we
import the code to internal repo.
3. Pumping the security policy from the public interfaces to the code
that handles SETUP_TRANSPORT transaction.
4. Abort the transport setup when the security policy is not satisfied.

Since meaningful tests will require to be run in real Android
environment, we will implement it later. For now, this change is
manually tested with example APKs.

For security policies that need to invoke Java to check authorization,
we will implement them in later.
2021-10-07 00:21:51 +08:00
Ming-Chuan 4cb907457b
Rename binder transport example client app (#27344)
Rename the app to exampleclient

Also moved and updated README.md
2021-09-15 13:29:29 +08:00
Craig Tiller ea389c00c2
Adjust include order per style guide (#27175)
Introduce clang-format configuration to sort includes closer to our rules.
2021-09-08 12:14:44 -07:00
Ta-Wei Tu 3a5e844b38
[binder] Implicitly initialize the binder pool (#27261) 2021-09-07 19:27:46 -07:00
Ming-Chuan 2dfa59e898
Enable server side implementation in example binder server app (#27259) 2021-09-07 12:11:51 +08:00
Ming-Chuan 73003f8527
Add BinderTransport example server app (#27067)
Some code are commented out because the server interface has not been
merged yet.

After this, user should be able to install both apps on Android device
and test if basic unary call works or not
2021-08-30 18:26:49 +08:00
Ming-Chuan 9da755a61e
Import binder transport channel create interface (#27007)
Also try use the API in example apk to make sure the binder transport
code and the rest of gRPC compiles with the Android toolchain

We will properly expose our interface later.
2021-08-20 13:03:21 +08:00
Ming-Chuan 746eaf6c48
Add BinderTransport example app (#26747)
This commit adds an app that will be served as BinderTransport example
later.

Currently the app simply calls C++ function when button is pressed. In
the future the C++ function will run BinderTransport gRPC example
instead.

Tests not included in this commit, later we will add a build test to
CI to make sure this apk is always build-able. (This app will also be
used to make sure our BinderTransport implementation is compile-able
with Android toolchain, on GitHub) For now we exclude this target in
bazel build test.

Changes are made to WORKSPACE file in order to support android builds.

Build instructions are documented at
examples/android/binder/java/io/grpc/binder/cpp/example/README.md
2021-07-27 11:18:59 +08:00