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