Skip to content

Commit a982ad1

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #5173952: Opening a Notification From Lock Screen..."
2 parents 6c984bc + 90c52de commit a982ad1

19 files changed

Lines changed: 170 additions & 34 deletions

File tree

core/java/android/app/ActivityManagerNative.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,13 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
15501550
return true;
15511551
}
15521552

1553+
case DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION: {
1554+
data.enforceInterface(IActivityManager.descriptor);
1555+
dismissKeyguardOnNextActivity();
1556+
reply.writeNoException();
1557+
return true;
1558+
}
1559+
15531560
}
15541561

15551562
return super.onTransact(code, data, reply, flags);
@@ -3504,5 +3511,15 @@ public void showBootMessage(CharSequence msg, boolean always) throws RemoteExcep
35043511
reply.recycle();
35053512
}
35063513

3514+
public void dismissKeyguardOnNextActivity() throws RemoteException {
3515+
Parcel data = Parcel.obtain();
3516+
Parcel reply = Parcel.obtain();
3517+
data.writeInterfaceToken(IActivityManager.descriptor);
3518+
mRemote.transact(DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION, data, reply, 0);
3519+
reply.readException();
3520+
data.recycle();
3521+
reply.recycle();
3522+
}
3523+
35073524
private IBinder mRemote;
35083525
}

core/java/android/app/IActivityManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ public void setPackageAskScreenCompat(String packageName, boolean ask)
372372

373373
public void showBootMessage(CharSequence msg, boolean always) throws RemoteException;
374374

375+
public void dismissKeyguardOnNextActivity() throws RemoteException;
376+
375377
/*
376378
* Private non-Binder interfaces
377379
*/
@@ -602,4 +604,5 @@ private WaitResult(Parcel source) {
602604
int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
603605
int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136;
604606
int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
607+
int DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+138;
605608
}

core/java/android/content/Intent.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5577,24 +5577,35 @@ public int filterHashCode() {
55775577

55785578
@Override
55795579
public String toString() {
5580-
StringBuilder b = new StringBuilder(128);
5580+
StringBuilder b = new StringBuilder(128);
55815581

55825582
b.append("Intent { ");
5583-
toShortString(b, true, true);
5583+
toShortString(b, true, true, true);
55845584
b.append(" }");
55855585

55865586
return b.toString();
55875587
}
55885588

55895589
/** @hide */
5590-
public String toShortString(boolean comp, boolean extras) {
5591-
StringBuilder b = new StringBuilder(128);
5592-
toShortString(b, comp, extras);
5590+
public String toInsecureString() {
5591+
StringBuilder b = new StringBuilder(128);
5592+
5593+
b.append("Intent { ");
5594+
toShortString(b, false, true, true);
5595+
b.append(" }");
5596+
55935597
return b.toString();
55945598
}
55955599

55965600
/** @hide */
5597-
public void toShortString(StringBuilder b, boolean comp, boolean extras) {
5601+
public String toShortString(boolean secure, boolean comp, boolean extras) {
5602+
StringBuilder b = new StringBuilder(128);
5603+
toShortString(b, secure, comp, extras);
5604+
return b.toString();
5605+
}
5606+
5607+
/** @hide */
5608+
public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras) {
55985609
boolean first = true;
55995610
if (mAction != null) {
56005611
b.append("act=").append(mAction);
@@ -5621,19 +5632,8 @@ public void toShortString(StringBuilder b, boolean comp, boolean extras) {
56215632
}
56225633
first = false;
56235634
b.append("dat=");
5624-
String scheme = mData.getScheme();
5625-
if (scheme != null) {
5626-
if (scheme.equalsIgnoreCase("tel")) {
5627-
b.append("tel:xxx-xxx-xxxx");
5628-
} else if (scheme.equalsIgnoreCase("sip")) {
5629-
b.append("sip:xxxxxxxxxx");
5630-
} else if (scheme.equalsIgnoreCase("sms")) {
5631-
b.append("sms:xxx-xxx-xxxx");
5632-
} else if (scheme.equalsIgnoreCase("smsto")) {
5633-
b.append("smsto:xxx-xxx-xxxx");
5634-
} else {
5635-
b.append(mData);
5636-
}
5635+
if (secure) {
5636+
b.append(mData.toSafeString());
56375637
} else {
56385638
b.append(mData);
56395639
}

core/java/android/net/Uri.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,48 @@ public int compareTo(Uri other) {
352352
*/
353353
public abstract String toString();
354354

355+
/**
356+
* Return a string representation of the URI that is safe to print
357+
* to logs and other places where PII should be avoided.
358+
* @hide
359+
*/
360+
public String toSafeString() {
361+
String scheme = getScheme();
362+
String ssp = getSchemeSpecificPart();
363+
if (scheme != null) {
364+
if (scheme.equalsIgnoreCase("tel") || scheme.equalsIgnoreCase("sip")
365+
|| scheme.equalsIgnoreCase("sms") || scheme.equalsIgnoreCase("smsto")
366+
|| scheme.equalsIgnoreCase("mailto")) {
367+
StringBuilder builder = new StringBuilder(64);
368+
builder.append(scheme);
369+
builder.append(':');
370+
if (ssp != null) {
371+
for (int i=0; i<ssp.length(); i++) {
372+
char c = ssp.charAt(i);
373+
if (c == '-' || c == '@' || c == '.') {
374+
builder.append(c);
375+
} else {
376+
builder.append('x');
377+
}
378+
}
379+
}
380+
return builder.toString();
381+
}
382+
}
383+
// Not a sensitive scheme, but let's still be conservative about
384+
// the data we include -- only the ssp, not the query params or
385+
// fragment, because those can often have sensitive info.
386+
StringBuilder builder = new StringBuilder(64);
387+
if (scheme != null) {
388+
builder.append(scheme);
389+
builder.append(':');
390+
}
391+
if (ssp != null) {
392+
builder.append(ssp);
393+
}
394+
return builder.toString();
395+
}
396+
355397
/**
356398
* Constructs a new builder, copying the attributes from this Uri.
357399
*/

core/java/android/view/IWindowManager.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ interface IWindowManager
116116
boolean isKeyguardLocked();
117117
boolean isKeyguardSecure();
118118
boolean inKeyguardRestrictedInputMode();
119+
void dismissKeyguard();
119120

120121
void closeSystemDialogs(String reason);
121122

core/java/android/view/WindowManagerPolicy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,11 @@ interface OnKeyguardExitResult {
849849
*/
850850
public boolean inKeyguardRestrictedKeyInputMode();
851851

852+
/**
853+
* Ask the policy to dismiss the keyguard, if it is currently shown.
854+
*/
855+
public void dismissKeyguardLw();
856+
852857
/**
853858
* Given an orientation constant, returns the appropriate surface rotation,
854859
* taking into account sensors, docking mode, rotation lock, and other factors.

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,9 @@ public void onClick(View v) {
15991599
// the user switches to home. We know it is safe to do at this
16001600
// point, so make sure new activity switches are now allowed.
16011601
ActivityManagerNative.getDefault().resumeAppSwitches();
1602+
// Also, notifications can be launched from the lock screen,
1603+
// so dismiss the lock screen when the activity starts.
1604+
ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
16021605
} catch (RemoteException e) {
16031606
}
16041607

packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,9 @@ public void onClick(View v) {
13081308
// the user switches to home. We know it is safe to do at this
13091309
// point, so make sure new activity switches are now allowed.
13101310
ActivityManagerNative.getDefault().resumeAppSwitches();
1311+
// Also, notifications can be launched from the lock screen,
1312+
// so dismiss the lock screen when the activity starts.
1313+
ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
13111314
} catch (RemoteException e) {
13121315
}
13131316

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,6 +2871,18 @@ public boolean inKeyguardRestrictedKeyInputMode() {
28712871
return mKeyguardMediator.isInputRestricted();
28722872
}
28732873

2874+
public void dismissKeyguardLw() {
2875+
if (!mKeyguardMediator.isSecure()) {
2876+
if (mKeyguardMediator.isShowing()) {
2877+
mHandler.post(new Runnable() {
2878+
public void run() {
2879+
mKeyguardMediator.keyguardDone(false, true);
2880+
}
2881+
});
2882+
}
2883+
}
2884+
}
2885+
28742886
void sendCloseSystemWindows() {
28752887
sendCloseSystemWindows(mContext, null);
28762888
}

services/java/com/android/server/AlarmManagerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
477477
: bs.filterStats.entrySet()) {
478478
pw.print(" "); pw.print(fe.getValue().count);
479479
pw.print(" alarms: ");
480-
pw.println(fe.getKey().getIntent().toShortString(true, false));
480+
pw.println(fe.getKey().getIntent().toShortString(false, true, false));
481481
}
482482
}
483483
}

0 commit comments

Comments
 (0)