1 /* 2 * Copyright (C) 2017 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.CurrentTimeMillisLong; 20 import android.annotation.UserIdInt; 21 import android.app.PendingIntent; 22 23 import com.android.server.SystemClockTime.TimeConfidence; 24 import com.android.server.SystemTimeZone.TimeZoneConfidence; 25 26 public interface AlarmManagerInternal { 27 // Some other components in the system server need to know about 28 // broadcast alarms currently in flight 29 public interface InFlightListener { 30 /** There is now an alarm pending delivery to the given app */ broadcastAlarmPending(int recipientUid)31 void broadcastAlarmPending(int recipientUid); 32 33 /** A broadcast alarm targeted to the given app has completed delivery */ broadcastAlarmComplete(int recipientUid)34 void broadcastAlarmComplete(int recipientUid); 35 } 36 37 /** Returns true if AlarmManager is delaying alarms due to device idle. */ isIdling()38 boolean isIdling(); 39 40 /** 41 * Returns the time at which the next alarm for the given user is going to trigger, or 0 if 42 * there is none. 43 * 44 * <p>This value is UTC wall clock time in milliseconds, as returned by 45 * {@link System#currentTimeMillis()} for example. 46 * @see android.app.AlarmManager.AlarmClockInfo#getTriggerTime() 47 */ getNextAlarmTriggerTimeForUser(@serIdInt int userId)48 long getNextAlarmTriggerTimeForUser(@UserIdInt int userId); 49 removeAlarmsForUid(int uid)50 public void removeAlarmsForUid(int uid); 51 registerInFlightListener(InFlightListener callback)52 public void registerInFlightListener(InFlightListener callback); 53 54 /** 55 * Removes any alarm with the given pending intent with equality determined using 56 * {@link android.app.PendingIntent#equals(java.lang.Object) PendingIntent.equals} 57 */ remove(PendingIntent rec)58 void remove(PendingIntent rec); 59 60 /** 61 * Returns {@code true} if the given package in the given uid holds 62 * {@link android.Manifest.permission#USE_EXACT_ALARM} or 63 * {@link android.Manifest.permission#SCHEDULE_EXACT_ALARM} for apps targeting T or lower. 64 */ shouldGetBucketElevation(String packageName, int uid)65 boolean shouldGetBucketElevation(String packageName, int uid); 66 67 /** 68 * Sets the device's current time zone and time zone confidence. 69 * 70 * @param tzId the time zone ID 71 * @param confidence the confidence that {@code tzId} is correct, see {@link TimeZoneConfidence} 72 * for details 73 * @param logInfo the reason the time zone is being changed, for bug report logging 74 */ setTimeZone(String tzId, @TimeZoneConfidence int confidence, String logInfo)75 void setTimeZone(String tzId, @TimeZoneConfidence int confidence, String logInfo); 76 77 /** 78 * Sets the device's current time and time confidence. 79 * 80 * @param unixEpochTimeMillis the time 81 * @param confidence the confidence that {@code unixEpochTimeMillis} is correct, see {@link 82 * TimeConfidence} for details 83 * @param logMsg the reason the time is being changed, for bug report logging 84 */ setTime(@urrentTimeMillisLong long unixEpochTimeMillis, @TimeConfidence int confidence, String logMsg)85 void setTime(@CurrentTimeMillisLong long unixEpochTimeMillis, @TimeConfidence int confidence, 86 String logMsg); 87 } 88