Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 package org.mozilla.gecko;
8 import android.app.Notification;
9 import android.app.Service;
10 import android.content.Intent;
11 import android.os.Binder;
12 import android.os.IBinder;
14 public class NotificationService extends Service {
15 private final IBinder mBinder = new NotificationBinder();
16 private NotificationHandler mHandler;
18 @Override
19 public void onCreate() {
20 // This has to be initialized in onCreate in order to ensure that the NotificationHandler can
21 // access the NotificationManager service.
22 mHandler = new NotificationHandler(this) {
23 @Override
24 protected void setForegroundNotification(int id, Notification notification) {
25 super.setForegroundNotification(id, notification);
27 if (notification == null) {
28 stopForeground(true);
29 } else {
30 startForeground(id, notification);
31 }
32 }
33 };
34 }
36 public class NotificationBinder extends Binder {
37 NotificationService getService() {
38 // Return this instance of NotificationService so clients can call public methods
39 return NotificationService.this;
40 }
41 }
43 @Override
44 public IBinder onBind(Intent intent) {
45 return mBinder;
46 }
48 public NotificationHandler getNotificationHandler() {
49 return mHandler;
50 }
51 }