Rename TimerFileDescriptor to RealtimeScheduler
Test: TH
Change-Id: I756cb84425e7701b9340d4f6589da364b7c515f7
diff --git a/staticlibs/device/com/android/net/module/util/TimerFileDescriptor.java b/staticlibs/device/com/android/net/module/util/RealtimeScheduler.java
similarity index 92%
rename from staticlibs/device/com/android/net/module/util/TimerFileDescriptor.java
rename to staticlibs/device/com/android/net/module/util/RealtimeScheduler.java
index 9efb00c..bc3b3a5 100644
--- a/staticlibs/device/com/android/net/module/util/TimerFileDescriptor.java
+++ b/staticlibs/device/com/android/net/module/util/RealtimeScheduler.java
@@ -34,7 +34,7 @@
import java.util.PriorityQueue;
/**
- * Represents a Timer file descriptor object used for scheduling tasks with precise delays.
+ * Represents a realtime scheduler object used for scheduling tasks with precise delays.
* Compared to {@link Handler#postDelayed}, this class offers enhanced accuracy for delayed
* callbacks by accounting for periods when the device is in deep sleep.
*
@@ -42,24 +42,24 @@
*
* **Usage Examples:**
*
- * ** Scheduling recurring tasks with the same TimerFileDescriptor **
+ * ** Scheduling recurring tasks with the same RealtimeScheduler **
*
* ```java
- * // Create a TimerFileDescriptor
- * final TimerFileDescriptor timerFd = new TimerFileDescriptor(handler);
+ * // Create a RealtimeScheduler
+ * final RealtimeScheduler scheduler = new RealtimeScheduler(handler);
*
* // Schedule a new task with a delay.
- * timerFd.postDelayed(() -> taskToExecute(), delayTime);
+ * scheduler.postDelayed(() -> taskToExecute(), delayTime);
*
* // Once the delay has elapsed, and the task is running, schedule another task.
- * timerFd.postDelayed(() -> anotherTaskToExecute(), anotherDelayTime);
+ * scheduler.postDelayed(() -> anotherTaskToExecute(), anotherDelayTime);
*
- * // Remember to close the TimerFileDescriptor after all tasks have finished running.
- * timerFd.close();
+ * // Remember to close the RealtimeScheduler after all tasks have finished running.
+ * scheduler.close();
* ```
*/
-public class TimerFileDescriptor {
- private static final String TAG = TimerFileDescriptor.class.getSimpleName();
+public class RealtimeScheduler {
+ private static final String TAG = RealtimeScheduler.class.getSimpleName();
// EVENT_ERROR may be generated even if not specified, as per its javadoc.
private static final int FD_EVENTS = EVENT_INPUT | EVENT_ERROR;
private final CloseGuard mGuard = new CloseGuard();
@@ -155,12 +155,12 @@
}
/**
- * The TimerFileDescriptor constructor
+ * The RealtimeScheduler constructor
*
* Note: The constructor is currently safe to call on another thread because it only sets final
* members and registers the event to be called on the handler.
*/
- public TimerFileDescriptor(@NonNull Handler handler) {
+ public RealtimeScheduler(@NonNull Handler handler) {
mFdInt = TimerFdUtils.createTimerFileDescriptor();
mParcelFileDescriptor = ParcelFileDescriptor.adoptFd(mFdInt);
mHandler = handler;
@@ -237,7 +237,7 @@
}
/**
- * Close the TimerFileDescriptor. This implementation closes the underlying
+ * Close the RealtimeScheduler. This implementation closes the underlying
* OS resources allocated to represent this stream.
*/
public void close() {
diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/TimerFileDescriptorTest.kt b/staticlibs/tests/unit/src/com/android/net/module/util/RealtimeSchedulerTest.kt
similarity index 95%
rename from staticlibs/tests/unit/src/com/android/net/module/util/TimerFileDescriptorTest.kt
rename to staticlibs/tests/unit/src/com/android/net/module/util/RealtimeSchedulerTest.kt
index 3ad979e..30b530f 100644
--- a/staticlibs/tests/unit/src/com/android/net/module/util/TimerFileDescriptorTest.kt
+++ b/staticlibs/tests/unit/src/com/android/net/module/util/RealtimeSchedulerTest.kt
@@ -39,7 +39,7 @@
@RunWith(DevSdkIgnoreRunner::class)
@SmallTest
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
-class TimerFileDescriptorTest {
+class RealtimeSchedulerTest {
private val TIMEOUT_MS = 1000L
private val TOLERANCE_MS = 50L
@@ -52,7 +52,7 @@
executionTimes.add(SystemClock.elapsedRealtime())
}
}
- private val thread = HandlerThread(TimerFileDescriptorTest::class.simpleName).apply { start() }
+ private val thread = HandlerThread(RealtimeSchedulerTest::class.simpleName).apply { start() }
private val handler by lazy { TestHandler(thread.looper) }
@After
@@ -63,7 +63,7 @@
@Test
fun testMultiplePostDelayedTasks() {
- val scheduler = TimerFileDescriptor(handler)
+ val scheduler = RealtimeScheduler(handler)
tryTest {
val initialTimeMs = SystemClock.elapsedRealtime()
val executionTimes = mutableListOf<Long>()
@@ -97,7 +97,7 @@
@Test
fun testMultipleSendDelayedMessages() {
- val scheduler = TimerFileDescriptor(handler)
+ val scheduler = RealtimeScheduler(handler)
tryTest {
val MSG_ID_0 = 0
val MSG_ID_1 = 1