Fix notification widget's alerting logs

- Use last alerted time if available
- Read from channel

Test: manual
Change-Id: I5e3ab7e234c9c6766a1a4dffb5636a633f6b5f2e
Fixes: 74495461
This commit is contained in:
Julia Reynolds
2019-01-04 11:09:35 -05:00
parent 7eade17c85
commit 8ddeb521ec
2 changed files with 53 additions and 21 deletions

View File

@@ -9473,10 +9473,14 @@
<string name="notification_log_details_parcel">parcel size</string>
<!-- Notification log debug tool: notification ashmem size -->
<string name="notification_log_details_ashmem">ashmem</string>
<!-- Notification log debug tool: header: notification alert info -->
<string name="notification_log_details_alerted">notification alerted</string>
<!-- Notification log debug tool: header: notification sound info -->
<string name="notification_log_details_sound">sound</string>
<!-- Notification log debug tool: header: notification vibration info -->
<string name="notification_log_details_vibrate">vibrate</string>
<!-- Notification log debug tool: header: notification vibration info -->
<string name="notification_log_details_vibrate_pattern">pattern</string>
<!-- Notification log debug tool: the word 'default' -->
<string name="notification_log_details_default">default</string>
<!-- Notification log debug tool: the word 'none' -->

View File

@@ -16,10 +16,13 @@
package com.android.settings.notification;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.INotificationManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -354,28 +357,53 @@ public class NotificationStation extends SettingsPreferenceFragment {
getString(R.string.notification_log_details_group_summary)));
}
}
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_sound)))
.append(delim);
if (0 != (n.defaults & Notification.DEFAULT_SOUND)) {
sb.append(getString(R.string.notification_log_details_default));
} else if (n.sound != null) {
sb.append(n.sound.toString());
} else {
sb.append(getString(R.string.notification_log_details_none));
}
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_vibrate)))
.append(delim);
if (0 != (n.defaults & Notification.DEFAULT_VIBRATE)) {
sb.append(getString(R.string.notification_log_details_default));
} else if (n.vibrate != null) {
for (int vi=0;vi<n.vibrate.length;vi++) {
if (vi > 0) sb.append(',');
sb.append(String.valueOf(n.vibrate[vi]));
if (info.active) {
// mRanking only applies to active notifications
if (mRanking != null && mRanking.getRanking(sbn.getKey(), rank)) {
if (rank.getLastAudiblyAlertedMillis() > 0) {
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_alerted)));
}
}
} else {
sb.append(getString(R.string.notification_log_details_none));
}
try {
NotificationChannel channel = mNoMan.getNotificationChannelForPackage(
sbn.getPackageName(), sbn.getUid(), n.getChannelId(), false);
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_sound)))
.append(delim);
if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
if (0 != (n.defaults & Notification.DEFAULT_SOUND)) {
sb.append(getString(R.string.notification_log_details_default));
} else if (n.sound != null) {
sb.append(n.sound.toString());
} else {
sb.append(getString(R.string.notification_log_details_none));
}
} else {
sb.append(String.valueOf(channel.getSound()));
}
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_vibrate)))
.append(delim);
if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
if (0 != (n.defaults & Notification.DEFAULT_VIBRATE)) {
sb.append(getString(R.string.notification_log_details_default));
} else if (n.vibrate != null) {
sb.append(getString(R.string.notification_log_details_vibrate_pattern));
} else {
sb.append(getString(R.string.notification_log_details_none));
}
} else {
if (channel.getVibrationPattern() != null) {
sb.append(getString(R.string.notification_log_details_vibrate_pattern));
} else {
sb.append(getString(R.string.notification_log_details_none));
}
}
} catch (RemoteException e) {
Log.d(TAG, "cannot read channel info", e);
}
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_visibility)))