You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<tdrowspan="8" >Direct the user to install/reinstall the server app.
43
44
</td>
44
45
</tr>
45
46
<tr>
46
47
<td>2
47
48
</td>
48
-
<td>Old version of the server app doesn’t declare the target android.app.Service in its manifest.
49
+
<td>Server app not installed
49
50
</td>
50
51
</tr>
51
52
<tr>
52
53
<td>3
53
54
</td>
54
-
<td>Target android.app.Service is disabled
55
+
<td>Old version of the server app doesn’t declare the target android.app.Service in its manifest.
55
56
</td>
56
57
</tr>
57
58
<tr>
58
59
<td>4
59
60
</td>
60
-
<td>The whole server app is disabled
61
+
<td>Target android.app.Service is disabled
61
62
</td>
62
63
</tr>
63
64
<tr>
64
65
<td>5
65
66
</td>
66
-
<td>Server app predates <ahref="https://developer.android.com/guide/topics/permissions/overview">the Android M permissions model</a> and the user must review and approve some newly requested permissions before it can run.
67
+
<td>The whole server app is disabled
67
68
</td>
68
69
</tr>
69
70
<tr>
70
71
<td>6
71
72
</td>
73
+
<td>Server app predates <ahref="https://developer.android.com/guide/topics/permissions/overview">the Android M permissions model</a> and the user must review and approve some newly requested permissions before it can run.
74
+
</td>
75
+
</tr>
76
+
<tr>
77
+
<td>7
78
+
</td>
72
79
<td>Target android.app.Service doesn’t recognize grpc binding Intent (old version of server app?)
73
80
</td>
74
81
<td>onNullBinding() ServiceConnection callback
75
82
</td>
76
83
</tr>
77
84
<tr>
78
-
<td>7
85
+
<td>8
79
86
</td>
80
87
<td>Method not found on the io.grpc.Server (old version of server app?)
81
88
</td>
82
89
<tdrowspan="2" >N/A
83
90
</td>
84
91
</tr>
85
92
<tr>
86
-
<td>8
93
+
<td>9
87
94
</td>
88
95
<td>Request cardinality violation (old version of server app expects unary rather than streaming, say)
89
96
</td>
90
97
</tr>
91
98
<tr>
92
-
<td>9
99
+
<td>10
93
100
</td>
94
101
<td>Old version of the server app exposes target android.app.Service but doesn’t android:export it.
95
102
</td>
@@ -102,37 +109,37 @@ Consider the table that follows as an BinderChannel-specific addendum to the “
102
109
</td>
103
110
</tr>
104
111
<tr>
105
-
<td>10
112
+
<td>11
106
113
</td>
107
114
<td>Target android.app.Service requires an <android:permission> that client doesn’t hold.
108
115
</td>
109
116
<td>Prompt the user to grant the needed Android permission
110
117
</td>
111
118
</tr>
112
119
<tr>
113
-
<td>11
120
+
<td>12
114
121
</td>
115
122
<td>Violations of the security policy for miscellaneous Android features like android:isolatedProcess, android:externalService, android:singleUser, instant apps, BIND_TREAT_LIKE_ACTIVITY, etc,
116
123
</td>
117
124
<tdrowspan="3" >Give up - This is a programming or packaging error that only the app developer can fix.
118
125
</td>
119
126
</tr>
120
127
<tr>
121
-
<td>12
128
+
<td>13
122
129
</td>
123
130
<td>Calling Android UID not allowed by ServerSecurityPolicy
124
131
</td>
125
132
<tdrowspan="2" >N/A
126
133
</td>
127
134
</tr>
128
135
<tr>
129
-
<td>13
136
+
<td>14
130
137
</td>
131
138
<td>Server Android UID not allowed by client’s SecurityPolicy
132
139
</td>
133
140
</tr>
134
141
<tr>
135
-
<tdrowspan="3" >14
142
+
<tdrowspan="3" >15
136
143
</td>
137
144
<tdrowspan="3" >Server process crashed or killed with request in flight.
138
145
</td>
@@ -154,29 +161,29 @@ Consider the table that follows as an BinderChannel-specific addendum to the “
154
161
</td>
155
162
</tr>
156
163
<tr>
157
-
<td>15
164
+
<td>16
158
165
</td>
159
166
<td>Server app is currently being upgraded to a new version
<td>Source Context for bindService() is destroyed with a request in flight
182
189
</td>
@@ -188,19 +195,19 @@ Consider the table that follows as an BinderChannel-specific addendum to the “
188
195
</td>
189
196
<tdrowspan="2" >Give up for now.
190
197
<p>
191
-
(Re. 18: The caller can try again later when the user opens the source Activity or restarts the source Service)
198
+
(Re. 19: The caller can try again later when the user opens the source Activity or restarts the source Service)
192
199
</td>
193
200
</tr>
194
201
<tr>
195
-
<td>19
202
+
<td>20
196
203
</td>
197
204
<td>Client application cancelled the request
198
205
</td>
199
206
<td>N/A
200
207
</td>
201
208
</tr>
202
209
<tr>
203
-
<tdrowspan="2" >19
210
+
<tdrowspan="2" >21
204
211
</td>
205
212
<tdrowspan="2" >Bug in Android itself or the way the io.grpc.binder transport uses it.
206
213
</td>
@@ -218,15 +225,15 @@ Consider the table that follows as an BinderChannel-specific addendum to the “
218
225
</td>
219
226
</tr>
220
227
<tr>
221
-
<td>20
228
+
<td>22
222
229
</td>
223
230
<td>Flow-control protocol violation
224
231
</td>
225
232
<tdrowspan="2" >N/A
226
233
</td>
227
234
</tr>
228
235
<tr>
229
-
<td>21
236
+
<td>23
230
237
</td>
231
238
<td>Can’t parse request/response proto
232
239
</td>
@@ -236,27 +243,27 @@ Consider the table that follows as an BinderChannel-specific addendum to the “
236
243
237
244
### Ambiguity
238
245
239
-
We say a status code is ambiguous if it maps to two error cases that reasonable clients want to handle differently. For instance, a client may have good reasons to handle error cases 9 and 10 above differently. But they can’t do so based on status code alone because those error cases map to the same one.
246
+
We say a status code is ambiguous if it maps to two error cases that reasonable clients want to handle differently. For instance, a client may have good reasons to handle error cases 10 and 11 above differently. But they can’t do so based on status code alone because those error cases map to the same one.
240
247
241
-
In contrast, for example, even though error case 18 and 19 both map to the status code (`CANCELLED`), they are not ambiguous because we see no reason that clients would want to distinguish them. In both cases, clients will simply give up on the request.
248
+
In contrast, for example, even though error case 19 and 20 both map to the status code (`CANCELLED`), they are not ambiguous because we see no reason that clients would want to distinguish them. In both cases, clients will simply give up on the request.
242
249
243
250
244
251
#### Ambiguity of PERMISSION_DENIED and Mitigations
245
252
246
253
The mapping above has only one apparently ambiguous status code: `PERMISSION_DENIED`. However, this isn’t so bad because of the following:
247
254
248
-
The use of `<android:permission>`s for inter-app IPC access control (error case 10) is uncommon. Instead, we recommend that server apps only allow IPC from a limited set of client apps known in advance and identified by signature.
255
+
The use of `<android:permission>`s for inter-app IPC access control (error case 11) is uncommon. Instead, we recommend that server apps only allow IPC from a limited set of client apps known in advance and identified by signature.
249
256
250
-
However, there may be gRPC server apps that want to use custom <android:permission>’s to let the end user decide which arbitrary other apps can make use of its gRPC services. In that case, clients should preempt error case 10 simply by [checking whether they hold the required permissions](https://developer.android.com/training/permissions/requesting) before sending a request.
257
+
However, there may be gRPC server apps that want to use custom <android:permission>’s to let the end user decide which arbitrary other apps can make use of its gRPC services. In that case, clients should preempt error case 11 simply by [checking whether they hold the required permissions](https://developer.android.com/training/permissions/requesting) before sending a request.
251
258
252
-
Server apps can avoid error case 9 by never reusing an android.app.Service as a gRPC host if it has ever been android:exported=false in some previous app version. Instead they should simply create a new android.app.Service for this purpose.
259
+
Server apps can avoid error case 10 by never reusing an android.app.Service as a gRPC host if it has ever been android:exported=false in some previous app version. Instead they should simply create a new android.app.Service for this purpose.
253
260
254
-
Only error cases 11 - 13 remain, making `PERMISSION_DENIED` unambiguous for the purpose of error handling. Reasonable client apps can handle it in a generic way by displaying an error message and/or proceeding with degraded functionality.
261
+
Only error cases 12 - 14 remain, making `PERMISSION_DENIED` unambiguous for the purpose of error handling. Reasonable client apps can handle it in a generic way by displaying an error message and/or proceeding with degraded functionality.
255
262
256
263
257
264
#### Non-Ambiguity of UNIMPLEMENTED
258
265
259
-
The `UNIMPLEMENTED` status code corresponds to quite a few different problems with the server app: It’s either not installed, too old, or disabled in whole or in part. Despite the diversity of underlying error cases, we believe most client apps will and should handle `UNIMPLEMENTED` in the same way: by sending the user to the app store to (re)install the server app. Reinstalling might be overkill for the disabled cases but most end users don't know what it means to enable/disable an app and there’s neither enough space in a UI dialog nor enough reader attention to explain it. Reinstalling is something users likely already understand and very likely to cure problems 1-8.
266
+
The `UNIMPLEMENTED` status code corresponds to quite a few different problems with the server app: It’s either not installed, too old, misconfigured, or disabled in whole or in part. Despite the diversity of underlying error cases, we believe most client apps will and should handle `UNIMPLEMENTED` in the same way: by sending the user to the app store to (re)install the server app. Reinstalling might be overkill for the disabled cases but most end users don't know what it means to enable/disable an app and there’s neither enough space in a UI dialog nor enough reader attention to explain it. Reinstalling is something users likely already understand and likely to cure problems 0-9 (once a fixed version of the server is available).
260
267
261
268
262
269
## Detailed Discussion of Binder Failure Modes
@@ -326,14 +333,15 @@ According to a review of the AOSP source code, there are in fact several cases:
326
333
2. The target package is installed but does not declare the target Service in its manifest.
327
334
3. The target package requests dangerous permissions but targets sdk <= 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
335
4. The target package is not visible to the client due to [Android 11 package visibility rules](https://developer.android.com/training/package-visibility).
336
+
5. One of the new [Safer Intents](https://developer.android.com/about/versions/15/behavior-changes-15#safer-intents) rules is violated. Most commonly, the bind `Intent` specifies a `ComponentName` explicitly but doesn't match any of its <intent-filter>s.
329
337
330
338
Status code mapping: **UNIMPLEMENTED**
331
339
332
340
(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.
333
341
334
342
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.
335
343
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.
344
+
(4) and (5) are intentially indistinguishable from (1) by Android design so we can't handle them differently. However, as an error in its own manifest, (4) isn't something a reasonable client would handle at runtime anyway. (5) is an error in the server manifest and so, just like the other cases, the best practice for handling it is to send the user to the app store in the hope that the server can be updated with a fix.
0 commit comments