Loading core/java/com/android/internal/statusbar/StatusBarNotification.java +6 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.internal.statusbar; import android.app.Notification; import android.os.Parcel; import android.os.Parcelable; import android.os.UserId; import android.widget.RemoteViews; Loading Loading @@ -132,6 +133,11 @@ public class StatusBarNotification implements Parcelable { return ((notification.flags & Notification.FLAG_ONGOING_EVENT) == 0) && ((notification.flags & Notification.FLAG_NO_CLEAR) == 0); } /** Returns a userHandle for the instance of the app that posted this notification. */ public int getUserId() { return UserId.getUserId(this.uid); } } packages/SystemUI/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> <uses-permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK" /> <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> <!-- Networking and telephony --> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> Loading packages/SystemUI/res/layout/status_bar_expanded_header.xml +15 −2 Original line number Diff line number Diff line Loading @@ -65,6 +65,19 @@ android:layout_weight="1" /> <TextView android:id="@+id/header_debug_info" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:fontFamily="sans-serif-condensed" android:textSize="11dp" android:textStyle="bold" android:textColor="#00A040" android:padding="2dp" /> <ImageView android:id="@+id/clear_all_button" android:layout_width="48dp" android:layout_height="48dp" Loading packages/SystemUI/res/layout/status_bar_notification_row.xml +13 −0 Original line number Diff line number Diff line Loading @@ -49,4 +49,17 @@ android:background="@drawable/bottom_divider_glow" /> <TextView android:id="@+id/debug_info" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:fontFamily="sans-serif-condensed" android:textSize="9dp" android:textStyle="bold" android:textColor="#00A040" android:padding="2dp" /> </FrameLayout> packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +49 −0 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ import android.app.ActivityManagerNative; import android.app.KeyguardManager; import android.app.PendingIntent; import android.app.TaskStackBuilder; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.database.ContentObserver; Loading @@ -47,6 +49,7 @@ import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserId; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; Loading @@ -65,6 +68,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupMenu; import android.widget.RemoteViews; import android.widget.TextView; import java.util.ArrayList; Loading @@ -72,6 +76,7 @@ public abstract class BaseStatusBar extends SystemUI implements CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener { static final String TAG = "StatusBar"; private static final boolean DEBUG = false; public static final boolean MULTIUSER_DEBUG = false; protected static final int MSG_OPEN_RECENTS_PANEL = 1020; protected static final int MSG_CLOSE_RECENTS_PANEL = 1021; Loading Loading @@ -112,6 +117,8 @@ public abstract class BaseStatusBar extends SystemUI implements protected PopupMenu mNotificationBlamePopup; protected int mCurrentUserId = 0; // UI-specific methods /** Loading Loading @@ -252,6 +259,40 @@ public abstract class BaseStatusBar extends SystemUI implements switches[3] )); } // XXX: this is currently broken and will always return 0, but should start working at some point try { mCurrentUserId = ActivityManagerNative.getDefault().getCurrentUser().id; } catch (RemoteException e) { Log.v(TAG, "Couldn't get current user ID; guessing it's 0", e); } IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_SWITCHED); mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_USER_SWITCHED.equals(action)) { mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USERID, -1); if (true) Slog.v(TAG, "userId " + mCurrentUserId + " is in the house"); userSwitched(mCurrentUserId); } }}, filter); } public void userSwitched(int newUserId) { // should be overridden } public boolean notificationIsForCurrentUser(StatusBarNotification n) { final int thisUserId = mCurrentUserId; final int notificationUserId = n.getUserId(); if (DEBUG && MULTIUSER_DEBUG) { Slog.v(TAG, String.format("%s: current userid: %d, notification userid: %d", n, thisUserId, notificationUserId)); } return thisUserId == notificationUserId; } protected View updateNotificationVetoButton(View row, StatusBarNotification n) { Loading Loading @@ -604,6 +645,14 @@ public abstract class BaseStatusBar extends SystemUI implements applyLegacyRowBackground(sbn, content); row.setTag(R.id.expandable_tag, Boolean.valueOf(large != null)); if (MULTIUSER_DEBUG) { TextView debug = (TextView) row.findViewById(R.id.debug_info); if (debug != null) { debug.setVisibility(View.VISIBLE); debug.setText("U " + entry.notification.getUserId()); } } entry.row = row; entry.content = content; entry.expanded = expandedOneU; Loading Loading
core/java/com/android/internal/statusbar/StatusBarNotification.java +6 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.internal.statusbar; import android.app.Notification; import android.os.Parcel; import android.os.Parcelable; import android.os.UserId; import android.widget.RemoteViews; Loading Loading @@ -132,6 +133,11 @@ public class StatusBarNotification implements Parcelable { return ((notification.flags & Notification.FLAG_ONGOING_EVENT) == 0) && ((notification.flags & Notification.FLAG_NO_CLEAR) == 0); } /** Returns a userHandle for the instance of the app that posted this notification. */ public int getUserId() { return UserId.getUserId(this.uid); } }
packages/SystemUI/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> <uses-permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK" /> <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> <!-- Networking and telephony --> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> Loading
packages/SystemUI/res/layout/status_bar_expanded_header.xml +15 −2 Original line number Diff line number Diff line Loading @@ -65,6 +65,19 @@ android:layout_weight="1" /> <TextView android:id="@+id/header_debug_info" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:fontFamily="sans-serif-condensed" android:textSize="11dp" android:textStyle="bold" android:textColor="#00A040" android:padding="2dp" /> <ImageView android:id="@+id/clear_all_button" android:layout_width="48dp" android:layout_height="48dp" Loading
packages/SystemUI/res/layout/status_bar_notification_row.xml +13 −0 Original line number Diff line number Diff line Loading @@ -49,4 +49,17 @@ android:background="@drawable/bottom_divider_glow" /> <TextView android:id="@+id/debug_info" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:fontFamily="sans-serif-condensed" android:textSize="9dp" android:textStyle="bold" android:textColor="#00A040" android:padding="2dp" /> </FrameLayout>
packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +49 −0 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ import android.app.ActivityManagerNative; import android.app.KeyguardManager; import android.app.PendingIntent; import android.app.TaskStackBuilder; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.database.ContentObserver; Loading @@ -47,6 +49,7 @@ import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserId; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; Loading @@ -65,6 +68,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupMenu; import android.widget.RemoteViews; import android.widget.TextView; import java.util.ArrayList; Loading @@ -72,6 +76,7 @@ public abstract class BaseStatusBar extends SystemUI implements CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener { static final String TAG = "StatusBar"; private static final boolean DEBUG = false; public static final boolean MULTIUSER_DEBUG = false; protected static final int MSG_OPEN_RECENTS_PANEL = 1020; protected static final int MSG_CLOSE_RECENTS_PANEL = 1021; Loading Loading @@ -112,6 +117,8 @@ public abstract class BaseStatusBar extends SystemUI implements protected PopupMenu mNotificationBlamePopup; protected int mCurrentUserId = 0; // UI-specific methods /** Loading Loading @@ -252,6 +259,40 @@ public abstract class BaseStatusBar extends SystemUI implements switches[3] )); } // XXX: this is currently broken and will always return 0, but should start working at some point try { mCurrentUserId = ActivityManagerNative.getDefault().getCurrentUser().id; } catch (RemoteException e) { Log.v(TAG, "Couldn't get current user ID; guessing it's 0", e); } IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_SWITCHED); mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_USER_SWITCHED.equals(action)) { mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USERID, -1); if (true) Slog.v(TAG, "userId " + mCurrentUserId + " is in the house"); userSwitched(mCurrentUserId); } }}, filter); } public void userSwitched(int newUserId) { // should be overridden } public boolean notificationIsForCurrentUser(StatusBarNotification n) { final int thisUserId = mCurrentUserId; final int notificationUserId = n.getUserId(); if (DEBUG && MULTIUSER_DEBUG) { Slog.v(TAG, String.format("%s: current userid: %d, notification userid: %d", n, thisUserId, notificationUserId)); } return thisUserId == notificationUserId; } protected View updateNotificationVetoButton(View row, StatusBarNotification n) { Loading Loading @@ -604,6 +645,14 @@ public abstract class BaseStatusBar extends SystemUI implements applyLegacyRowBackground(sbn, content); row.setTag(R.id.expandable_tag, Boolean.valueOf(large != null)); if (MULTIUSER_DEBUG) { TextView debug = (TextView) row.findViewById(R.id.debug_info); if (debug != null) { debug.setVisibility(View.VISIBLE); debug.setText("U " + entry.notification.getUserId()); } } entry.row = row; entry.content = content; entry.expanded = expandedOneU; Loading