• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.server.deviceidle;
18 
19 import android.annotation.IntDef;
20 
21 import java.lang.annotation.Retention;
22 import 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  */
30 public 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      */
startMonitoring()63     void startMonitoring();
64 
65     /** Stop checking for new events and do not call into LocalService with updates any more. */
stopMonitoring()66     void stopMonitoring();
67 }
68