README.md
1<!--
2 Copyright (C) 2023 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License
15 -->
16
17## Reference implementation for Vendor Service Controller's service
18
19This project has the reference implementation for a service which can be used for vendor service
20controller. Vendor service controller reads different service components from RRO configuration
21(config_earlyStartupServices) and these
22services are started/bound by Vendor service controller. Vendor service controller is part of
23CarService. The config needs to be defined in the following format:
24
25```
26 <item>com.bar.foo/.Service#bind={bind|start|startForeground},
27 user={all|system|foreground|visible|backgroundVisible},
28 trigger={asap|resume|userUnlocked|userPostUnlocked}</item>
29
30 bind: bind - start service with Context#bindService
31 start - start service with Context#startService
32 startForeground - start service with Context#startForegroundService
33 If service was bound it will be restarted unless it is constantly crashing.
34 The default value is 'start'
35 user: all - the service will be bound/started for system and all visible users
36 system - the service will be started/bound only for system user (u0)
37 foreground - the service will be bound/started only for foreground users
38 visible - the service will be bound/started only for visible users (as defined by
39 `UserManager#isUserVisible()`).
40 backgroundVisible - the service will be bound/started only for background users that
41 are visible.
42 The default value is 'all'
43 trigger: indicates when the service needs to be started/bound
44 asap - the service might be bound when user is not fully loaded, be careful with
45 this value, the service also needs to have directBootAware flag set to true
46 resume - start service when the device resumes from suspend (suspend-to-RAM, or
47 suspend-to-disk).
48 userUnlocked - start service when user unlocked the device
49 userPostUnlocked - start service later after user unlocked. This is used when the
50 service is not urgent and can wait to start.
51 The default value is 'userUnlocked'
52 maxRetries: the maximum number of attempts to rebind/restart a disconnected service.
53 Retries start with 4 second initial delay, being doubled after each failed attempt.
54 The default value is 6.
55
56 If the service bound/started for foreground user it will be unbound/stopped when user
57 is no longer foreground.
58```
59
60Service bound to CarService are special. As CarService is a persistent process, these services
61bound with CarService would be running as
62PROCESS_STATE_IMPORTANT_FOREGROUND, It means they would have higher priority and would not be killed
63due to resource constraints. They can be killed based on different user scope. For example, services
64running for visible user only will be killed when user is no longer visible. By default, these
65services don't have access to things like location, camera, microphone or network.
66
67## Remaining work
68b/308208710
69
70b/308208631
71
72b/306704239
73
74
75