1 /* 2 * Copyright (C) 2023 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 android.os; 18 19 import android.annotation.CallbackExecutor; 20 import android.annotation.NonNull; 21 import android.annotation.StringDef; 22 23 import java.lang.annotation.ElementType; 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 import java.lang.annotation.Target; 27 import java.util.concurrent.Executor; 28 import java.util.function.Consumer; 29 30 /** 31 * Mode Manager local service interface. 32 * Example usage: LocalServices.get(WearModeManagerInternal.class). 33 * 34 * TODO(b/288115060): consolidate with {@link com.android.server.policy.WearModeServiceInternal} 35 * 36 * @hide 37 */ 38 public interface WearModeManagerInternal { 39 40 /** 41 * Mode manager quick doze request identifier. 42 * 43 * <p>Unique identifier that can be used as identifier parameter in 44 * registerInternalStateObserver 45 * to listen to changes in quick doze request state from mode manager. 46 * 47 * TODO(b/288276510): convert to int constant 48 */ 49 String QUICK_DOZE_REQUEST_IDENTIFIER = "quick_doze_request"; 50 51 /** 52 * Mode manager off body state identifier. 53 * 54 * <p>Unique identifier that can be used as identifier parameter in 55 * registerInternalStateObserver 56 * to listen to changes in quick doze request state from mode manager. 57 * 58 * TODO(b/288276510): convert to int constant 59 */ 60 String OFFBODY_STATE_ID = "off_body"; 61 62 /** 63 * StringDef for Mode manager identifiers. 64 * 65 * @hide 66 */ 67 @Retention(RetentionPolicy.SOURCE) 68 @StringDef({ 69 QUICK_DOZE_REQUEST_IDENTIFIER, 70 OFFBODY_STATE_ID 71 }) 72 @Target(ElementType.TYPE_USE) 73 @interface Identifier { 74 } 75 76 /** 77 * Method to register a callback in Mode manager. 78 * 79 * <p>Callback is executed when there is a change of active state for the 80 * provided identifier. 81 * 82 * <p>Mode manager has active states and configured states where active state is the state of a 83 * mode/feature as reflected on the device, 84 * configured state refers to the configured value of the state of the mode / feature. 85 * For e.g.: Quick doze might be configured to be disabled by default but in certain modes, it 86 * can be overridden to be enabled. At that point active=enabled, configured=disabled. 87 * 88 * <p> 89 * 90 * @param identifier Observer listens for changes to this {@link Identifier} 91 * @param executor Executor used to execute the callback. 92 * @param callback Boolean consumer callback. 93 */ addActiveStateChangeListener(@onNull @dentifier String identifier, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<T> callback)94 <T> void addActiveStateChangeListener(@NonNull @Identifier String identifier, 95 @NonNull @CallbackExecutor Executor executor, 96 @NonNull Consumer<T> callback); 97 } 98