• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.android.wallpaper.module;
17 
18 import android.app.AlarmManager;
19 import android.app.PendingIntent;
20 import android.content.Context;
21 
22 /**
23  * Default implementation of {@link AlarmManagerWrapper}.
24  */
25 public class DefaultAlarmManagerWrapper implements AlarmManagerWrapper {
26 
27     private AlarmManager mAlarmManager;
28 
DefaultAlarmManagerWrapper(Context context)29     public DefaultAlarmManagerWrapper(Context context) {
30         mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
31     }
32 
33     @Override
set(int type, long triggerAtMillis, PendingIntent operation)34     public void set(int type, long triggerAtMillis, PendingIntent operation) {
35         mAlarmManager.set(type, triggerAtMillis, operation);
36     }
37 
38     @Override
setWindow(int type, long windowStartMillis, long windowLengthMillis, PendingIntent operation)39     public void setWindow(int type, long windowStartMillis, long windowLengthMillis,
40                           PendingIntent operation) {
41         mAlarmManager.setWindow(type, windowStartMillis, windowLengthMillis, operation);
42     }
43 
44     @Override
setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation)45     public void setInexactRepeating(int type, long triggerAtMillis, long intervalMillis,
46                                     PendingIntent operation) {
47         mAlarmManager.setInexactRepeating(type, triggerAtMillis, intervalMillis, operation);
48     }
49 
50     @Override
cancel(PendingIntent operation)51     public void cancel(PendingIntent operation) {
52         mAlarmManager.cancel(operation);
53     }
54 }
55