2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.server.notification;
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;
26 import com.android.server.notification.NotificationManagerService.DumpFilter;
28 import java.io.PrintWriter;
29 import java.util.Date;
31 public abstract class SystemConditionProviderService extends ConditionProviderService {
33 abstract public void dump(PrintWriter pw, DumpFilter filter);
34 abstract public void attachBase(Context context);
35 abstract public IConditionProvider asInterface();
36 abstract public ComponentName getComponent();
37 abstract public boolean isValidConditionId(Uri id);
38 abstract public void onBootComplete();
40 protected static String ts(long time) {
41 return new Date(time) + " (" + time + ")";
44 protected static String formatDuration(long millis) {
45 final StringBuilder sb = new StringBuilder();
46 TimeUtils.formatDuration(millis, sb);
50 protected static void dumpUpcomingTime(PrintWriter pw, String var, long time, long now) {
51 pw.print(" "); pw.print(var); pw.print('=');
53 pw.printf("%s, in %s, now=%s", ts(time), formatDuration(time - now), ts(now));