Loading core/java/android/os/SystemClock.java +12 −4 Original line number Original line Diff line number Diff line Loading @@ -104,6 +104,8 @@ import java.time.ZoneOffset; public final class SystemClock { public final class SystemClock { private static final String TAG = "SystemClock"; private static final String TAG = "SystemClock"; private static volatile IAlarmManager sIAlarmManager; /** /** * This class is uninstantiable. * This class is uninstantiable. */ */ Loading Loading @@ -151,8 +153,7 @@ public final class SystemClock { * @return if the clock was successfully set to the specified time. * @return if the clock was successfully set to the specified time. */ */ public static boolean setCurrentTimeMillis(long millis) { public static boolean setCurrentTimeMillis(long millis) { final IAlarmManager mgr = IAlarmManager.Stub final IAlarmManager mgr = getIAlarmManager(); .asInterface(ServiceManager.getService(Context.ALARM_SERVICE)); if (mgr == null) { if (mgr == null) { Slog.e(TAG, "Unable to set RTC: mgr == null"); Slog.e(TAG, "Unable to set RTC: mgr == null"); return false; return false; Loading Loading @@ -280,8 +281,7 @@ public final class SystemClock { * @hide * @hide */ */ public static long currentNetworkTimeMillis() { public static long currentNetworkTimeMillis() { final IAlarmManager mgr = IAlarmManager.Stub final IAlarmManager mgr = getIAlarmManager(); .asInterface(ServiceManager.getService(Context.ALARM_SERVICE)); if (mgr != null) { if (mgr != null) { try { try { return mgr.currentNetworkTimeMillis(); return mgr.currentNetworkTimeMillis(); Loading @@ -296,6 +296,14 @@ public final class SystemClock { } } } } private static IAlarmManager getIAlarmManager() { if (sIAlarmManager == null) { sIAlarmManager = IAlarmManager.Stub .asInterface(ServiceManager.getService(Context.ALARM_SERVICE)); } return sIAlarmManager; } /** /** * Returns a {@link Clock} that starts at January 1, 1970 00:00:00.0 UTC, * Returns a {@link Clock} that starts at January 1, 1970 00:00:00.0 UTC, * synchronized using a remote network source outside the device. * synchronized using a remote network source outside the device. Loading Loading
core/java/android/os/SystemClock.java +12 −4 Original line number Original line Diff line number Diff line Loading @@ -104,6 +104,8 @@ import java.time.ZoneOffset; public final class SystemClock { public final class SystemClock { private static final String TAG = "SystemClock"; private static final String TAG = "SystemClock"; private static volatile IAlarmManager sIAlarmManager; /** /** * This class is uninstantiable. * This class is uninstantiable. */ */ Loading Loading @@ -151,8 +153,7 @@ public final class SystemClock { * @return if the clock was successfully set to the specified time. * @return if the clock was successfully set to the specified time. */ */ public static boolean setCurrentTimeMillis(long millis) { public static boolean setCurrentTimeMillis(long millis) { final IAlarmManager mgr = IAlarmManager.Stub final IAlarmManager mgr = getIAlarmManager(); .asInterface(ServiceManager.getService(Context.ALARM_SERVICE)); if (mgr == null) { if (mgr == null) { Slog.e(TAG, "Unable to set RTC: mgr == null"); Slog.e(TAG, "Unable to set RTC: mgr == null"); return false; return false; Loading Loading @@ -280,8 +281,7 @@ public final class SystemClock { * @hide * @hide */ */ public static long currentNetworkTimeMillis() { public static long currentNetworkTimeMillis() { final IAlarmManager mgr = IAlarmManager.Stub final IAlarmManager mgr = getIAlarmManager(); .asInterface(ServiceManager.getService(Context.ALARM_SERVICE)); if (mgr != null) { if (mgr != null) { try { try { return mgr.currentNetworkTimeMillis(); return mgr.currentNetworkTimeMillis(); Loading @@ -296,6 +296,14 @@ public final class SystemClock { } } } } private static IAlarmManager getIAlarmManager() { if (sIAlarmManager == null) { sIAlarmManager = IAlarmManager.Stub .asInterface(ServiceManager.getService(Context.ALARM_SERVICE)); } return sIAlarmManager; } /** /** * Returns a {@link Clock} that starts at January 1, 1970 00:00:00.0 UTC, * Returns a {@link Clock} that starts at January 1, 1970 00:00:00.0 UTC, * synchronized using a remote network source outside the device. * synchronized using a remote network source outside the device. Loading