Merge "Add a notification channel for car services."
diff --git a/service/src/com/android/car/CanBusErrorNotifier.java b/service/src/com/android/car/CanBusErrorNotifier.java
index 7caa1a8..163b706 100644
--- a/service/src/com/android/car/CanBusErrorNotifier.java
+++ b/service/src/com/android/car/CanBusErrorNotifier.java
@@ -16,6 +16,7 @@
package com.android.car;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;
@@ -30,7 +31,7 @@
* Class used to notify user about CAN bus failure.
*/
final class CanBusErrorNotifier {
- private static final String TAG = CarLog.TAG_CAN_BUS + ".ERROR.NOTIFIER";
+ private static final String TAG = CarLog.TAG_CAN_BUS + ".NOTIFIER";
private static final int NOTIFICATION_ID = 1;
private static final boolean IS_RELEASE_BUILD = "user".equals(Build.TYPE);
@@ -42,9 +43,6 @@
@GuardedBy("this")
private final Set<Object> mReportedObjects = new HashSet<>();
- @GuardedBy("this")
- private Notification mNotification;
-
CanBusErrorNotifier(Context context) {
mNotificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);
@@ -71,7 +69,10 @@
shouldShowNotification = !mReportedObjects.isEmpty();
}
- Log.i(TAG, "Changing CAN bus failure state to " + shouldShowNotification);
+
+ if (Log.isLoggable(TAG, Log.INFO)) {
+ Log.i(TAG, "Changing CAN bus failure state to " + shouldShowNotification);
+ }
if (shouldShowNotification) {
showNotification();
@@ -85,18 +86,13 @@
// TODO: for user, we should show message to take car to the dealer. bug:32096297
return;
}
- Notification notification;
- synchronized (this) {
- if (mNotification == null) {
- mNotification = new Notification.Builder(mContext)
+ Notification notification =
+ new Notification.Builder(mContext, NotificationChannel.DEFAULT_CHANNEL_ID)
.setContentTitle(mContext.getString(R.string.car_can_bus_failure))
.setContentText(mContext.getString(R.string.car_can_bus_failure_desc))
.setSmallIcon(R.drawable.car_ic_error)
.setOngoing(true)
.build();
- }
- notification = mNotification;
- }
mNotificationManager.notify(TAG, NOTIFICATION_ID, notification);
}
diff --git a/tools/bootanalyze/stressfs/src/com/android/car/test/stressfs/WritingService.java b/tools/bootanalyze/stressfs/src/com/android/car/test/stressfs/WritingService.java
index d5a6710..0db75d4 100644
--- a/tools/bootanalyze/stressfs/src/com/android/car/test/stressfs/WritingService.java
+++ b/tools/bootanalyze/stressfs/src/com/android/car/test/stressfs/WritingService.java
@@ -17,6 +17,7 @@
import android.app.Service;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -112,11 +113,13 @@
/** Raises service priority and starts the writing threads. */
@Override
public IBinder onBind(Intent intent) {
+ Notification notification =
+ new Notification.Builder(this, NotificationChannel.DEFAULT_CHANNEL_ID)
+ .setContentTitle("Stress Filesystem service running.")
+ .setSmallIcon(drawable.ic_menu_save)
+ .build();
+
// Raise priority of this service.
- Notification notification = new Notification.Builder(this)
- .setContentTitle("Stress Filesystem service running.")
- .setSmallIcon(drawable.ic_menu_save)
- .build();
startForeground(NOTIFICATION_ID, notification);
File dataPartitionFile = getFileStreamPath(FILENAME_PREFIX + UUID.randomUUID());