• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.notification;
18 
19 import android.content.ComponentName;
20 import android.content.Context;
21 import android.net.Uri;
22 import android.service.notification.ConditionProviderService;
23 import android.service.notification.IConditionProvider;
24 import android.util.TimeUtils;
25 
26 import com.android.server.notification.NotificationManagerService.DumpFilter;
27 
28 import java.io.PrintWriter;
29 import java.util.Date;
30 
31 public abstract class SystemConditionProviderService extends ConditionProviderService {
32 
dump(PrintWriter pw, DumpFilter filter)33     abstract public void dump(PrintWriter pw, DumpFilter filter);
attachBase(Context context)34     abstract public void attachBase(Context context);
asInterface()35     abstract public IConditionProvider asInterface();
getComponent()36     abstract public ComponentName getComponent();
isValidConditionId(Uri id)37     abstract public boolean isValidConditionId(Uri id);
onBootComplete()38     abstract public void onBootComplete();
39 
ts(long time)40     protected static String ts(long time) {
41         return new Date(time) + " (" + time + ")";
42     }
43 
formatDuration(long millis)44     protected static String formatDuration(long millis) {
45         final StringBuilder sb = new StringBuilder();
46         TimeUtils.formatDuration(millis, sb);
47         return sb.toString();
48     }
49 
dumpUpcomingTime(PrintWriter pw, String var, long time, long now)50     protected static void dumpUpcomingTime(PrintWriter pw, String var, long time, long now) {
51         pw.print("      "); pw.print(var); pw.print('=');
52         if (time > 0) {
53             pw.printf("%s, in %s, now=%s", ts(time), formatDuration(time - now), ts(now));
54         } else {
55             pw.print(time);
56         }
57         pw.println();
58     }
59 }
60