Debian Codegraph @

apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 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;
18
19 import android.annotation.Nullable;
20 import android.os.PowerExemptionManager;
21 import android.os.PowerExemptionManager.ReasonCode;
22 import android.os.PowerExemptionManager.TempAllowListType;
23
24 import com.android.server.deviceidle.IDeviceIdleConstraint;
25
26 public interface DeviceIdleInternal {
27 void onConstraintStateChanged(IDeviceIdleConstraint constraint, boolean active);
28
29 void registerDeviceIdleConstraint(IDeviceIdleConstraint constraint, String name,
30 @IDeviceIdleConstraint.MinimumState int minState);
31
32 void unregisterDeviceIdleConstraint(IDeviceIdleConstraint constraint);
33
34 void exitIdle(String reason);
35
36 /**
37 * Same as {@link #addPowerSaveTempWhitelistApp(int, String, long, int, boolean, int, String)}
38 * with {@link PowerExemptionManager#TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED}.
39 */
40 void addPowerSaveTempWhitelistApp(int callingUid, String packageName,
41 long durationMs, int userId, boolean sync, @ReasonCode int reasonCode,
42 @Nullable String reason);
43
44 /**
45 * Put a package in the temp-allowlist.
46 */
47 void addPowerSaveTempWhitelistApp(int callingUid, String packageName,
48 long durationMs, @TempAllowListType int tempAllowListType, int userId, boolean sync,
49 @ReasonCode int reasonCode, @Nullable String reason);
50
51 /**
52 * Called by ActivityManagerService to directly add UID to DeviceIdleController's temp
53 * allowlist.
54 * @param uid
55 * @param duration duration in milliseconds
56 * @param type temp allowlist type defined at {@link TempAllowListType}
57 * @param sync
58 * @param reasonCode one of {@link ReasonCode}
59 * @param reason
60 * @param callingUid UID of app who added this temp-allowlist.
61 */
62 void addPowerSaveTempWhitelistAppDirect(int uid, long duration,
63 @TempAllowListType int type, boolean sync, @ReasonCode int reasonCode,
64 @Nullable String reason, int callingUid);
65
66 // duration in milliseconds
67 long getNotificationAllowlistDuration();
68
69 void setJobsActive(boolean active);
70
71 // Up-call from alarm manager.
72 void setAlarmsActive(boolean active);
73
74 boolean isAppOnWhitelist(int appid);
75
76 int[] getPowerSaveWhitelistUserAppIds();
77
78 int[] getPowerSaveTempWhitelistAppIds();
79
80 /**
81 * Listener to be notified when DeviceIdleController determines that the device has moved or is
82 * stationary.
83 */
84 interface StationaryListener {
85 void onDeviceStationaryChanged(boolean isStationary);
86 }
87
88 /**
89 * Registers a listener that will be notified when the system has detected that the device is
90 * stationary or in motion.
91 */
92 void registerStationaryListener(StationaryListener listener);
93
94 /**
95 * Unregisters a registered stationary listener from being notified when the system has detected
96 * that the device is stationary or in motion.
97 */
98 void unregisterStationaryListener(StationaryListener listener);
99
100 /**
101 * Apply some restrictions on temp allowlist type based on the reasonCode.
102 * @param reasonCode temp allowlist reason code.
103 * @param defaultType default temp allowlist type if reasonCode can not decide a type.
104 * @return temp allowlist type based on the reasonCode.
105 */
106 @TempAllowListType int getTempAllowListType(@ReasonCode int reasonCode,
107 @TempAllowListType int defaultType);
108 }