frameworks/base
Revision | 4ce29f8179a5322e27fb8f4316059a497159f444 (tree) |
---|---|
Time | 2015-10-28 02:38:34 |
Author | Adrian Roos <roosa@goog...> |
Commiter | The Android Automerger |
DO NOT MERGE Send next alarm's show intent via PendingIntent
Bug: 23909438
Change-Id: I0bb277c8385b7936fbda03cd76f02248c4fc55de
@@ -1528,6 +1528,58 @@ public abstract class BaseStatusBar extends SystemUI implements | ||
1528 | 1528 | return new NotificationClicker(intent, notificationKey, forHun); |
1529 | 1529 | } |
1530 | 1530 | |
1531 | + public void startPendingIntentDismissingKeyguard(final PendingIntent intent) { | |
1532 | + if (!isDeviceProvisioned()) return; | |
1533 | + | |
1534 | + final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); | |
1535 | + final boolean afterKeyguardGone = intent.isActivity() | |
1536 | + && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(), | |
1537 | + mCurrentUserId); | |
1538 | + dismissKeyguardThenExecute(new OnDismissAction() { | |
1539 | + public boolean onDismiss() { | |
1540 | + new Thread() { | |
1541 | + @Override | |
1542 | + public void run() { | |
1543 | + try { | |
1544 | + if (keyguardShowing && !afterKeyguardGone) { | |
1545 | + ActivityManagerNative.getDefault() | |
1546 | + .keyguardWaitingForActivityDrawn(); | |
1547 | + } | |
1548 | + | |
1549 | + // The intent we are sending is for the application, which | |
1550 | + // won't have permission to immediately start an activity after | |
1551 | + // the user switches to home. We know it is safe to do at this | |
1552 | + // point, so make sure new activity switches are now allowed. | |
1553 | + ActivityManagerNative.getDefault().resumeAppSwitches(); | |
1554 | + } catch (RemoteException e) { | |
1555 | + } | |
1556 | + | |
1557 | + try { | |
1558 | + intent.send(); | |
1559 | + } catch (PendingIntent.CanceledException e) { | |
1560 | + // the stack trace isn't very helpful here. | |
1561 | + // Just log the exception message. | |
1562 | + Log.w(TAG, "Sending intent failed: " + e); | |
1563 | + | |
1564 | + // TODO: Dismiss Keyguard. | |
1565 | + } | |
1566 | + if (intent.isActivity()) { | |
1567 | + overrideActivityPendingAppTransition(keyguardShowing | |
1568 | + && !afterKeyguardGone); | |
1569 | + } | |
1570 | + } | |
1571 | + }.start(); | |
1572 | + | |
1573 | + // close the shade if it was open | |
1574 | + animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, | |
1575 | + true /* force */); | |
1576 | + visibilityChanged(false); | |
1577 | + | |
1578 | + return true; | |
1579 | + } | |
1580 | + }, afterKeyguardGone); | |
1581 | + } | |
1582 | + | |
1531 | 1583 | protected class NotificationClicker implements View.OnClickListener { |
1532 | 1584 | private PendingIntent mIntent; |
1533 | 1585 | private final String mNotificationKey; |
@@ -16,6 +16,7 @@ | ||
16 | 16 | |
17 | 17 | package com.android.systemui.statusbar.phone; |
18 | 18 | |
19 | +import android.app.PendingIntent; | |
19 | 20 | import android.content.Intent; |
20 | 21 | |
21 | 22 | /** |
@@ -24,5 +25,6 @@ import android.content.Intent; | ||
24 | 25 | * Keyguard. |
25 | 26 | */ |
26 | 27 | public interface ActivityStarter { |
28 | + void startPendingIntentDismissingKeyguard(PendingIntent intent); | |
27 | 29 | public void startActivity(Intent intent, boolean dismissShade); |
28 | 30 | } |
@@ -16,6 +16,7 @@ | ||
16 | 16 | |
17 | 17 | package com.android.systemui.statusbar.phone; |
18 | 18 | |
19 | +import android.app.PendingIntent; | |
19 | 20 | import android.content.Context; |
20 | 21 | import android.content.Intent; |
21 | 22 | import android.content.res.Resources; |
@@ -498,8 +498,8 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL | ||
498 | 498 | startBatteryActivity(); |
499 | 499 | } else if (v == mAlarmStatus && mNextAlarm != null) { |
500 | 500 | PendingIntent showIntent = mNextAlarm.getShowIntent(); |
501 | - if (showIntent != null && showIntent.isActivity()) { | |
502 | - mActivityStarter.startActivity(showIntent.getIntent(), true /* dismissShade */); | |
501 | + if (showIntent != null) { | |
502 | + mActivityStarter.startPendingIntentDismissingKeyguard(showIntent); | |
503 | 503 | } |
504 | 504 | } |
505 | 505 | } |