1 package com.android.server.deviceconfig;
2 
3 import android.annotation.NonNull;
4 import android.annotation.Nullable;
5 import android.content.Context;
6 import android.content.IntentSender;
7 import android.os.RecoverySystem;
8 
9 import java.io.IOException;
10 import java.time.ZoneId;
11 
12 /**
13  * Dependency injectors for {@link com.android.server.deviceconfig.UnattendedRebootManager} to
14  * enable unit testing.
15  */
16 interface UnattendedRebootManagerInjector {
17 
18   /** Time injectors. */
now()19   long now();
20 
zoneId()21   ZoneId zoneId();
22 
elapsedRealtime()23   long elapsedRealtime();
24 
25   /** Reboot time injectors. */
getRebootStartTime()26   int getRebootStartTime();
27 
getRebootEndTime()28   int getRebootEndTime();
29 
getRebootFrequency()30   int getRebootFrequency();
31 
32   /** Alarm injectors. */
setRebootAlarm(Context context, long rebootTimeMillis)33   void setRebootAlarm(Context context, long rebootTimeMillis);
34 
setPrepareForUnattendedRebootFallbackAlarm(Context context, long delayMillis)35   void setPrepareForUnattendedRebootFallbackAlarm(Context context, long delayMillis);
36 
cancelPrepareForUnattendedRebootFallbackAlarm(Context context)37   void cancelPrepareForUnattendedRebootFallbackAlarm(Context context);
38 
39   /** Connectivity injector. */
triggerRebootOnNetworkAvailable(Context context)40   void triggerRebootOnNetworkAvailable(Context context);
41 
42   /** {@link RecoverySystem} methods injectors. */
rebootAndApply(@onNull Context context, @NonNull String reason, boolean slotSwitch)43   int rebootAndApply(@NonNull Context context, @NonNull String reason, boolean slotSwitch)
44       throws IOException;
45 
prepareForUnattendedUpdate( @onNull Context context, @NonNull String updateToken, @Nullable IntentSender intentSender)46   void prepareForUnattendedUpdate(
47       @NonNull Context context, @NonNull String updateToken, @Nullable IntentSender intentSender)
48       throws IOException;
49 
isPreparedForUnattendedUpdate(@onNull Context context)50   boolean isPreparedForUnattendedUpdate(@NonNull Context context) throws IOException;
51 
requiresChargingForReboot(Context context)52   boolean requiresChargingForReboot(Context context);
53 
54   /** Regular reboot injector. */
regularReboot(Context context)55   void regularReboot(Context context);
56 }
57