Fixing issue where home was triggered on top of other activities being launched. (Bug 16823617)
- Also fixes issue with the Recents hide message being clobbered
This commit is contained in:
@ -39,7 +39,7 @@ oneway interface IStatusBar
|
||||
void notificationLightPulse(int argb, int millisOn, int millisOff);
|
||||
|
||||
void showRecentApps(boolean triggeredFromAltTab);
|
||||
void hideRecentApps(boolean triggeredFromAltTab);
|
||||
void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
|
||||
void toggleRecentApps();
|
||||
void preloadRecentApps();
|
||||
void cancelPreloadRecentApps();
|
||||
|
@ -55,7 +55,7 @@ interface IStatusBarService
|
||||
void setWindowState(int window, int state);
|
||||
|
||||
void showRecentApps(boolean triggeredFromAltTab);
|
||||
void hideRecentApps(boolean triggeredFromAltTab);
|
||||
void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
|
||||
void toggleRecentApps();
|
||||
void preloadRecentApps();
|
||||
void cancelPreloadRecentApps();
|
||||
|
@ -25,7 +25,7 @@ public interface RecentsComponent {
|
||||
}
|
||||
|
||||
void showRecents(boolean triggeredFromAltTab, View statusBarView);
|
||||
void hideRecents(boolean triggeredFromAltTab);
|
||||
void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
|
||||
void toggleRecents(Display display, int layoutDirection, View statusBarView);
|
||||
void preloadRecents();
|
||||
void cancelPreloadingRecents();
|
||||
|
@ -77,9 +77,9 @@ public class Recents extends SystemUI implements RecentsComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideRecents(boolean triggeredFromAltTab) {
|
||||
public void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
if (mUseAlternateRecents) {
|
||||
mAlternateRecents.onHideRecents(triggeredFromAltTab);
|
||||
mAlternateRecents.onHideRecents(triggeredFromAltTab, triggeredFromHomeKey);
|
||||
} else {
|
||||
Intent intent = new Intent(RecentsActivity.CLOSE_RECENTS_INTENT);
|
||||
intent.setPackage("com.android.systemui");
|
||||
|
@ -51,8 +51,13 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
||||
final public static String EXTRA_FROM_HOME = "recents.triggeredOverHome";
|
||||
final public static String EXTRA_FROM_APP_THUMBNAIL = "recents.animatingWithThumbnail";
|
||||
final public static String EXTRA_FROM_APP_FULL_SCREENSHOT = "recents.thumbnail";
|
||||
final public static String EXTRA_FROM_TASK_ID = "recents.activeTaskId";
|
||||
final public static String EXTRA_TRIGGERED_FROM_ALT_TAB = "recents.triggeredFromAltTab";
|
||||
final public static String EXTRA_TRIGGERED_FROM_TASK_ID = "recents.activeTaskId";
|
||||
final public static String EXTRA_TRIGGERED_FROM_HOME_KEY = "recents.triggeredFromHomeKey";
|
||||
|
||||
final public static String ACTION_START_ENTER_ANIMATION = "action_start_enter_animation";
|
||||
final public static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity";
|
||||
final public static String ACTION_HIDE_RECENTS_ACTIVITY = "action_hide_recents_activity";
|
||||
|
||||
final static int sMinToggleDelay = 425;
|
||||
|
||||
@ -126,14 +131,15 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
||||
}
|
||||
|
||||
/** Hides the recents */
|
||||
public void onHideRecents(boolean triggeredFromAltTab) {
|
||||
public void onHideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
if (mBootCompleted) {
|
||||
if (isRecentsTopMost(getTopMostTask(), null)) {
|
||||
// Notify recents to hide itself
|
||||
Intent intent = new Intent(RecentsActivity.ACTION_HIDE_RECENTS_ACTIVITY);
|
||||
Intent intent = new Intent(ACTION_HIDE_RECENTS_ACTIVITY);
|
||||
intent.setPackage(mContext.getPackageName());
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||
intent.putExtra(RecentsActivity.EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab);
|
||||
intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab);
|
||||
intent.putExtra(EXTRA_TRIGGERED_FROM_HOME_KEY, triggeredFromHomeKey);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||
}
|
||||
}
|
||||
@ -220,7 +226,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
||||
AtomicBoolean isTopTaskHome = new AtomicBoolean();
|
||||
if (isRecentsTopMost(topTask, isTopTaskHome)) {
|
||||
// Notify recents to toggle itself
|
||||
Intent intent = new Intent(RecentsActivity.ACTION_TOGGLE_RECENTS_ACTIVITY);
|
||||
Intent intent = new Intent(ACTION_TOGGLE_RECENTS_ACTIVITY);
|
||||
intent.setPackage(mContext.getPackageName());
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||
@ -403,7 +409,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
||||
intent.putExtra(extraFlag, true);
|
||||
}
|
||||
intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, mTriggeredFromAltTab);
|
||||
intent.putExtra(EXTRA_TRIGGERED_FROM_TASK_ID, (topTask != null) ? topTask.id : -1);
|
||||
intent.putExtra(EXTRA_FROM_TASK_ID, (topTask != null) ? topTask.id : -1);
|
||||
if (opts != null) {
|
||||
mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT);
|
||||
} else {
|
||||
@ -442,7 +448,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
||||
public void onAnimationStarted() {
|
||||
// Notify recents to start the enter animation
|
||||
if (!mStartAnimationTriggered) {
|
||||
Intent intent = new Intent(RecentsActivity.ACTION_START_ENTER_ANIMATION);
|
||||
Intent intent = new Intent(ACTION_START_ENTER_ANIMATION);
|
||||
intent.setPackage(mContext.getPackageName());
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||
|
@ -59,12 +59,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks,
|
||||
DebugOverlayView.DebugOverlayViewCallbacks {
|
||||
|
||||
// Actions and Extras sent from AlternateRecentsComponent
|
||||
final static String EXTRA_TRIGGERED_FROM_ALT_TAB = "extra_triggered_from_alt_tab";
|
||||
final static String ACTION_START_ENTER_ANIMATION = "action_start_enter_animation";
|
||||
final static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity";
|
||||
final static String ACTION_HIDE_RECENTS_ACTIVITY = "action_hide_recents_activity";
|
||||
|
||||
RecentsConfiguration mConfig;
|
||||
boolean mVisible;
|
||||
|
||||
@ -131,18 +125,22 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(ACTION_HIDE_RECENTS_ACTIVITY)) {
|
||||
if (intent.getBooleanExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, false)) {
|
||||
if (action.equals(AlternateRecentsComponent.ACTION_HIDE_RECENTS_ACTIVITY)) {
|
||||
// Mark Recents as no longer visible
|
||||
AlternateRecentsComponent.notifyVisibilityChanged(false);
|
||||
if (intent.getBooleanExtra(AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false)) {
|
||||
// If we are hiding from releasing Alt-Tab, dismiss Recents to the focused app
|
||||
dismissRecentsToFocusedTaskOrHome(false);
|
||||
} else {
|
||||
} else if (intent.getBooleanExtra(AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_HOME_KEY, false)) {
|
||||
// Otherwise, dismiss Recents to Home
|
||||
dismissRecentsToHome(true);
|
||||
} else {
|
||||
// Do nothing, another activity is being launched on top of Recents
|
||||
}
|
||||
} else if (action.equals(ACTION_TOGGLE_RECENTS_ACTIVITY)) {
|
||||
} else if (action.equals(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY)) {
|
||||
// If we are toggling Recents, then first unfilter any filtered stacks first
|
||||
dismissRecentsToFocusedTaskOrHome(true);
|
||||
} else if (action.equals(ACTION_START_ENTER_ANIMATION)) {
|
||||
} else if (action.equals(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION)) {
|
||||
// Try and start the enter animation (or restart it on configuration changed)
|
||||
ReferenceCountedTrigger t = new ReferenceCountedTrigger(context, null, null, null);
|
||||
mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t));
|
||||
@ -195,11 +193,11 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
AlternateRecentsComponent.EXTRA_FROM_APP_THUMBNAIL, false);
|
||||
mConfig.launchedFromAppWithScreenshot = launchIntent.getBooleanExtra(
|
||||
AlternateRecentsComponent.EXTRA_FROM_APP_FULL_SCREENSHOT, false);
|
||||
mConfig.launchedToTaskId = launchIntent.getIntExtra(
|
||||
AlternateRecentsComponent.EXTRA_FROM_TASK_ID, -1);
|
||||
mConfig.launchedWithAltTab = launchIntent.getBooleanExtra(
|
||||
AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
|
||||
mConfig.launchedWithNoRecentTasks = !root.hasTasks();
|
||||
mConfig.launchedToTaskId = launchIntent.getIntExtra(
|
||||
AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_TASK_ID, -1);
|
||||
|
||||
// Mark the task that is the launch target
|
||||
int taskStackCount = stacks.size();
|
||||
@ -444,9 +442,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
|
||||
// Register the broadcast receiver to handle messages from our service
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ACTION_HIDE_RECENTS_ACTIVITY);
|
||||
filter.addAction(ACTION_TOGGLE_RECENTS_ACTIVITY);
|
||||
filter.addAction(ACTION_START_ENTER_ANIMATION);
|
||||
filter.addAction(AlternateRecentsComponent.ACTION_HIDE_RECENTS_ACTIVITY);
|
||||
filter.addAction(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY);
|
||||
filter.addAction(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION);
|
||||
registerReceiver(mServiceBroadcastReceiver, filter);
|
||||
|
||||
// Register any broadcast receivers for the task loader
|
||||
|
@ -684,10 +684,11 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideRecentApps(boolean triggeredFromAltTab) {
|
||||
public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
int msg = MSG_HIDE_RECENT_APPS;
|
||||
mHandler.removeMessages(msg);
|
||||
mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0, 0).sendToTarget();
|
||||
mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0,
|
||||
triggeredFromHomeKey ? 1 : 0).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -797,9 +798,9 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
}
|
||||
}
|
||||
|
||||
protected void hideRecents(boolean triggeredFromAltTab) {
|
||||
protected void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
if (mRecents != null) {
|
||||
mRecents.hideRecents(triggeredFromAltTab);
|
||||
mRecents.hideRecents(triggeredFromAltTab, triggeredFromHomeKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -890,13 +891,12 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
|
||||
protected class H extends Handler {
|
||||
public void handleMessage(Message m) {
|
||||
Intent intent;
|
||||
switch (m.what) {
|
||||
case MSG_SHOW_RECENT_APPS:
|
||||
showRecents(m.arg1 > 0);
|
||||
break;
|
||||
case MSG_HIDE_RECENT_APPS:
|
||||
hideRecents(m.arg1 > 0);
|
||||
hideRecents(m.arg1 > 0, m.arg2 > 0);
|
||||
break;
|
||||
case MSG_TOGGLE_RECENTS_APPS:
|
||||
toggleRecents();
|
||||
|
@ -89,7 +89,7 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
boolean showImeSwitcher);
|
||||
public void setHardKeyboardStatus(boolean available, boolean enabled);
|
||||
public void showRecentApps(boolean triggeredFromAltTab);
|
||||
public void hideRecentApps(boolean triggeredFromAltTab);
|
||||
public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
|
||||
public void toggleRecentApps();
|
||||
public void preloadRecentApps();
|
||||
public void cancelPreloadRecentApps();
|
||||
@ -191,11 +191,12 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void hideRecentApps(boolean triggeredFromAltTab) {
|
||||
public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
synchronized (mList) {
|
||||
mHandler.removeMessages(MSG_HIDE_RECENT_APPS);
|
||||
mHandler.obtainMessage(MSG_HIDE_RECENT_APPS,
|
||||
triggeredFromAltTab ? 1 : 0, 0, null).sendToTarget();
|
||||
triggeredFromAltTab ? 1 : 0, triggeredFromHomeKey ? 1 : 0,
|
||||
null).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +307,7 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
mCallbacks.showRecentApps(msg.arg1 != 0);
|
||||
break;
|
||||
case MSG_HIDE_RECENT_APPS:
|
||||
mCallbacks.hideRecentApps(msg.arg1 != 0);
|
||||
mCallbacks.hideRecentApps(msg.arg1 != 0, msg.arg2 != 0);
|
||||
break;
|
||||
case MSG_TOGGLE_RECENT_APPS:
|
||||
mCallbacks.toggleRecentApps();
|
||||
|
@ -2130,8 +2130,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
}
|
||||
|
||||
if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) {
|
||||
mHandler.removeMessages(MSG_HIDE_RECENT_APPS);
|
||||
mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS);
|
||||
if (!mHandler.hasMessages(MSG_HIDE_RECENT_APPS)) {
|
||||
mHandler.removeMessages(MSG_HIDE_RECENT_APPS);
|
||||
mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS);
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL) == 0) {
|
||||
@ -3752,11 +3754,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hideRecents(boolean triggeredFromAltTab) {
|
||||
protected void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
// Unset the recents visibility flag
|
||||
mSystemUiVisibility &= ~View.RECENT_APPS_VISIBLE;
|
||||
notifyUiVisibilityChanged(mSystemUiVisibility);
|
||||
super.hideRecents(triggeredFromAltTab);
|
||||
super.hideRecents(triggeredFromAltTab, triggeredFromHomeKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2439,7 +2439,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
} else if (!down && mRecentAppsHeldModifiers != 0
|
||||
&& (metaState & mRecentAppsHeldModifiers) == 0) {
|
||||
mRecentAppsHeldModifiers = 0;
|
||||
hideRecentApps(true);
|
||||
hideRecentApps(true, false);
|
||||
}
|
||||
|
||||
// Handle keyboard language switching.
|
||||
@ -2658,12 +2658,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
private void hideRecentApps(boolean triggeredFromAltTab) {
|
||||
private void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHome) {
|
||||
mPreloadedRecentApps = false; // preloading no longer needs to be canceled
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
statusbar.hideRecentApps(triggeredFromAltTab);
|
||||
statusbar.hideRecentApps(triggeredFromAltTab, triggeredFromHome);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when closing recent apps", e);
|
||||
@ -2705,7 +2705,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
// Hide Recents and notify it to launch Home
|
||||
awakenDreams();
|
||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
||||
hideRecentApps(false);
|
||||
hideRecentApps(false, true);
|
||||
} else {
|
||||
// Otherwise, just launch Home
|
||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
||||
|
@ -453,10 +453,10 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideRecentApps(boolean triggeredFromAltTab) {
|
||||
public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
if (mBar != null) {
|
||||
try {
|
||||
mBar.hideRecentApps(triggeredFromAltTab);
|
||||
mBar.hideRecentApps(triggeredFromAltTab, triggeredFromHomeKey);
|
||||
} catch (RemoteException ex) {}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user