blob: f1f957307716396c4e5434926a232a163ccc0f70 [file] [log] [blame]
Robin Lee876b88542018-11-13 17:22:24 +01001/*
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.deviceidle;
18
19import android.annotation.IntDef;
20
21import java.lang.annotation.Retention;
22import java.lang.annotation.RetentionPolicy;
23
24/**
25 * Implemented by OEM and/or Form Factor. System ones are built into the
26 * image regardless of build flavour but may still be switched off at run time.
27 * Individual feature flags at build time control which are used. We may
28 * also explore a local override for quick testing.
29 */
30public interface IDeviceIdleConstraint {
31
32 /**
33 * A state for this constraint to block descent from.
34 *
35 * <p>These states are a subset of the states in DeviceIdleController that make sense for
36 * constraints to be able to block on. For example, {@link #SENSING_OR_ABOVE} clearly has
37 * defined "above" and "below" states. However, a hypothetical {@code QUICK_DOZE_OR_ABOVE}
38 * state would not have clear semantics as to what transitions should be blocked and which
39 * should be allowed.
40 */
41 @IntDef(flag = false, value = {
42 ACTIVE,
43 SENSING_OR_ABOVE,
44 })
45 @Retention(RetentionPolicy.SOURCE)
46 @interface MinimumState {}
47
48 int ACTIVE = 0;
49 int SENSING_OR_ABOVE = 1;
50
51 /**
52 * Begin tracking events for this constraint.
53 *
54 * <p>The device idle controller has reached a point where it is waiting for the all-clear
55 * from this tracker (possibly among others) in order to continue with progression into
56 * idle state. It will not proceed until one of the following happens:
57 * <ul>
58 * <li>The constraint reports inactive with {@code .setActive(false)}.</li>
59 * <li>The constraint is unregistered with {@code .unregisterDeviceIdleConstraint(this)}.</li>
60 * <li>A transition timeout in DeviceIdleController fires.
61 * </ul>
62 */
63 void startMonitoring();
64
65 /** Stop checking for new events and do not call into LocalService with updates any more. */
66 void stopMonitoring();
67}