Member-only story
Write AOSP System Service that extends the SystemService class
5 min readJan 18, 2025
In this article, we will see how to write a system service, which extends the SystemService class and starts automatically on boot. We’ll walk through creating a basic system service, setting it up, and starting when the device boots into the Android system.
Topics to implement and walkthrough AOSP source:
- Write the Service class that extends the SystemService class.
- Register custom Service to Android SystemServer.
- Build AOSP source with Service Integrated.
- Verify Logs and walkthroughs of source code.
- Add a periodic task into the custom service and check if it runs.
- Issues if we face any.
- Key Points captured.
Write the Service class
Create a Service named <YourServiceName> that extends SystemService like below.
public class BootPhaseService extends SystemService {
private static final String TAG = "BootPhaseService";
private final Context mContext;
public BootPhaseService(Context context) {
super(context);
mContext = context;
Slog.i(TAG, "BootPhaseService Constructor called");
}
}