1 /*
2  * Copyright (C) 2021 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 androidx.window.common;
18 
19 import android.annotation.IntDef;
20 import android.annotation.Nullable;
21 import android.graphics.Rect;
22 
23 import androidx.annotation.NonNull;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /** Wrapper for both Extension and Sidecar versions of DisplayFeature. */
29 public interface DisplayFeature {
30     /** Returns the type of the feature. */
getType()31     int getType();
32 
33     /** Returns the state of the feature, or {@code null} if the feature has no state. */
34     @Nullable
35     @State
getState()36     Integer getState();
37 
38     /** Returns the bounds of the feature. */
39     @NonNull
getRect()40     Rect getRect();
41 
42     /**
43      * A common state to represent a FLAT hinge. This is needed because the definitions in Sidecar
44      * and Extensions do not match exactly.
45      */
46     int COMMON_STATE_FLAT = 3;
47     /**
48      * A common state to represent a HALF_OPENED hinge. This is needed because the definitions in
49      * Sidecar and Extensions do not match exactly.
50      */
51     int COMMON_STATE_HALF_OPENED = 2;
52 
53     /**
54      * The possible states for a folding hinge.
55      */
56     @IntDef({COMMON_STATE_FLAT, COMMON_STATE_HALF_OPENED})
57     @Retention(RetentionPolicy.SOURCE)
58     @interface State {}
59 
60 }
61