method public abstract void onAudioDeviceConnection();
}
+ public abstract interface OnAudioRecordRoutingListener {
+ method public abstract void onAudioRecordRouting(android.media.AudioRecord);
+ }
+
+ public abstract interface OnAudioTrackRoutingListener {
+ method public abstract void onAudioTrackRouting(android.media.AudioTrack);
+ }
+
public final class PlaybackSettings {
ctor public PlaybackSettings();
method public android.media.PlaybackSettings allowDefaults();
field public static final int AUDIO_STRETCH_MODE_VOICE = 1; // 0x1
}
- public abstract interface OnAudioRecordRoutingListener {
- method public abstract void onAudioRecordRouting(android.media.AudioRecord);
- }
-
- public abstract interface OnAudioTrackRoutingListener {
- method public abstract void onAudioTrackRouting(android.media.AudioTrack);
- }
-
public final class Rating implements android.os.Parcelable {
method public int describeContents();
method public float getPercentRating();
method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
method public final void requestInterruptionFilter(int);
method public final void requestListenerHints(int);
+ method public final void setNotificationsShown(java.lang.String[]);
field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4
field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1
method public abstract void onAudioDeviceConnection();
}
+ public abstract interface OnAudioRecordRoutingListener {
+ method public abstract void onAudioRecordRouting(android.media.AudioRecord);
+ }
+
+ public abstract interface OnAudioTrackRoutingListener {
+ method public abstract void onAudioTrackRouting(android.media.AudioTrack);
+ }
+
public final class PlaybackSettings {
ctor public PlaybackSettings();
method public android.media.PlaybackSettings allowDefaults();
field public static final int AUDIO_STRETCH_MODE_VOICE = 1; // 0x1
}
- public abstract interface OnAudioRecordRoutingListener {
- method public abstract void onAudioRecordRouting(android.media.AudioRecord);
- }
-
- public abstract interface OnAudioTrackRoutingListener {
- method public abstract void onAudioTrackRouting(android.media.AudioTrack);
- }
-
public final class Rating implements android.os.Parcelable {
method public int describeContents();
method public float getPercentRating();
method public void registerAsSystemService(android.content.Context, android.content.ComponentName, int) throws android.os.RemoteException;
method public final void requestInterruptionFilter(int);
method public final void requestListenerHints(int);
+ method public final void setNotificationsShown(java.lang.String[]);
method public final void setOnNotificationPostedTrim(int);
method public void unregisterAsSystemService() throws android.os.RemoteException;
field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
void cancelNotificationFromListener(in INotificationListener token, String pkg, String tag, int id);
void cancelNotificationsFromListener(in INotificationListener token, in String[] keys);
+ void setNotificationsShownFromListener(in INotificationListener token, in String[] keys);
+
ParceledListSlice getActiveNotificationsFromListener(in INotificationListener token, in String[] keys, int trim);
void requestHintsFromListener(in INotificationListener token, int hints);
int getHintsFromListener(in INotificationListener token);
}
/**
+ * Inform the notification manager that these notifications have been viewed by the
+ * user.
+ * @param keys Notifications to mark as seen.
+ */
+ public final void setNotificationsShown(String[] keys) {
+ if (!isBound()) return;
+ try {
+ getNotificationInterface().setNotificationsShownFromListener(mWrapper, keys);
+ } catch (android.os.RemoteException ex) {
+ Log.v(TAG, "Unable to contact notification manager", ex);
+ }
+ }
+
+ /**
* Sets the notification trim that will be received via {@link #onNotificationPosted}.
*
* <p>
return isCurrentProfile(notificationUserId);
}
+ protected void setNotificationShown(StatusBarNotification n) {
+ mNotificationListener.setNotificationsShown(new String[] { n.getKey() });
+ }
+
+ protected void setNotificationsShown(String[] keys) {
+ mNotificationListener.setNotificationsShown(keys);
+ }
+
+ protected void setNotificationsShownAll() {
+ ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
+ final int N = activeNotifications.size();
+
+ String[] keys = new String[N];
+ for (int i = 0; i < N; i++) {
+ NotificationData.Entry entry = activeNotifications.get(i);
+ keys[i] = entry.key;
+ }
+ setNotificationsShown(keys);
+ }
+
protected boolean isCurrentProfile(int userId) {
synchronized (mCurrentProfiles) {
return userId == UserHandle.USER_ALL || mCurrentProfiles.get(userId) != null;
boolean clearNotificationEffects =
(mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED);
mBarService.onPanelRevealed(clearNotificationEffects);
+ setNotificationsShownAll();
} else {
mBarService.onPanelHidden();
}
boolean isHeadsUped = mUseHeadsUp && shouldInterrupt(notification);
if (isHeadsUped) {
mHeadsUpManager.showNotification(shadeEntry);
+ // Mark as seen immediately
+ setNotificationShown(notification);
}
if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) {
import android.app.NotificationManager.Policy;
import android.app.PendingIntent;
import android.app.StatusBarManager;
+import android.app.usage.UsageEvents;
+import android.app.usage.UsageStats;
+import android.app.usage.UsageStatsManagerInternal;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import com.android.internal.R;
import com.android.internal.util.FastXmlSerializer;
import com.android.server.EventLogTags;
+import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.lights.Light;
import com.android.server.lights.LightsManager;
ArrayList<String> mLights = new ArrayList<>();
private AppOpsManager mAppOps;
+ private UsageStatsManagerInternal mAppUsageStats;
private Archive mArchive;
mAm = ActivityManagerNative.getDefault();
mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
mVibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
+ mAppUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
mHandler = new WorkerHandler();
mRankingThread.start();
}
}
+ @Override
+ public void setNotificationsShownFromListener(INotificationListener token, String[] keys) {
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mNotificationList) {
+ final ManagedServiceInfo info = mListeners.checkServiceTokenLocked(token);
+ if (keys != null) {
+ final int N = keys.length;
+ for (int i = 0; i < N; i++) {
+ NotificationRecord r = mNotificationsByKey.get(keys[i]);
+ if (r == null) continue;
+ final int userId = r.sbn.getUserId();
+ if (userId != info.userid && userId != UserHandle.USER_ALL &&
+ !mUserProfiles.isCurrentProfile(userId)) {
+ throw new SecurityException("Disallowed call from listener: "
+ + info.service);
+ }
+ if (!r.isSeen()) {
+ if (DBG) Slog.d(TAG, "Marking notification as seen " + keys[i]);
+ mAppUsageStats.reportEvent(r.sbn.getPackageName(),
+ userId == UserHandle.USER_ALL ? UserHandle.USER_OWNER
+ : userId,
+ UsageEvents.Event.INTERACTION);
+ r.setSeen();
+ }
+ }
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
private void cancelNotificationFromListenerLocked(ManagedServiceInfo info,
int callingUid, int callingPid, String pkg, String tag, int id, int userId) {
cancelNotification(callingUid, callingPid, pkg, tag, id, 0,
NotificationUsageStats.SingleNotificationStats stats;
boolean isCanceled;
int score;
+ /** Whether the notification was seen by the user via one of the notification listeners. */
+ boolean mIsSeen;
// These members are used by NotificationSignalExtractors
// to communicate with the ranking module.
return mGlobalSortKey;
}
+ /** Check if any of the listeners have marked this notification as seen by the user. */
+ public boolean isSeen() {
+ return mIsSeen;
+ }
+
+ /** Mark the notification as seen by the user. */
+ public void setSeen() {
+ mIsSeen = true;
+ }
+
public void setAuthoritativeRank(int authoritativeRank) {
mAuthoritativeRank = authoritativeRank;
}
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManagerInternal;
import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
+import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
DevicePolicyManager dpm = getContext().getSystemService(DevicePolicyManager.class);
if (dpm == null) return false;
List<ComponentName> components = dpm.getActiveAdminsAsUser(userId);
- if (components == null) {
- return false;
- }
+ if (components == null) return false;
final int size = components.size();
for (int i = 0; i < size; i++) {
if (components.get(i).getPackageName().equals(packageName)) {