am 4762c2d7
: Add expand and collapse.
This commit is contained in:
@ -105,18 +105,6 @@ public class StatusBarManager {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggle the status bar.
|
|
||||||
*/
|
|
||||||
public void toggle() {
|
|
||||||
try {
|
|
||||||
mService.toggle();
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
// system process is dead anyway.
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIcon(String slot, int iconId, int iconLevel) {
|
public void setIcon(String slot, int iconId, int iconLevel) {
|
||||||
try {
|
try {
|
||||||
|
@ -24,5 +24,7 @@ oneway interface IStatusBar
|
|||||||
void setIcon(int index, in StatusBarIcon icon);
|
void setIcon(int index, in StatusBarIcon icon);
|
||||||
void removeIcon(int index);
|
void removeIcon(int index);
|
||||||
void disable(int state);
|
void disable(int state);
|
||||||
|
void animateExpand();
|
||||||
|
void animateCollapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ interface IStatusBarService
|
|||||||
{
|
{
|
||||||
void expand();
|
void expand();
|
||||||
void collapse();
|
void collapse();
|
||||||
void toggle();
|
|
||||||
void disable(int what, IBinder token, String pkg);
|
void disable(int what, IBinder token, String pkg);
|
||||||
void setIcon(String slot, String iconPackage, int iconId, int iconLevel);
|
void setIcon(String slot, String iconPackage, int iconId, int iconLevel);
|
||||||
void setIconVisibility(String slot, boolean visible);
|
void setIconVisibility(String slot, boolean visible);
|
||||||
@ -33,4 +32,5 @@ interface IStatusBarService
|
|||||||
|
|
||||||
// ---- Methods below are for use by the status bar policy services ----
|
// ---- Methods below are for use by the status bar policy services ----
|
||||||
void registerStatusBar(IStatusBar callbacks, out StatusBarIconList state);
|
void registerStatusBar(IStatusBar callbacks, out StatusBarIconList state);
|
||||||
|
void visibilityChanged(boolean visible);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@ import com.android.internal.statusbar.StatusBarIconList;
|
|||||||
* This class takes the functions from IStatusBar that come in on
|
* This class takes the functions from IStatusBar that come in on
|
||||||
* binder pool threads and posts messages to get them onto the main
|
* binder pool threads and posts messages to get them onto the main
|
||||||
* thread, and calls onto Callbacks. It also takes care of
|
* thread, and calls onto Callbacks. It also takes care of
|
||||||
* coalescing these calls so they don't stack up.
|
* coalescing these calls so they don't stack up. For the calls
|
||||||
|
* are coalesced, note that they are all idempotent.
|
||||||
*/
|
*/
|
||||||
class CommandQueue extends IStatusBar.Stub {
|
class CommandQueue extends IStatusBar.Stub {
|
||||||
private static final String TAG = "StatusBar.CommandQueue";
|
private static final String TAG = "StatusBar.CommandQueue";
|
||||||
@ -42,6 +43,10 @@ class CommandQueue extends IStatusBar.Stub {
|
|||||||
|
|
||||||
private static final int MSG_DISABLE = 0x00020000;
|
private static final int MSG_DISABLE = 0x00020000;
|
||||||
|
|
||||||
|
private static final int MSG_SET_VISIBILITY = 0x00030000;
|
||||||
|
private static final int OP_EXPAND = 1;
|
||||||
|
private static final int OP_COLLAPSE = 2;
|
||||||
|
|
||||||
private StatusBarIconList mList;
|
private StatusBarIconList mList;
|
||||||
private Callbacks mCallbacks;
|
private Callbacks mCallbacks;
|
||||||
private Handler mHandler = new H();
|
private Handler mHandler = new H();
|
||||||
@ -55,6 +60,8 @@ class CommandQueue extends IStatusBar.Stub {
|
|||||||
StatusBarIcon old, StatusBarIcon icon);
|
StatusBarIcon old, StatusBarIcon icon);
|
||||||
public void removeIcon(String slot, int index, int viewIndex);
|
public void removeIcon(String slot, int index, int viewIndex);
|
||||||
public void disable(int state);
|
public void disable(int state);
|
||||||
|
public void animateExpand();
|
||||||
|
public void animateCollapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
|
public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
|
||||||
@ -85,9 +92,24 @@ class CommandQueue extends IStatusBar.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void animateExpand() {
|
||||||
|
synchronized (mList) {
|
||||||
|
mHandler.removeMessages(MSG_SET_VISIBILITY);
|
||||||
|
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_EXPAND, 0, null).sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void animateCollapse() {
|
||||||
|
synchronized (mList) {
|
||||||
|
mHandler.removeMessages(MSG_SET_VISIBILITY);
|
||||||
|
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, 0, null).sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final class H extends Handler {
|
private final class H extends Handler {
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
final int what = msg.what & MSG_MASK;
|
final int what = msg.what & MSG_MASK;
|
||||||
|
Slog.d(TAG, "handleMessage what=0x" + Integer.toHexString(what) + " arg1=" + msg.arg1);
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case MSG_ICON: {
|
case MSG_ICON: {
|
||||||
final int index = msg.what & INDEX_MASK;
|
final int index = msg.what & INDEX_MASK;
|
||||||
@ -116,6 +138,12 @@ class CommandQueue extends IStatusBar.Stub {
|
|||||||
case MSG_DISABLE:
|
case MSG_DISABLE:
|
||||||
mCallbacks.disable(msg.arg1);
|
mCallbacks.disable(msg.arg1);
|
||||||
break;
|
break;
|
||||||
|
case MSG_SET_VISIBILITY:
|
||||||
|
if (msg.arg1 == OP_EXPAND) {
|
||||||
|
mCallbacks.animateExpand();
|
||||||
|
} else {
|
||||||
|
mCallbacks.animateCollapse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
|
|
||||||
public class PhoneStatusBarService extends StatusBarService {
|
public class PhoneStatusBarService extends StatusBarService {
|
||||||
static final String TAG = "StatusBar";
|
static final String TAG = "PhoneStatusBarService";
|
||||||
static final boolean SPEW = false;
|
static final boolean SPEW = false;
|
||||||
|
|
||||||
public static final String ACTION_STATUSBAR_START
|
public static final String ACTION_STATUSBAR_START
|
||||||
@ -203,10 +203,6 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotificationCallbacks(NotificationCallbacks listener) {
|
|
||||||
mNotificationCallbacks = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
// Constructing the view
|
// Constructing the view
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
@ -365,7 +361,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All changes to the status bar and notifications funnel through here and are batched.
|
* All changes to the status bar and notifications funnel through here and are batched.
|
||||||
*/
|
*/
|
||||||
@ -531,7 +527,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mExpandedVisible = true;
|
mExpandedVisible = true;
|
||||||
panelSlightlyVisible(true);
|
visibilityChanged(true);
|
||||||
|
|
||||||
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
|
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
|
||||||
mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||||
@ -545,7 +541,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void animateExpand() {
|
public void animateExpand() {
|
||||||
if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded);
|
if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded);
|
||||||
if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) {
|
if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) {
|
||||||
return ;
|
return ;
|
||||||
@ -558,7 +554,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
performFling(0, 2000.0f, true);
|
performFling(0, 2000.0f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void animateCollapse() {
|
public void animateCollapse() {
|
||||||
if (SPEW) {
|
if (SPEW) {
|
||||||
Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded
|
Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded
|
||||||
+ " mExpandedVisible=" + mExpandedVisible
|
+ " mExpandedVisible=" + mExpandedVisible
|
||||||
@ -618,7 +614,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mExpandedVisible = false;
|
mExpandedVisible = false;
|
||||||
panelSlightlyVisible(false);
|
visibilityChanged(false);
|
||||||
mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||||
mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||||
mExpandedDialog.getWindow().setAttributes(mExpandedParams);
|
mExpandedDialog.getWindow().setAttributes(mExpandedParams);
|
||||||
@ -1205,7 +1201,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
// because the window itself extends below the content view.
|
// because the window itself extends below the content view.
|
||||||
mExpandedParams.y = -disph;
|
mExpandedParams.y = -disph;
|
||||||
}
|
}
|
||||||
panelSlightlyVisible(visible);
|
visibilityChanged(visible);
|
||||||
mExpandedDialog.getWindow().setAttributes(mExpandedParams);
|
mExpandedDialog.getWindow().setAttributes(mExpandedParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,16 +1233,13 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
* this is what he wants. (see bug 1131461)
|
* this is what he wants. (see bug 1131461)
|
||||||
*/
|
*/
|
||||||
private boolean mPanelSlightlyVisible;
|
private boolean mPanelSlightlyVisible;
|
||||||
void panelSlightlyVisible(boolean visible) {
|
void visibilityChanged(boolean visible) {
|
||||||
if (true) {
|
|
||||||
// XXX
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mPanelSlightlyVisible != visible) {
|
if (mPanelSlightlyVisible != visible) {
|
||||||
mPanelSlightlyVisible = visible;
|
mPanelSlightlyVisible = visible;
|
||||||
if (visible) {
|
try {
|
||||||
// tell the notification manager to turn off the lights.
|
mBarService.visibilityChanged(visible);
|
||||||
mNotificationCallbacks.onPanelRevealed();
|
} catch (RemoteException ex) {
|
||||||
|
// Won't fail unless the world has ended.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1260,7 +1253,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
|
if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
|
||||||
if ((net & StatusBarManager.DISABLE_EXPAND) != 0) {
|
if ((net & StatusBarManager.DISABLE_EXPAND) != 0) {
|
||||||
Slog.d(TAG, "DISABLE_EXPAND: yes");
|
Slog.d(TAG, "DISABLE_EXPAND: yes");
|
||||||
//animateCollapse();
|
animateCollapse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
|
if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
|
||||||
@ -1288,7 +1281,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
private View.OnClickListener mClearButtonListener = new View.OnClickListener() {
|
private View.OnClickListener mClearButtonListener = new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mNotificationCallbacks.onClearAll();
|
mNotificationCallbacks.onClearAll();
|
||||||
//addPendingOp(OP_EXPAND, null, false);
|
animateCollapse();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1140,22 +1140,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (code == KeyEvent.KEYCODE_NOTIFICATION) {
|
|
||||||
if (down) {
|
|
||||||
// this key doesn't exist on current hardware, but if a device
|
|
||||||
// didn't have a touchscreen, it would want one of these to open
|
|
||||||
// the status bar.
|
|
||||||
IStatusBarService sbs = IStatusBarService.Stub.asInterface(ServiceManager.getService("statusbar"));
|
|
||||||
if (sbs != null) {
|
|
||||||
try {
|
|
||||||
sbs.toggle();
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
// we're screwed anyway, since it's in this process
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else if (code == KeyEvent.KEYCODE_SEARCH) {
|
} else if (code == KeyEvent.KEYCODE_SEARCH) {
|
||||||
if (down) {
|
if (down) {
|
||||||
if (repeatCount == 0) {
|
if (repeatCount == 0) {
|
||||||
|
@ -49,7 +49,7 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
public class StatusBarManagerService extends IStatusBarService.Stub
|
public class StatusBarManagerService extends IStatusBarService.Stub
|
||||||
{
|
{
|
||||||
static final String TAG = "StatusBar";
|
static final String TAG = "StatusBarManagerService";
|
||||||
static final boolean SPEW = true;
|
static final boolean SPEW = true;
|
||||||
|
|
||||||
public static final String ACTION_STATUSBAR_START
|
public static final String ACTION_STATUSBAR_START
|
||||||
@ -58,7 +58,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
|||||||
final Context mContext;
|
final Context mContext;
|
||||||
Handler mHandler = new Handler();
|
Handler mHandler = new Handler();
|
||||||
NotificationCallbacks mNotificationCallbacks;
|
NotificationCallbacks mNotificationCallbacks;
|
||||||
IStatusBar mBar;
|
volatile IStatusBar mBar;
|
||||||
StatusBarIconList mIcons = new StatusBarIconList();
|
StatusBarIconList mIcons = new StatusBarIconList();
|
||||||
private UninstallReceiver mUninstallReceiver;
|
private UninstallReceiver mUninstallReceiver;
|
||||||
|
|
||||||
@ -115,20 +115,30 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
|||||||
Intent intent = new Intent(ACTION_STATUSBAR_START);
|
Intent intent = new Intent(ACTION_STATUSBAR_START);
|
||||||
mContext.sendBroadcast(intent /** permission **/);
|
mContext.sendBroadcast(intent /** permission **/);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
// From IStatusBarService
|
// From IStatusBarService
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
public void expand() {
|
public void expand() {
|
||||||
enforceExpandStatusBar();
|
enforceExpandStatusBar();
|
||||||
|
|
||||||
|
if (mBar != null) {
|
||||||
|
try {
|
||||||
|
mBar.animateExpand();
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collapse() {
|
public void collapse() {
|
||||||
enforceExpandStatusBar();
|
enforceExpandStatusBar();
|
||||||
}
|
|
||||||
|
|
||||||
public void toggle() {
|
if (mBar != null) {
|
||||||
enforceExpandStatusBar();
|
try {
|
||||||
|
mBar.animateCollapse();
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable(int what, IBinder token, String pkg) {
|
public void disable(int what, IBinder token, String pkg) {
|
||||||
@ -238,12 +248,24 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
|||||||
"StatusBarManagerService");
|
"StatusBarManagerService");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ================================================================================
|
||||||
|
// Callbacks from the status bar service.
|
||||||
|
// ================================================================================
|
||||||
public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList) {
|
public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList) {
|
||||||
Slog.i(TAG, "registerStatusBar bar=" + bar);
|
Slog.i(TAG, "registerStatusBar bar=" + bar);
|
||||||
mBar = bar;
|
mBar = bar;
|
||||||
iconList.copyFrom(mIcons);
|
iconList.copyFrom(mIcons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status bar service should call this when the user changes whether
|
||||||
|
* the status bar is visible or not.
|
||||||
|
*/
|
||||||
|
public void visibilityChanged(boolean visible) {
|
||||||
|
Slog.d(TAG, "visibilityChanged visible=" + visible);
|
||||||
|
}
|
||||||
|
|
||||||
public IBinder addNotification(IconData iconData, NotificationData notificationData) {
|
public IBinder addNotification(IconData iconData, NotificationData notificationData) {
|
||||||
return new Binder();
|
return new Binder();
|
||||||
}
|
}
|
||||||
|
@ -134,13 +134,9 @@ public class StatusBarTest extends TestActivity
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Test("Expand in 3 sec.") {
|
new Test("Expand") {
|
||||||
public void run() {
|
public void run() {
|
||||||
mHandler.postDelayed(new Runnable() {
|
mStatusBarManager.expand();
|
||||||
public void run() {
|
|
||||||
mStatusBarManager.expand();
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Test("Expand in 3 sec.") {
|
new Test("Expand in 3 sec.") {
|
||||||
@ -161,14 +157,5 @@ public class StatusBarTest extends TestActivity
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Test("Toggle in 3 sec.") {
|
|
||||||
public void run() {
|
|
||||||
mHandler.postDelayed(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
mStatusBarManager.toggle();
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user