Member-only story

Write AOSP System Service that extends the SystemService class

Narendra Harny
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.

Photo by NASA on Unsplash

Topics to implement and walkthrough AOSP source:

  1. Write the Service class that extends the SystemService class.
  2. Register custom Service to Android SystemServer.
  3. Build AOSP source with Service Integrated.
  4. Verify Logs and walkthroughs of source code.
  5. Add a periodic task into the custom service and check if it runs.
  6. Issues if we face any.
  7. 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");
}
}

--

--

Narendra Harny
Narendra Harny

Written by Narendra Harny

Connect on https://medium.com/make-android | Write On, Android AOSP & Applications | Python | DevOps | Java | C++ | Kotlin | Shell | Linux | Android Auto | IVI

Responses (2)