1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.Wifi
15 */
16
17package com.android.server.wifi;
18
19import android.os.SystemClock;
20/**
21 * Wrapper class for time operations. Allows replacement of clock operations for testing.
22 */
23public class Clock {
24
25    /**
26     * Get the current time of the clock in milliseconds.
27     *
28     * @return Current time in milliseconds.
29     */
30    public long currentTimeMillis() {
31        return System.currentTimeMillis();
32    }
33
34    /**
35     * Returns milliseconds since boot, including time spent in sleep.
36     *
37     * @return Current time since boot in milliseconds.
38     */
39    public long elapsedRealtime() {
40        return SystemClock.elapsedRealtime();
41    }
42
43    /**
44     * Returns the current timestamp of the most precise timer available on the local system, in
45     * nanoseconds.
46     *
47     * @return Current time in nanoseconds.
48     */
49    public long nanoTime() {
50        return System.nanoTime();
51    }
52
53    /**
54     * Returns nanoseconds since boot, including time spent in sleep.
55     *
56     * @return Current time since boot in nanoseconds.
57     */
58    public long elapsedRealtimeNanos() {
59        return SystemClock.elapsedRealtimeNanos();
60    }
61}
62