Merge "Fix potential NPE in NotificationRecord's KeyguardManager call" into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0dca838108
@@ -103,7 +103,7 @@ public final class NotificationRecord {
|
|||||||
final int mTargetSdkVersion;
|
final int mTargetSdkVersion;
|
||||||
final int mOriginalFlags;
|
final int mOriginalFlags;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final KeyguardManager mKeyguardManager;
|
private KeyguardManager mKeyguardManager;
|
||||||
private final PowerManager mPowerManager;
|
private final PowerManager mPowerManager;
|
||||||
NotificationUsageStats.SingleNotificationStats stats;
|
NotificationUsageStats.SingleNotificationStats stats;
|
||||||
boolean isCanceled;
|
boolean isCanceled;
|
||||||
@@ -1625,10 +1625,21 @@ public final class NotificationRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean isLocked() {
|
boolean isLocked() {
|
||||||
return mKeyguardManager.isKeyguardLocked()
|
return getKeyguardManager().isKeyguardLocked()
|
||||||
|| !mPowerManager.isInteractive(); // Unlocked AOD
|
|| !mPowerManager.isInteractive(); // Unlocked AOD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For some early {@link NotificationRecord}, {@link KeyguardManager} can be {@code null} in
|
||||||
|
* the constructor. Retrieve it again if it is null.
|
||||||
|
*/
|
||||||
|
private KeyguardManager getKeyguardManager() {
|
||||||
|
if (mKeyguardManager == null) {
|
||||||
|
mKeyguardManager = mContext.getSystemService(KeyguardManager.class);
|
||||||
|
}
|
||||||
|
return mKeyguardManager;
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final class Light {
|
static final class Light {
|
||||||
public final int color;
|
public final int color;
|
||||||
|
|||||||
Reference in New Issue
Block a user