Merge "Multiuser support for notifications, take 1." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
228916713d
@@ -19,6 +19,7 @@ package com.android.internal.statusbar;
|
|||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.os.UserId;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
|
|
||||||
@@ -132,6 +133,11 @@ public class StatusBarNotification implements Parcelable {
|
|||||||
return ((notification.flags & Notification.FLAG_ONGOING_EVENT) == 0)
|
return ((notification.flags & Notification.FLAG_ONGOING_EVENT) == 0)
|
||||||
&& ((notification.flags & Notification.FLAG_NO_CLEAR) == 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
|
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
|
||||||
<uses-permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK" />
|
<uses-permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||||
|
|
||||||
<!-- Networking and telephony -->
|
<!-- Networking and telephony -->
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
|||||||
@@ -65,11 +65,24 @@
|
|||||||
android:layout_weight="1"
|
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"
|
<ImageView android:id="@+id/clear_all_button"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:src="@drawable/ic_notify_clear"
|
android:src="@drawable/ic_notify_clear"
|
||||||
android:contentDescription="@string/accessibility_clear_all"
|
android:contentDescription="@string/accessibility_clear_all"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -49,4 +49,17 @@
|
|||||||
android:background="@drawable/bottom_divider_glow"
|
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>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -34,8 +34,10 @@ import android.app.ActivityManagerNative;
|
|||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.TaskStackBuilder;
|
import android.app.TaskStackBuilder;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@@ -47,6 +49,7 @@ import android.os.IBinder;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.UserId;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -65,6 +68,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -72,6 +76,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener {
|
CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener {
|
||||||
static final String TAG = "StatusBar";
|
static final String TAG = "StatusBar";
|
||||||
private static final boolean DEBUG = false;
|
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_OPEN_RECENTS_PANEL = 1020;
|
||||||
protected static final int MSG_CLOSE_RECENTS_PANEL = 1021;
|
protected static final int MSG_CLOSE_RECENTS_PANEL = 1021;
|
||||||
@@ -112,6 +117,8 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
|
|
||||||
protected PopupMenu mNotificationBlamePopup;
|
protected PopupMenu mNotificationBlamePopup;
|
||||||
|
|
||||||
|
protected int mCurrentUserId = 0;
|
||||||
|
|
||||||
// UI-specific methods
|
// UI-specific methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,6 +259,40 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
switches[3]
|
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) {
|
protected View updateNotificationVetoButton(View row, StatusBarNotification n) {
|
||||||
@@ -604,6 +645,14 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
applyLegacyRowBackground(sbn, content);
|
applyLegacyRowBackground(sbn, content);
|
||||||
|
|
||||||
row.setTag(R.id.expandable_tag, Boolean.valueOf(large != null));
|
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.row = row;
|
||||||
entry.content = content;
|
entry.content = content;
|
||||||
entry.expanded = expandedOneU;
|
entry.expanded = expandedOneU;
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
int mNotificationPanelMarginBottomPx, mNotificationPanelMarginPx;
|
int mNotificationPanelMarginBottomPx, mNotificationPanelMarginPx;
|
||||||
int mNotificationPanelMinHeight;
|
int mNotificationPanelMinHeight;
|
||||||
boolean mNotificationPanelIsFullScreenWidth;
|
boolean mNotificationPanelIsFullScreenWidth;
|
||||||
|
TextView mNotificationPanelDebugText;
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
PanelView mSettingsPanel;
|
PanelView mSettingsPanel;
|
||||||
@@ -343,6 +344,10 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
mIntruderAlertView.setVisibility(View.GONE);
|
mIntruderAlertView.setVisibility(View.GONE);
|
||||||
mIntruderAlertView.setBar(this);
|
mIntruderAlertView.setBar(this);
|
||||||
}
|
}
|
||||||
|
if (MULTIUSER_DEBUG) {
|
||||||
|
mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById(R.id.header_debug_info);
|
||||||
|
mNotificationPanelDebugText.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
updateShowSearchHoldoff();
|
updateShowSearchHoldoff();
|
||||||
|
|
||||||
@@ -806,9 +811,9 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
// If the device hasn't been through Setup, we only show system notifications
|
// If the device hasn't been through Setup, we only show system notifications
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
Entry ent = mNotificationData.get(N-i-1);
|
Entry ent = mNotificationData.get(N-i-1);
|
||||||
if (provisioned || showNotificationEvenIfUnprovisioned(ent.notification)) {
|
if (!(provisioned || showNotificationEvenIfUnprovisioned(ent.notification))) continue;
|
||||||
toShow.add(ent.row);
|
if (!notificationIsForCurrentUser(ent.notification)) continue;
|
||||||
}
|
toShow.add(ent.row);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<View> toRemove = new ArrayList<View>();
|
ArrayList<View> toRemove = new ArrayList<View>();
|
||||||
@@ -854,10 +859,10 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
// If the device hasn't been through Setup, we only show system notifications
|
// If the device hasn't been through Setup, we only show system notifications
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
Entry ent = mNotificationData.get(N-i-1);
|
Entry ent = mNotificationData.get(N-i-1);
|
||||||
if ((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE)
|
if (!((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE)
|
||||||
|| showNotificationEvenIfUnprovisioned(ent.notification)) {
|
|| showNotificationEvenIfUnprovisioned(ent.notification))) continue;
|
||||||
toShow.add(ent.icon);
|
if (!notificationIsForCurrentUser(ent.notification)) continue;
|
||||||
}
|
toShow.add(ent.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<View> toRemove = new ArrayList<View>();
|
ArrayList<View> toRemove = new ArrayList<View>();
|
||||||
@@ -1789,6 +1794,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
|
|
||||||
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Slog.v(TAG, "onReceive: " + intent);
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
|
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
|
||||||
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
|
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
|
||||||
@@ -1812,6 +1818,13 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void userSwitched(int newUserId) {
|
||||||
|
if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId);
|
||||||
|
animateCollapse();
|
||||||
|
updateNotificationIcons();
|
||||||
|
}
|
||||||
|
|
||||||
private void setIntruderAlertVisibility(boolean vis) {
|
private void setIntruderAlertVisibility(boolean vis) {
|
||||||
if (!ENABLE_INTRUDERS) return;
|
if (!ENABLE_INTRUDERS) return;
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|||||||
Reference in New Issue
Block a user