Injecting system calls into alarm manager
Injecting and mocking dependencies to make the service unit testable.
Shuffled around initialization to make that possible.
Also added the first batch of unit tests. The idea is to have extensive
coverage of minute pieces of alarm manager logic, which should help us
catch any regressions caused by future changes to the code.
Test: atest com.android.server.AlarmManagerServiceTest
atest CtsAlarmManagerTestCases
Bug: 111454659
Change-Id: Ifa1c09646f688cf5c41abe17d98dbc19978eac70
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 6431344..4664601 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -878,7 +878,8 @@
}
traceBeginAndSlog("StartAlarmManagerService");
- mSystemServiceManager.startService(AlarmManagerService.class);
+ mSystemServiceManager.startService(new AlarmManagerService(context));
+
traceEnd();
traceBeginAndSlog("InitWatchdog");