-
Notifications
You must be signed in to change notification settings - Fork 4k
binder: Promote out of experimental status #9669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a021cb7
ee1d14c
a0fc978
724cab7
c163f1c
095259b
ff5e64c
7a283dd
f1f3ee5
e92f90c
5313582
1c9806e
6630c75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ | |
| import android.content.ComponentName; | ||
| import android.content.Context; | ||
| import android.content.Intent; | ||
| import io.grpc.ExperimentalApi; | ||
| import java.net.SocketAddress; | ||
|
|
||
| /** | ||
|
|
@@ -41,8 +40,7 @@ | |
| * fields, namely, an action of {@link ApiConstants#ACTION_BIND}, an empty category set and null | ||
| * type and data URI. | ||
| */ | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8022") | ||
| public class AndroidComponentAddress extends SocketAddress { // NOTE: Only temporarily non-final. | ||
| public final class AndroidComponentAddress extends SocketAddress { | ||
| private static final long serialVersionUID = 0L; | ||
|
|
||
| private final Intent bindIntent; // An "explicit" Intent. In other words, getComponent() != null. | ||
|
|
@@ -103,6 +101,10 @@ public static AndroidComponentAddress forComponent(ComponentName component) { | |
| new Intent(ApiConstants.ACTION_BIND).setComponent(component)); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the Authority which is the package name of the target app. | ||
| * See {@link android.content.ComponentName}. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. between paragraphs (https://google.github.io/styleguide/javaguide.html#s7.1.2-javadoc-paragraphs) |
||
| */ | ||
| public String getAuthority() { | ||
| return getComponent().getPackageName(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Copyright 2022 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc.binder; | ||
ejona86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import android.os.IBinder; | ||
| import io.grpc.Internal; | ||
|
|
||
| /** | ||
| * Helper class to expose IBinderReceiver methods for legacy internal builders. | ||
| */ | ||
| @Internal | ||
| public class BinderInternal { | ||
|
|
||
| /** | ||
| * Set the receiver's {@link IBinder} using {@link IBinderReceiver#set(IBinder)}. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| */ | ||
| static void setIBinder(IBinderReceiver receiver, IBinder binder) { | ||
| receiver.set(binder); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,18 +42,21 @@ | |
|
|
||
| /** Static factory methods for creating standard security policies. */ | ||
| @CheckReturnValue | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8022") | ||
| public final class SecurityPolicies { | ||
|
|
||
| private static final int MY_UID = Process.myUid(); | ||
| private static final int SHA_256_BYTES_LENGTH = 32; | ||
|
|
||
| private SecurityPolicies() {} | ||
|
|
||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8022") | ||
| public static ServerSecurityPolicy serverInternalOnly() { | ||
| return new ServerSecurityPolicy(); | ||
| } | ||
cbianchi-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Creates a default {@link SecurityPolicy} that checks authorization based on UID. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "... that allows access only to callers with the same UID as the current process." |
||
| */ | ||
| public static SecurityPolicy internalOnly() { | ||
| return new SecurityPolicy() { | ||
| @Override | ||
|
|
@@ -66,6 +69,7 @@ public Status checkAuthorization(int uid) { | |
| }; | ||
| } | ||
|
|
||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8022") | ||
| public static SecurityPolicy permissionDenied(String description) { | ||
| Status denied = Status.PERMISSION_DENIED.withDescription(description); | ||
| return new SecurityPolicy() { | ||
|
|
@@ -84,6 +88,7 @@ public Status checkAuthorization(int uid) { | |
| * @param requiredSignature the allowed signature of the allowed package. | ||
| * @throws NullPointerException if any of the inputs are {@code null}. | ||
| */ | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8022") | ||
| public static SecurityPolicy hasSignature( | ||
| PackageManager packageManager, String packageName, Signature requiredSignature) { | ||
| return oneOfSignatures( | ||
|
|
@@ -99,6 +104,7 @@ public static SecurityPolicy hasSignature( | |
| * @throws NullPointerException if any of the inputs are {@code null}. | ||
| * @throws IllegalArgumentException if {@code requiredSignatureSha256Hash} is not of length 32. | ||
| */ | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8022") | ||
| public static SecurityPolicy hasSignatureSha256Hash( | ||
| PackageManager packageManager, String packageName, byte[] requiredSignatureSha256Hash) { | ||
| return oneOfSignatureSha256Hash( | ||
|
|
@@ -114,6 +120,7 @@ public static SecurityPolicy hasSignatureSha256Hash( | |
| * @throws NullPointerException if any of the inputs are {@code null}. | ||
| * @throws IllegalArgumentException if {@code requiredSignatures} is empty. | ||
| */ | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8022") | ||
| public static SecurityPolicy oneOfSignatures( | ||
| PackageManager packageManager, | ||
| String packageName, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.