Merge "Don't attach private Notification to A11yEvent when user locked" into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
075e4bbbb2
30
services/core/java/com/android/server/notification/NotificationManagerService.java
Normal file → Executable file
30
services/core/java/com/android/server/notification/NotificationManagerService.java
Normal file → Executable file
@@ -73,6 +73,7 @@ import android.app.backup.BackupManager;
|
|||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
import android.app.INotificationManager;
|
import android.app.INotificationManager;
|
||||||
import android.app.ITransientNotification;
|
import android.app.ITransientNotification;
|
||||||
|
import android.app.KeyguardManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager.Policy;
|
import android.app.NotificationManager.Policy;
|
||||||
@@ -329,6 +330,8 @@ public class NotificationManagerService extends SystemService {
|
|||||||
final ArrayList<ToastRecord> mToastQueue = new ArrayList<>();
|
final ArrayList<ToastRecord> mToastQueue = new ArrayList<>();
|
||||||
final ArrayMap<String, NotificationRecord> mSummaryByGroupKey = new ArrayMap<>();
|
final ArrayMap<String, NotificationRecord> mSummaryByGroupKey = new ArrayMap<>();
|
||||||
|
|
||||||
|
private KeyguardManager mKeyguardManager;
|
||||||
|
|
||||||
// The last key in this list owns the hardware.
|
// The last key in this list owns the hardware.
|
||||||
ArrayList<String> mLights = new ArrayList<>();
|
ArrayList<String> mLights = new ArrayList<>();
|
||||||
|
|
||||||
@@ -1451,6 +1454,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
|
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
|
||||||
mAudioManagerInternal = getLocalService(AudioManagerInternal.class);
|
mAudioManagerInternal = getLocalService(AudioManagerInternal.class);
|
||||||
mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
|
mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
|
||||||
|
mKeyguardManager = getContext().getSystemService(KeyguardManager.class);
|
||||||
mZenModeHelper.onSystemReady();
|
mZenModeHelper.onSystemReady();
|
||||||
} else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
|
} else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
|
||||||
// This observer will force an update when observe is called, causing us to
|
// This observer will force an update when observe is called, causing us to
|
||||||
@@ -4054,7 +4058,6 @@ public class NotificationManagerService extends SystemService {
|
|||||||
boolean beep = false;
|
boolean beep = false;
|
||||||
boolean blink = false;
|
boolean blink = false;
|
||||||
|
|
||||||
final Notification notification = record.sbn.getNotification();
|
|
||||||
final String key = record.getKey();
|
final String key = record.getKey();
|
||||||
|
|
||||||
// Should this notification make noise, vibe, or use the LED?
|
// Should this notification make noise, vibe, or use the LED?
|
||||||
@@ -4071,7 +4074,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
// If the notification will appear in the status bar, it should send an accessibility
|
// If the notification will appear in the status bar, it should send an accessibility
|
||||||
// event
|
// event
|
||||||
if (!record.isUpdate && record.getImportance() > IMPORTANCE_MIN) {
|
if (!record.isUpdate && record.getImportance() > IMPORTANCE_MIN) {
|
||||||
sendAccessibilityEvent(notification, record.sbn.getPackageName());
|
sendAccessibilityEvent(record);
|
||||||
sentAccessibilityEvent = true;
|
sentAccessibilityEvent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4095,7 +4098,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
boolean hasAudibleAlert = hasValidSound || hasValidVibrate;
|
boolean hasAudibleAlert = hasValidSound || hasValidVibrate;
|
||||||
if (hasAudibleAlert && !shouldMuteNotificationLocked(record)) {
|
if (hasAudibleAlert && !shouldMuteNotificationLocked(record)) {
|
||||||
if (!sentAccessibilityEvent) {
|
if (!sentAccessibilityEvent) {
|
||||||
sendAccessibilityEvent(notification, record.sbn.getPackageName());
|
sendAccessibilityEvent(record);
|
||||||
sentAccessibilityEvent = true;
|
sentAccessibilityEvent = true;
|
||||||
}
|
}
|
||||||
if (DBG) Slog.v(TAG, "Interrupting!");
|
if (DBG) Slog.v(TAG, "Interrupting!");
|
||||||
@@ -4614,17 +4617,30 @@ public class NotificationManagerService extends SystemService {
|
|||||||
return (x < low) ? low : ((x > high) ? high : x);
|
return (x < low) ? low : ((x > high) ? high : x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendAccessibilityEvent(Notification notification, CharSequence packageName) {
|
void sendAccessibilityEvent(NotificationRecord record) {
|
||||||
if (!mAccessibilityManager.isEnabled()) {
|
if (!mAccessibilityManager.isEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessibilityEvent event =
|
final Notification notification = record.getNotification();
|
||||||
|
final CharSequence packageName = record.sbn.getPackageName();
|
||||||
|
final AccessibilityEvent event =
|
||||||
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
|
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
|
||||||
event.setPackageName(packageName);
|
event.setPackageName(packageName);
|
||||||
event.setClassName(Notification.class.getName());
|
event.setClassName(Notification.class.getName());
|
||||||
event.setParcelableData(notification);
|
final int visibilityOverride = record.getPackageVisibilityOverride();
|
||||||
CharSequence tickerText = notification.tickerText;
|
final int notifVisibility = visibilityOverride == NotificationManager.VISIBILITY_NO_OVERRIDE
|
||||||
|
? notification.visibility : visibilityOverride;
|
||||||
|
final int userId = record.getUser().getIdentifier();
|
||||||
|
final boolean needPublic = userId >= 0 && mKeyguardManager.isDeviceLocked(userId);
|
||||||
|
if (needPublic && notifVisibility != Notification.VISIBILITY_PUBLIC) {
|
||||||
|
// Emit the public version if we're on the lockscreen and this notification isn't
|
||||||
|
// publicly visible.
|
||||||
|
event.setParcelableData(notification.publicVersion);
|
||||||
|
} else {
|
||||||
|
event.setParcelableData(notification);
|
||||||
|
}
|
||||||
|
final CharSequence tickerText = notification.tickerText;
|
||||||
if (!TextUtils.isEmpty(tickerText)) {
|
if (!TextUtils.isEmpty(tickerText)) {
|
||||||
event.getText().add(tickerText);
|
event.getText().add(tickerText);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user