diff options
9 files changed, 291 insertions, 197 deletions
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index aca1fa2..6e36fdb 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -35,5 +35,7 @@ oneway interface IStatusBar void setImeWindowStatus(in IBinder token, int vis, int backDisposition); void setHardKeyboardStatus(boolean available, boolean enabled); void toggleRecentApps(); + void preloadRecentApps(); + void cancelPreloadRecentApps(); } diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index ecebfc0..118e541 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -47,4 +47,6 @@ interface IStatusBarService void setSystemUiVisibility(int vis); void setHardKeyboardEnabled(boolean enabled); void toggleRecentApps(); + void preloadRecentApps(); + void cancelPreloadRecentApps(); } diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 564b07b..ebed522 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -456,6 +456,9 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener mPreloadTasksRunnable = new Runnable() { public void run() { + // If we set our visibility to INVISIBLE here, we avoid an extra call to + // onLayout later when we become visible (because onLayout is always called + // when going from GONE) if (!mShowing) { setVisibility(INVISIBLE); refreshRecentTasksList(); @@ -562,9 +565,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener if (!mShowing) { int action = ev.getAction() & MotionEvent.ACTION_MASK; if (action == MotionEvent.ACTION_DOWN) { - // If we set our visibility to INVISIBLE here, we avoid an extra call to - // onLayout later when we become visible (because onLayout is always called - // when going from GONE) post(mPreloadTasksRunnable); } else if (action == MotionEvent.ACTION_CANCEL) { setVisibility(GONE); @@ -583,9 +583,15 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener return false; } + public void preloadRecentTasksList() { + if (!mShowing) { + mPreloadTasksRunnable.run(); + } + } + public void clearRecentTasksList() { // Clear memory used by screenshots - if (mRecentTaskDescriptions != null) { + if (!mShowing && mRecentTaskDescriptions != null) { mRecentTasksLoader.cancelLoadingThumbnailsAndIcons(); mRecentTaskDescriptions.clear(); mListAdapter.notifyDataSetInvalidated(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 3a06127..832d539 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -19,31 +19,53 @@ package com.android.systemui.statusbar; import java.util.ArrayList; import android.content.Context; +import android.os.Handler; import android.os.IBinder; +import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; import android.util.Slog; import android.view.Display; import android.view.IWindowManager; +import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; +import android.view.WindowManagerImpl; +import android.widget.LinearLayout; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.statusbar.StatusBarIconList; import com.android.internal.statusbar.StatusBarNotification; import com.android.systemui.SystemUI; +import com.android.systemui.recent.RecentsPanelView; +import com.android.systemui.recent.RecentTasksLoader; +import com.android.systemui.recent.TaskDescription; import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.tablet.StatusBarPanel; import com.android.systemui.R; -public abstract class BaseStatusBar extends SystemUI implements CommandQueue.Callbacks { +public abstract class BaseStatusBar extends SystemUI implements + CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener { static final String TAG = "StatusBar"; private static final boolean DEBUG = false; + protected static final int MSG_OPEN_RECENTS_PANEL = 1020; + protected static final int MSG_CLOSE_RECENTS_PANEL = 1021; + protected static final int MSG_PRELOAD_RECENT_APPS = 1022; + protected static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 1023; + protected CommandQueue mCommandQueue; protected IStatusBarService mBarService; + protected H mHandler = createHandler(); + + // Recent apps + protected RecentsPanelView mRecentsPanel; + protected RecentTasksLoader mRecentTasksLoader; // UI-specific methods @@ -162,4 +184,121 @@ public abstract class BaseStatusBar extends SystemUI implements CommandQueue.Cal public void dismissIntruder() { // pass } + + @Override + public void toggleRecentApps() { + int msg = (mRecentsPanel.getVisibility() == View.VISIBLE) + ? MSG_CLOSE_RECENTS_PANEL : MSG_OPEN_RECENTS_PANEL; + mHandler.removeMessages(msg); + mHandler.sendEmptyMessage(msg); + } + + @Override + public void preloadRecentApps() { + int msg = MSG_PRELOAD_RECENT_APPS; + mHandler.removeMessages(msg); + mHandler.sendEmptyMessage(msg); + } + + @Override + public void cancelPreloadRecentApps() { + int msg = MSG_CANCEL_PRELOAD_RECENT_APPS; + mHandler.removeMessages(msg); + mHandler.sendEmptyMessage(msg); + } + + @Override + public void onRecentsPanelVisibilityChanged(boolean visible) { + } + + protected abstract WindowManager.LayoutParams getRecentsLayoutParams( + LayoutParams layoutParams); + + protected void updateRecentsPanel() { + // Recents Panel + boolean visible = false; + ArrayList<TaskDescription> recentTasksList = null; + boolean firstScreenful = false; + if (mRecentsPanel != null) { + visible = mRecentsPanel.isShowing(); + WindowManagerImpl.getDefault().removeView(mRecentsPanel); + if (visible) { + recentTasksList = mRecentsPanel.getRecentTasksList(); + firstScreenful = mRecentsPanel.getFirstScreenful(); + } + } + + // Provide RecentsPanelView with a temporary parent to allow layout params to work. + LinearLayout tmpRoot = new LinearLayout(mContext); + mRecentsPanel = (RecentsPanelView) LayoutInflater.from(mContext).inflate( + R.layout.status_bar_recent_panel, tmpRoot, false); + mRecentsPanel.setRecentTasksLoader(mRecentTasksLoader); + mRecentTasksLoader.setRecentsPanel(mRecentsPanel); + mRecentsPanel.setOnTouchListener( + new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, mRecentsPanel)); + mRecentsPanel.setVisibility(View.GONE); + + + WindowManager.LayoutParams lp = getRecentsLayoutParams(mRecentsPanel.getLayoutParams()); + + WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); + mRecentsPanel.setBar(this); + if (visible) { + mRecentsPanel.show(true, false, recentTasksList, firstScreenful); + } + + } + + H createHandler() { + return new H(); + } + + protected class H extends Handler { + public void handleMessage(Message m) { + switch (m.what) { + case MSG_OPEN_RECENTS_PANEL: + if (DEBUG) Slog.d(TAG, "opening recents panel"); + if (mRecentsPanel != null) { + mRecentsPanel.show(true, true); + } + break; + case MSG_CLOSE_RECENTS_PANEL: + if (DEBUG) Slog.d(TAG, "closing recents panel"); + if (mRecentsPanel != null && mRecentsPanel.isShowing()) { + mRecentsPanel.show(false, true); + } + break; + case MSG_PRELOAD_RECENT_APPS: + if (DEBUG) Slog.d(TAG, "preloading recents"); + mRecentsPanel.preloadRecentTasksList(); + break; + case MSG_CANCEL_PRELOAD_RECENT_APPS: + if (DEBUG) Slog.d(TAG, "cancel preloading recents"); + mRecentsPanel.clearRecentTasksList(); + break; + } + } + } + + public class TouchOutsideListener implements View.OnTouchListener { + private int mMsg; + private StatusBarPanel mPanel; + + public TouchOutsideListener(int msg, StatusBarPanel panel) { + mMsg = msg; + mPanel = panel; + } + + public boolean onTouch(View v, MotionEvent ev) { + final int action = ev.getAction(); + if (action == MotionEvent.ACTION_OUTSIDE + || (action == MotionEvent.ACTION_DOWN + && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { + mHandler.removeMessages(mMsg); + mHandler.sendEmptyMessage(mMsg); + return true; + } + return false; + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index f8dfa8f..37ab58a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -61,8 +61,10 @@ public class CommandQueue extends IStatusBar.Stub { private static final int MSG_SET_HARD_KEYBOARD_STATUS = 10 << MSG_SHIFT; private static final int MSG_TOGGLE_RECENT_APPS = 11 << MSG_SHIFT; + private static final int MSG_PRELOAD_RECENT_APPS = 12 << MSG_SHIFT; + private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 13 << MSG_SHIFT; - private static final int MSG_SET_NAVIGATION_ICON_HINTS = 13 << MSG_SHIFT; + private static final int MSG_SET_NAVIGATION_ICON_HINTS = 14 << MSG_SHIFT; private StatusBarIconList mList; private Callbacks mCallbacks; @@ -92,6 +94,8 @@ public class CommandQueue extends IStatusBar.Stub { public void setImeWindowStatus(IBinder token, int vis, int backDisposition); public void setHardKeyboardStatus(boolean available, boolean enabled); public void toggleRecentApps(); + public void preloadRecentApps(); + public void cancelPreloadRecentApps(); public void setNavigationIconHints(int hints); } @@ -199,6 +203,20 @@ public class CommandQueue extends IStatusBar.Stub { } } + public void preloadRecentApps() { + synchronized (mList) { + mHandler.removeMessages(MSG_PRELOAD_RECENT_APPS); + mHandler.obtainMessage(MSG_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget(); + } + } + + public void cancelPreloadRecentApps() { + synchronized (mList) { + mHandler.removeMessages(MSG_CANCEL_PRELOAD_RECENT_APPS); + mHandler.obtainMessage(MSG_CANCEL_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget(); + } + } + public void setNavigationIconHints(int hints) { synchronized (mList) { mHandler.removeMessages(MSG_SET_NAVIGATION_ICON_HINTS); @@ -275,6 +293,12 @@ public class CommandQueue extends IStatusBar.Stub { case MSG_TOGGLE_RECENT_APPS: mCallbacks.toggleRecentApps(); break; + case MSG_PRELOAD_RECENT_APPS: + mCallbacks.preloadRecentApps(); + break; + case MSG_CANCEL_PRELOAD_RECENT_APPS: + mCallbacks.cancelPreloadRecentApps(); + break; case MSG_SET_NAVIGATION_ICON_HINTS: mCallbacks.setNavigationIconHints(msg.arg1); break; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 023b21f..a8ab597 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -30,24 +30,22 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.Resources; import android.content.res.Configuration; -import android.inputmethodservice.InputMethodService; +import android.content.res.Resources; import android.graphics.PixelFormat; import android.graphics.Rect; -import android.graphics.drawable.Drawable; +import android.inputmethodservice.InputMethodService; import android.os.Build; import android.os.IBinder; -import android.os.RemoteException; -import android.os.Handler; import android.os.Message; +import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.provider.Settings; import android.text.TextUtils; import android.util.DisplayMetrics; -import android.util.Slog; import android.util.Log; +import android.util.Slog; import android.view.Display; import android.view.Gravity; import android.view.IWindowManager; @@ -76,19 +74,16 @@ import java.util.ArrayList; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.statusbar.StatusBarNotification; - import com.android.systemui.R; import com.android.systemui.SwipeHelper; import com.android.systemui.recent.RecentTasksLoader; -import com.android.systemui.recent.RecentsPanelView; -import com.android.systemui.recent.TaskDescription; -import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.BaseStatusBar; -import com.android.systemui.statusbar.StatusBarIconView; +import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.SignalClusterView; -import com.android.systemui.statusbar.policy.DateView; +import com.android.systemui.statusbar.StatusBarIconView; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.IntruderAlertView; +import com.android.systemui.statusbar.policy.DateView; import com.android.systemui.statusbar.policy.LocationController; import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.statusbar.policy.NotificationRowLayout; @@ -116,8 +111,7 @@ public class PhoneStatusBar extends BaseStatusBar { private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; private static final int MSG_SHOW_INTRUDER = 1002; private static final int MSG_HIDE_INTRUDER = 1003; - private static final int MSG_OPEN_RECENTS_PANEL = 1020; - private static final int MSG_CLOSE_RECENTS_PANEL = 1021; + // 1020-1030 reserved for BaseStatusBar // will likely move to a resource or other tunable param at some point private static final int INTRUDER_ALERT_DECAY_MS = 0; // disabled, was 10000; @@ -152,7 +146,6 @@ public class PhoneStatusBar extends BaseStatusBar { PhoneStatusBarView mStatusBarView; int mPixelFormat; - H mHandler = new H(); Object mQueueLock = new Object(); // icons @@ -202,10 +195,6 @@ public class PhoneStatusBar extends BaseStatusBar { private View mTickerView; private boolean mTicking; - // Recent apps - private RecentsPanelView mRecentsPanel; - private RecentTasksLoader mRecentTasksLoader; - // Tracking finger for opening/closing. int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore boolean mTracking; @@ -382,6 +371,7 @@ public class PhoneStatusBar extends BaseStatusBar { return sb; } + @Override protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { boolean opaque = false; WindowManager.LayoutParams lp = new WindowManager.LayoutParams( @@ -406,42 +396,13 @@ public class PhoneStatusBar extends BaseStatusBar { return lp; } + @Override protected void updateRecentsPanel() { - // Recents Panel - boolean visible = false; - ArrayList<TaskDescription> recentTasksList = null; - boolean firstScreenful = false; - if (mRecentsPanel != null) { - visible = mRecentsPanel.isShowing(); - WindowManagerImpl.getDefault().removeView(mRecentsPanel); - if (visible) { - recentTasksList = mRecentsPanel.getRecentTasksList(); - firstScreenful = mRecentsPanel.getFirstScreenful(); - } - } - - // Provide RecentsPanelView with a temporary parent to allow layout params to work. - LinearLayout tmpRoot = new LinearLayout(mContext); - mRecentsPanel = (RecentsPanelView) LayoutInflater.from(mContext).inflate( - R.layout.status_bar_recent_panel, tmpRoot, false); - mRecentsPanel.setRecentTasksLoader(mRecentTasksLoader); - mRecentTasksLoader.setRecentsPanel(mRecentsPanel); - mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, - mRecentsPanel)); - mRecentsPanel.setVisibility(View.GONE); - + super.updateRecentsPanel(); // Make .03 alpha the minimum so you always see the item a bit-- slightly below // .03, the item disappears entirely (as if alpha = 0) and that discontinuity looks // a bit jarring mRecentsPanel.setMinSwipeAlpha(0.03f); - WindowManager.LayoutParams lp = getRecentsLayoutParams(mRecentsPanel.getLayoutParams()); - - WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); - mRecentsPanel.setBar(this); - if (visible) { - mRecentsPanel.show(true, false, recentTasksList, firstScreenful); - } - } protected int getStatusBarGravity() { @@ -1076,11 +1037,17 @@ public class PhoneStatusBar extends BaseStatusBar { } } + @Override + BaseStatusBar.H createHandler() { + return new PhoneStatusBar.H(); + } + /** * All changes to the status bar and notifications funnel through here and are batched. */ - private class H extends Handler { + private class H extends BaseStatusBar.H { public void handleMessage(Message m) { + super.handleMessage(m); switch (m.what) { case MSG_ANIMATE: doAnimation(); @@ -1101,18 +1068,6 @@ public class PhoneStatusBar extends BaseStatusBar { setIntruderAlertVisibility(false); mCurrentlyIntrudingNotification = null; break; - case MSG_OPEN_RECENTS_PANEL: - if (DEBUG) Slog.d(TAG, "opening recents panel"); - if (mRecentsPanel != null) { - mRecentsPanel.show(true, true); - } - break; - case MSG_CLOSE_RECENTS_PANEL: - if (DEBUG) Slog.d(TAG, "closing recents panel"); - if (mRecentsPanel != null && mRecentsPanel.isShowing()) { - mRecentsPanel.show(false, true); - } - break; } } } @@ -2041,13 +1996,6 @@ public class PhoneStatusBar extends BaseStatusBar { } } - public void toggleRecentApps() { - int msg = (mRecentsPanel.getVisibility() == View.VISIBLE) - ? MSG_CLOSE_RECENTS_PANEL : MSG_OPEN_RECENTS_PANEL; - mHandler.removeMessages(msg); - mHandler.sendEmptyMessage(msg); - } - /** * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. * This was added last-minute and is inconsistent with the way the rest of the notifications @@ -2335,27 +2283,5 @@ public class PhoneStatusBar extends BaseStatusBar { vibrate(); } }; - - public class TouchOutsideListener implements View.OnTouchListener { - private int mMsg; - private RecentsPanelView mPanel; - - public TouchOutsideListener(int msg, RecentsPanelView panel) { - mMsg = msg; - mPanel = panel; - } - - public boolean onTouch(View v, MotionEvent ev) { - final int action = ev.getAction(); - if (action == MotionEvent.ACTION_OUTSIDE - || (action == MotionEvent.ACTION_DOWN - && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { - mHandler.removeMessages(mMsg); - mHandler.sendEmptyMessage(mMsg); - return true; - } - return false; - } - } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index 9d5faa4..71644f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -36,21 +36,19 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; -import android.inputmethodservice.InputMethodService; import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; +import android.inputmethodservice.InputMethodService; import android.os.Build; -import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; import android.text.TextUtils; import android.util.Slog; -import android.view.accessibility.AccessibilityEvent; import android.view.Display; import android.view.Gravity; import android.view.IWindowManager; @@ -62,8 +60,10 @@ import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; import android.view.WindowManagerImpl; +import android.view.accessibility.AccessibilityEvent; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RemoteViews; @@ -78,7 +78,6 @@ import com.android.systemui.recent.RecentsPanelView; import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.SignalClusterView; -import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.StatusBarIconView; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BluetoothController; @@ -100,8 +99,7 @@ public class TabletStatusBar extends BaseStatusBar implements public static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; public static final int MSG_OPEN_NOTIFICATION_PEEK = 1002; public static final int MSG_CLOSE_NOTIFICATION_PEEK = 1003; - public static final int MSG_OPEN_RECENTS_PANEL = 1020; - public static final int MSG_CLOSE_RECENTS_PANEL = 1021; + // 1020-1029 reserved for BaseStatusBar public static final int MSG_SHOW_CHROME = 1030; public static final int MSG_HIDE_CHROME = 1031; public static final int MSG_OPEN_INPUT_METHODS_PANEL = 1040; @@ -127,8 +125,6 @@ public class TabletStatusBar extends BaseStatusBar implements int mMenuNavIconWidth = -1; private int mMaxNotificationIcons = 5; - H mHandler = new H(); - IWindowManager mWindowManager; // tracking all current notifications @@ -189,8 +185,6 @@ public class TabletStatusBar extends BaseStatusBar implements // for disabling the status bar int mDisabled = 0; - private RecentsPanelView mRecentsPanel; - private RecentTasksLoader mRecentTasksLoader; private InputMethodsPanel mInputMethodsPanel; private CompatModePanel mCompatModePanel; @@ -348,33 +342,7 @@ public class TabletStatusBar extends BaseStatusBar implements // Recents Panel mRecentTasksLoader = new RecentTasksLoader(context); - mRecentsPanel = (RecentsPanelView) View.inflate(context, - R.layout.status_bar_recent_panel, null); - mRecentsPanel.setVisibility(View.GONE); - mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, - mRecentsPanel)); - mRecentsPanel.setOnVisibilityChangedListener(this); - mRecentsPanel.setRecentTasksLoader(mRecentTasksLoader); - mRecentTasksLoader.setRecentsPanel(mRecentsPanel); - - lp = new WindowManager.LayoutParams( - (int) res.getDimension(R.dimen.status_bar_recents_width), - ViewGroup.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, - WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN - | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM - | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH - | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, - PixelFormat.TRANSLUCENT); - lp.gravity = Gravity.BOTTOM | Gravity.LEFT; - lp.setTitle("RecentsPanel"); - lp.windowAnimations = R.style.Animation_RecentPanel; - lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; - - WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); - mRecentsPanel.setBar(this); - mRecentsPanel.setStatusBarView(mStatusBarView); + updateRecentsPanel(); // Input methods Panel mInputMethodsPanel = (InputMethodsPanel) View.inflate(context, @@ -680,6 +648,31 @@ public class TabletStatusBar extends BaseStatusBar implements return sb; } + @Override + protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { + WindowManager.LayoutParams lp = new WindowManager.LayoutParams( + (int) mContext.getResources().getDimension(R.dimen.status_bar_recents_width), + ViewGroup.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, + WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN + | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM + | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH + | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, + PixelFormat.TRANSLUCENT); + lp.gravity = Gravity.BOTTOM | Gravity.LEFT; + lp.setTitle("RecentsPanel"); + lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; + lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED + | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; + + return lp; + } + + protected void updateRecentsPanel() { + super.updateRecentsPanel(); + mRecentsPanel.setStatusBarView(mStatusBarView); + } + public int getStatusBarHeight() { return mHeightReceiver.getHeight(); } @@ -702,8 +695,14 @@ public class TabletStatusBar extends BaseStatusBar implements } } - private class H extends Handler { + @Override + BaseStatusBar.H createHandler() { + return new TabletStatusBar.H(); + } + + private class H extends BaseStatusBar.H { public void handleMessage(Message m) { + super.handleMessage(m); switch (m.what) { case MSG_OPEN_NOTIFICATION_PEEK: if (DEBUG) Slog.d(TAG, "opening notification peek window; arg=" + m.arg1); @@ -798,18 +797,6 @@ public class TabletStatusBar extends BaseStatusBar implements mNotificationArea.setVisibility(View.VISIBLE); } break; - case MSG_OPEN_RECENTS_PANEL: - if (DEBUG) Slog.d(TAG, "opening recents panel"); - if (mRecentsPanel != null) { - mRecentsPanel.show(true, true); - } - break; - case MSG_CLOSE_RECENTS_PANEL: - if (DEBUG) Slog.d(TAG, "closing recents panel"); - if (mRecentsPanel != null && mRecentsPanel.isShowing()) { - mRecentsPanel.show(false, true); - } - break; case MSG_OPEN_INPUT_METHODS_PANEL: if (DEBUG) Slog.d(TAG, "opening input methods panel"); if (mInputMethodsPanel != null) mInputMethodsPanel.openPanel(); @@ -1921,13 +1908,6 @@ public class TabletStatusBar extends BaseStatusBar implements visibilityChanged(false); } - public void toggleRecentApps() { - int msg = (mRecentsPanel.getVisibility() == View.VISIBLE) - ? MSG_CLOSE_RECENTS_PANEL : MSG_OPEN_RECENTS_PANEL; - mHandler.removeMessages(msg); - mHandler.sendEmptyMessage(msg); - } - private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); @@ -1953,28 +1933,6 @@ public class TabletStatusBar extends BaseStatusBar implements } }; - public class TouchOutsideListener implements View.OnTouchListener { - private int mMsg; - private StatusBarPanel mPanel; - - public TouchOutsideListener(int msg, StatusBarPanel panel) { - mMsg = msg; - mPanel = panel; - } - - public boolean onTouch(View v, MotionEvent ev) { - final int action = ev.getAction(); - if (action == MotionEvent.ACTION_OUTSIDE - || (action == MotionEvent.ACTION_DOWN - && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { - mHandler.removeMessages(mMsg); - mHandler.sendEmptyMessage(mMsg); - return true; - } - return false; - } - } - public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.print("mDisabled=0x"); pw.println(Integer.toHexString(mDisabled)); diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 92c94a9..6214086 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -430,6 +430,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mHideLockScreen; boolean mDismissKeyguard; boolean mHomePressed; + boolean mHomeLongPressed; Intent mHomeIntent; Intent mCarDockIntent; Intent mDeskDockIntent; @@ -744,7 +745,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Eat the longpress so it won't dismiss the recent apps dialog when // the user lets go of the home key - mHomePressed = false; + mHomeLongPressed = true; } if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_DIALOG) { @@ -1619,33 +1620,45 @@ public class PhoneWindowManager implements WindowManagerPolicy { // it handle it, because that gives us the correct 5 second // timeout. if (keyCode == KeyEvent.KEYCODE_HOME) { + // If we have released the home key, and didn't do anything else // while it was pressed, then it is time to go home! - if (mHomePressed && !down) { + if (!down) { + final boolean homeWasLongPressed = mHomeLongPressed; mHomePressed = false; - if (!canceled) { - // If an incoming call is ringing, HOME is totally disabled. - // (The user is already on the InCallScreen at this point, - // and his ONLY options are to answer or reject the call.) - boolean incomingRinging = false; + mHomeLongPressed = false; + if (!homeWasLongPressed) { try { - ITelephony telephonyService = getTelephonyService(); - if (telephonyService != null) { - incomingRinging = telephonyService.isRinging(); - } - } catch (RemoteException ex) { - Log.w(TAG, "RemoteException from getPhoneInterface()", ex); + mStatusBarService.cancelPreloadRecentApps(); + } catch (RemoteException e) { + Slog.e(TAG, "RemoteException when showing recent apps", e); } - if (incomingRinging) { - Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); + mHomePressed = false; + if (!canceled) { + // If an incoming call is ringing, HOME is totally disabled. + // (The user is already on the InCallScreen at this point, + // and his ONLY options are to answer or reject the call.) + boolean incomingRinging = false; + try { + ITelephony telephonyService = getTelephonyService(); + if (telephonyService != null) { + incomingRinging = telephonyService.isRinging(); + } + } catch (RemoteException ex) { + Log.w(TAG, "RemoteException from getPhoneInterface()", ex); + } + + if (incomingRinging) { + Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); + } else { + launchHomeFromHotKey(); + } } else { - launchHomeFromHotKey(); + Log.i(TAG, "Ignoring HOME; event canceled."); } - } else { - Log.i(TAG, "Ignoring HOME; event canceled."); + return -1; } - return -1; } // If a system window has focus, then it doesn't make sense @@ -1666,8 +1679,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } - if (down) { + if (!mHomePressed) { + try { + mStatusBarService.preloadRecentApps(); + } catch (RemoteException e) { + Slog.e(TAG, "RemoteException when preloading recent apps", e); + } + } if (repeatCount == 0) { mHomePressed = true; } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java index a9ff6c5..6452be7 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -352,6 +352,24 @@ public class StatusBarManagerService extends IStatusBarService.Stub } } + @Override + public void preloadRecentApps() { + if (mBar != null) { + try { + mBar.preloadRecentApps(); + } catch (RemoteException ex) {} + } + } + + @Override + public void cancelPreloadRecentApps() { + if (mBar != null) { + try { + mBar.cancelPreloadRecentApps(); + } catch (RemoteException ex) {} + } + } + private void enforceStatusBar() { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR, "StatusBarManagerService"); |
