diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index a98601a33300b..048c4bd4a770a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -16,6 +16,9 @@ package com.android.systemui.statusbar.phone; +import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; +import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; + import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.ActivityOptions; @@ -65,9 +68,6 @@ import com.android.systemui.statusbar.policy.AccessibilityController; import com.android.systemui.statusbar.policy.FlashlightController; import com.android.systemui.statusbar.policy.PreviewInflater; -import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; -import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; - /** * Implementation for the bottom area of the Keyguard, including camera/phone affordance and status * text. @@ -403,7 +403,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL public void bindCameraPrewarmService() { Intent intent = getCameraIntent(); ActivityInfo targetInfo = PreviewInflater.getTargetActivityInfo(mContext, intent, - KeyguardUpdateMonitor.getCurrentUser()); + KeyguardUpdateMonitor.getCurrentUser(), true /* onlyDirectBootAware */); if (targetInfo != null && targetInfo.metaData != null) { String clazz = targetInfo.metaData.getString( MediaStore.META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE); @@ -590,10 +590,16 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } private void inflateCameraPreview() { + View previewBefore = mCameraPreview; + boolean visibleBefore = false; + if (previewBefore != null) { + mPreviewContainer.removeView(previewBefore); + visibleBefore = previewBefore.getVisibility() == View.VISIBLE; + } mCameraPreview = mPreviewInflater.inflatePreview(getCameraIntent()); if (mCameraPreview != null) { mPreviewContainer.addView(mCameraPreview); - mCameraPreview.setVisibility(View.INVISIBLE); + mCameraPreview.setVisibility(visibleBefore ? View.VISIBLE : View.INVISIBLE); } } @@ -712,4 +718,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL updateLeftAffordanceIcon(); updateLeftPreview(); } + + public void onKeyguardShowingChanged() { + updateLeftAffordance(); + inflateCameraPreview(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 768e5f2b2f233..da3fcf7f2a7ff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -1013,7 +1013,7 @@ public class NotificationPanelView extends PanelView implements mKeyguardStatusBar.setAlpha(1f); mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE); if (keyguardShowing && oldState != mStatusBarState) { - mKeyguardBottomArea.updateLeftAffordance(); + mKeyguardBottomArea.onKeyguardShowingChanged(); mAfforanceHelper.updatePreviews(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java index 93d0ec362ade1..687b83a4bf634 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java @@ -119,13 +119,16 @@ public class PreviewInflater { private WidgetInfo getWidgetInfo(Intent intent) { PackageManager packageManager = mContext.getPackageManager(); + int flags = PackageManager.MATCH_DEFAULT_ONLY + | PackageManager.MATCH_DIRECT_BOOT_AWARE + | PackageManager.MATCH_DIRECT_BOOT_UNAWARE; final List appList = packageManager.queryIntentActivitiesAsUser( - intent, PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser()); + intent, flags, KeyguardUpdateMonitor.getCurrentUser()); if (appList.size() == 0) { return null; } ResolveInfo resolved = packageManager.resolveActivityAsUser(intent, - PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, + flags | PackageManager.GET_META_DATA, KeyguardUpdateMonitor.getCurrentUser()); if (wouldLaunchResolverActivity(resolved, appList)) { return null; @@ -139,23 +142,32 @@ public class PreviewInflater { public static boolean wouldLaunchResolverActivity(Context ctx, Intent intent, int currentUserId) { - return getTargetActivityInfo(ctx, intent, currentUserId) == null; + return getTargetActivityInfo(ctx, intent, currentUserId, false /* onlyDirectBootAware */) + == null; } /** + * @param onlyDirectBootAware a boolean indicating whether the matched activity packages must + * be direct boot aware when in direct boot mode if false, all + * packages are considered a match even if they are not aware. * @return the target activity info of the intent it resolves to a specific package or * {@code null} if it resolved to the resolver activity */ public static ActivityInfo getTargetActivityInfo(Context ctx, Intent intent, - int currentUserId) { + int currentUserId, boolean onlyDirectBootAware) { PackageManager packageManager = ctx.getPackageManager(); + int flags = PackageManager.MATCH_DEFAULT_ONLY; + if (!onlyDirectBootAware) { + flags |= PackageManager.MATCH_DIRECT_BOOT_AWARE + | PackageManager.MATCH_DIRECT_BOOT_UNAWARE; + } final List appList = packageManager.queryIntentActivitiesAsUser( - intent, PackageManager.MATCH_DEFAULT_ONLY, currentUserId); + intent, flags, currentUserId); if (appList.size() == 0) { return null; } ResolveInfo resolved = packageManager.resolveActivityAsUser(intent, - PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, currentUserId); + flags | PackageManager.GET_META_DATA, currentUserId); if (resolved == null || wouldLaunchResolverActivity(resolved, appList)) { return null; } else {