Skip to content

Commit

Permalink
pick a patch from AOSP (a same patch of 1311 (44aefbeaee27)):
Browse files Browse the repository at this point in the history
- setLatestEventInfo deprecated in SDK 23,
  but we still need API 9. so it remain in source.

From 9f32db87b486c93a0ea71eb1781ee45676b8bf8b Mon Sep 17 00:00:00 2001
From: Xin Li <delphij@google.com>
Date: Tue, 9 Feb 2016 11:04:53 -0800
Subject: [PATCH] Move sl4a to its own project.
  • Loading branch information
kuri65536 committed Feb 5, 2017
1 parent 72f9303 commit f010ff8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
Expand Up @@ -103,14 +103,27 @@ public void onCreate() {

@Override
protected Notification createNotification() {
mNotification =
new Notification(R.drawable.sl4a_notification_logo, null, System.currentTimeMillis());
mNotification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
Intent notificationIntent = new Intent(this, ScriptingLayerService.class);
notificationIntent.setAction(Constants.ACTION_SHOW_RUNNING_SCRIPTS);
mNotificationPendingIntent = PendingIntent.getService(this, 0, notificationIntent, 0);
// with older SDK < 23
mNotification =
new Notification(R.drawable.sl4a_notification_logo, null, System.currentTimeMillis());
mNotification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
mNotification.setLatestEventInfo(this, "SL4A Service", "Tap to view running scripts",
mNotificationPendingIntent);

/* with newer SDK >= 23 and API >= 11
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.sl4a_notification_logo)
.setTicker(null)
.setWhen(System.currentTimeMillis())
.setContentTitle("SL4A Service")
.setContentText("Tap to view running scripts")
.setContentIntent(mNotificationPendingIntent);
mNotification = builder.build();
mNotification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
*/
return mNotification;
}

Expand All @@ -129,7 +142,20 @@ private void updateNotification(String tickerText) {
} else {
msg = "Tap to view " + Integer.toString(mProcessMap.size()) + " running scripts";
}
// with older SDK < 23
mNotification.setLatestEventInfo(this, "SL4A Service", msg, mNotificationPendingIntent);

/* with newer SDK >= 23 and API >= 11
Notification.Builder builder = new Notification.Builder(this);
builder.setContentTitle("SL4A Service")
.setContentText(msg)
.setContentIntent(mNotificationPendingIntent)
.setSmallIcon(mNotification.icon, mProcessMap.size())
.setWhen(mNotification.when)
.setTicker(tickerText);
mNotification = builder.build();
*/
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 Google Inc.
* Copyright (C) 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -42,15 +42,15 @@

/**
* The trigger service takes care of installing triggers serialized to the preference storage.
*
*
* <p>
* The service also installs an alarm that keeps it running, unless the user force-quits the
* service.
*
*
* <p>
* When no triggers are installed the service shuts down silently as to not consume resources
* unnecessarily.
*
*
* @author Felix Arends (felix.arends@gmail.com)
* @author Damon Kohler (damonkohler@gmail.com)
*/
Expand Down Expand Up @@ -105,12 +105,23 @@ public void onStart(Intent intent, int startId) {
/** Returns the notification to display whenever the service is running. */
@Override
protected Notification createNotification() {
Intent notificationIntent = new Intent(this, TriggerManager.class);
// with older SDK < 23
Notification notification =
new Notification(R.drawable.sl4a_logo_48, "SL4A Trigger Service started.",
System.currentTimeMillis());
Intent notificationIntent = new Intent(this, TriggerManager.class);
notification.setLatestEventInfo(this, "SL4A Trigger Service", "Tap to view triggers",
PendingIntent.getActivity(this, 0, notificationIntent, 0));
/* for newer SDK >= 23
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.sl4a_logo_48)
.setTicker("SL4A Trigger Service started.")
.setWhen(System.currentTimeMillis())
.setContentTitle("SL4A Trigger Service")
.setContentText("Tap to view triggers")
.setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0));
Notification notification = builder.build();
*/
notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
return notification;
}
Expand Down

0 comments on commit f010ff8

Please sign in to comment.