blob: cdab7e538ca5fde0e0d7d25686eaf17893b15e23 [file] [log] [blame]
Serik Beketayev2ac4f062018-07-26 20:49:59 -07001/*
2 * Copyright (C) 2018 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
15 */
16
17package com.android.server.job.controllers.idle;
18
19import android.content.Context;
Kweku Adamsc3f9ba62019-08-01 12:14:55 -070020import android.util.proto.ProtoOutputStream;
Serik Beketayev2ac4f062018-07-26 20:49:59 -070021
22import java.io.PrintWriter;
23
24public interface IdlenessTracker {
25 /**
26 * One-time initialization: this method is called once, after construction of
27 * the IdlenessTracker instance. This is when the tracker should actually begin
28 * monitoring whatever signals it consumes in deciding when the device is in a
29 * non-interacting state. When the idle state changes thereafter, the given
30 * listener must be called to report the new state.
31 */
32 void startTracking(Context context, IdlenessListener listener);
33
34 /**
35 * Report whether the device is currently considered "idle" for purposes of
36 * running scheduled jobs with idleness constraints.
37 *
38 * @return {@code true} if the job scheduler should consider idleness
39 * constraints to be currently satisfied; {@code false} otherwise.
40 */
41 boolean isIdle();
42
43 /**
44 * Dump useful information about tracked idleness-related state in plaintext.
45 */
46 void dump(PrintWriter pw);
Kweku Adamsc3f9ba62019-08-01 12:14:55 -070047
48 /**
49 * Dump useful information about tracked idleness-related state to proto.
50 */
51 void dump(ProtoOutputStream proto, long fieldId);
Serik Beketayev2ac4f062018-07-26 20:49:59 -070052}