Skip to content

Commit 99be6e9

Browse files
authored
Address Android 11's package visibility rules. (#11551)
1 parent d8f73e0 commit 99be6e9

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

documentation/android-binderchannel-status-codes.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@ Consider the table that follows as an BinderChannel-specific addendum to the “
2323
</td>
2424
</tr>
2525
<tr>
26-
<td>1
26+
<td>0
2727
</td>
28-
<td>Server app not installed
28+
<td><a href="https://developer.android.com/training/package-visibility">Server app not visible</a>.
29+
</td>
30+
<td rowspan="6" >bindService() returns false
31+
</td>
32+
<td rowspan="9" ><p>UNIMPLEMENTED<p>“The operation is not implemented or is not supported / enabled in this service.”
33+
</td>
34+
<td>Give up - This is an error in the client manifest.
2935
</td>
30-
<td rowspan="5" >bindService() returns false
36+
</tr>
37+
<tr>
38+
<td>1
3139
</td>
32-
<td rowspan="8" ><p>UNIMPLEMENTED<p>“The operation is not implemented or is not supported / enabled in this service.”
40+
<td>Server app not installed
3341
</td>
34-
<td rowspan="9" >Direct the user to install/reinstall the server app.
42+
<td rowspan="8" >Direct the user to install/reinstall the server app.
3543
</td>
3644
</tr>
3745
<tr>
@@ -90,6 +98,8 @@ Consider the table that follows as an BinderChannel-specific addendum to the “
9098
<td rowspan="5" ><p>PERMISSION_DENIED<p>
9199
“The caller does not have permission to execute the specified operation …”
92100
</td>
101+
<td>Direct the user to update the server app in the hopes that a newer version fixes this error in its manifest.
102+
</td>
93103
</tr>
94104
<tr>
95105
<td>10
@@ -315,13 +325,15 @@ According to a review of the AOSP source code, there are in fact several cases:
315325
1. The target package is not installed
316326
2. The target package is installed but does not declare the target Service in its manifest.
317327
3. The target package requests dangerous permissions but targets sdk &lt;= M and therefore requires a permissions review, but the caller is not running in the foreground and so it would be inappropriate to launch the review UI.
328+
4. The target package is not visible to the client due to [Android 11 package visibility rules](https://developer.android.com/training/package-visibility).
318329

319330
Status code mapping: **UNIMPLEMENTED**
320331

321332
(1) and (2) are interesting new possibilities unique to on-device RPC. (1) is straightforward and the most likely cause of (2) is that the user has an old version of the server app installed that predates its gRPC integration. Many clients will want to handle these cases, likely by directing the user to the app store in order to install/upgrade the server.
322333

323334
Unfortunately `UNIMPLEMENTED` doesn’t capture (3) but none of the other canonical status codes do either and we expect this case to be extremely rare.
324335

336+
(4) is intentially indistinguishable from (1) by Android design so we can't handle it differently. However, as a client manifest error, it's not something reasonable apps would handle at runtime anyway.
325337

326338
### bindService() throws SecurityException
327339

@@ -382,4 +394,4 @@ Android’s Parcel class exposes a mechanism for marshalling certain types of `R
382394

383395
The calling Activity or Service Context might be destroyed with a gRPC request in flight. Apps should cease operations when the Context hosting it goes away and this includes cancelling any outstanding RPCs.
384396

385-
Status code mapping: **CANCELLED**
397+
Status code mapping: **CANCELLED**

0 commit comments

Comments
 (0)