TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 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.systemui.dock; |
| 18 | |
| 19 | /** |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 20 | * Allows an app to handle dock events. |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 21 | */ |
| 22 | public interface DockManager { |
| 23 | |
| 24 | /** |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 25 | * Uninitialized / undocking dock states. |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 26 | */ |
| 27 | int STATE_NONE = 0; |
| 28 | /** |
| 29 | * The state for docking |
| 30 | */ |
Jerry Chang | 5d3eb447 | 2018-12-21 11:49:06 +0800 | [diff] [blame] | 31 | int STATE_DOCKED = 1; |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 32 | /** |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 33 | * The state for docking without showing UI. |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 34 | */ |
Jerry Chang | 5d3eb447 | 2018-12-21 11:49:06 +0800 | [diff] [blame] | 35 | int STATE_DOCKED_HIDE = 2; |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 36 | |
| 37 | /** |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 38 | * Indicates there's no alignment issue. |
| 39 | */ |
| 40 | int ALIGN_STATE_GOOD = 0; |
| 41 | |
| 42 | /** |
| 43 | * Indicates it's slightly not aligned with dock. Normally combines with slow charging issue. |
| 44 | */ |
| 45 | int ALIGN_STATE_POOR = 1; |
| 46 | |
| 47 | /** |
| 48 | * Indicates it's not aligned with dock. Normally combines with not charging issue. |
| 49 | */ |
| 50 | int ALIGN_STATE_TERRIBLE = 2; |
| 51 | |
| 52 | /** |
| 53 | * Adds a dock event listener into manager. |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 54 | * |
Jerry Chang | 5d3eb447 | 2018-12-21 11:49:06 +0800 | [diff] [blame] | 55 | * @param callback A {@link DockEventListener} which want to add |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 56 | */ |
| 57 | void addListener(DockEventListener callback); |
| 58 | |
| 59 | /** |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 60 | * Removes the added listener from dock manager |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 61 | * |
TYM Tsai | 2d23690 | 2018-12-27 16:46:06 +0800 | [diff] [blame] | 62 | * @param callback A {@link DockEventListener} which want to remove |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 63 | */ |
| 64 | void removeListener(DockEventListener callback); |
| 65 | |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 66 | /** |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 67 | * Adds a alignment listener into manager. |
| 68 | * |
| 69 | * @param listener A {@link AlignmentStateListener} which want to add |
| 70 | */ |
| 71 | void addAlignmentStateListener(AlignmentStateListener listener); |
| 72 | |
| 73 | /** |
| 74 | * Removes the added alignment listener from dock manager. |
| 75 | * |
| 76 | * @param listener A {@link AlignmentStateListener} which want to remove |
| 77 | */ |
| 78 | void removeAlignmentStateListener(AlignmentStateListener listener); |
| 79 | |
| 80 | /** |
lpeter | 8a5f470 | 2019-01-18 16:53:07 +0800 | [diff] [blame] | 81 | * Returns true if the device is in docking state. |
| 82 | */ |
| 83 | boolean isDocked(); |
| 84 | |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 85 | /** |
| 86 | * Listens to dock events. |
| 87 | */ |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 88 | interface DockEventListener { |
| 89 | /** |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 90 | * Override to handle dock events. |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 91 | */ |
| 92 | void onEvent(int event); |
| 93 | } |
Jerry Chang | 4bbf159 | 2019-11-15 06:52:54 +0800 | [diff] [blame^] | 94 | |
| 95 | /** |
| 96 | * Listens to dock alignment state changed. |
| 97 | */ |
| 98 | interface AlignmentStateListener { |
| 99 | /** |
| 100 | * Override to handle alignment state changes. |
| 101 | */ |
| 102 | void onAlignmentStateChanged(int alignState); |
| 103 | } |
TYM Tsai | 2fc027d | 2018-12-04 19:28:19 +0800 | [diff] [blame] | 104 | } |