Merge "Loading the camera preview correctly with direct boot" into nyc-mr1-dev
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.phone;
|
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.ActivityManager;
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.app.ActivityOptions;
|
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.FlashlightController;
|
||||||
import com.android.systemui.statusbar.policy.PreviewInflater;
|
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
|
* Implementation for the bottom area of the Keyguard, including camera/phone affordance and status
|
||||||
* text.
|
* text.
|
||||||
@@ -403,7 +403,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
|||||||
public void bindCameraPrewarmService() {
|
public void bindCameraPrewarmService() {
|
||||||
Intent intent = getCameraIntent();
|
Intent intent = getCameraIntent();
|
||||||
ActivityInfo targetInfo = PreviewInflater.getTargetActivityInfo(mContext, intent,
|
ActivityInfo targetInfo = PreviewInflater.getTargetActivityInfo(mContext, intent,
|
||||||
KeyguardUpdateMonitor.getCurrentUser());
|
KeyguardUpdateMonitor.getCurrentUser(), true /* onlyDirectBootAware */);
|
||||||
if (targetInfo != null && targetInfo.metaData != null) {
|
if (targetInfo != null && targetInfo.metaData != null) {
|
||||||
String clazz = targetInfo.metaData.getString(
|
String clazz = targetInfo.metaData.getString(
|
||||||
MediaStore.META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE);
|
MediaStore.META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE);
|
||||||
@@ -590,10 +590,16 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void inflateCameraPreview() {
|
private void inflateCameraPreview() {
|
||||||
|
View previewBefore = mCameraPreview;
|
||||||
|
boolean visibleBefore = false;
|
||||||
|
if (previewBefore != null) {
|
||||||
|
mPreviewContainer.removeView(previewBefore);
|
||||||
|
visibleBefore = previewBefore.getVisibility() == View.VISIBLE;
|
||||||
|
}
|
||||||
mCameraPreview = mPreviewInflater.inflatePreview(getCameraIntent());
|
mCameraPreview = mPreviewInflater.inflatePreview(getCameraIntent());
|
||||||
if (mCameraPreview != null) {
|
if (mCameraPreview != null) {
|
||||||
mPreviewContainer.addView(mCameraPreview);
|
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();
|
updateLeftAffordanceIcon();
|
||||||
updateLeftPreview();
|
updateLeftPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onKeyguardShowingChanged() {
|
||||||
|
updateLeftAffordance();
|
||||||
|
inflateCameraPreview();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1013,7 +1013,7 @@ public class NotificationPanelView extends PanelView implements
|
|||||||
mKeyguardStatusBar.setAlpha(1f);
|
mKeyguardStatusBar.setAlpha(1f);
|
||||||
mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE);
|
mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE);
|
||||||
if (keyguardShowing && oldState != mStatusBarState) {
|
if (keyguardShowing && oldState != mStatusBarState) {
|
||||||
mKeyguardBottomArea.updateLeftAffordance();
|
mKeyguardBottomArea.onKeyguardShowingChanged();
|
||||||
mAfforanceHelper.updatePreviews();
|
mAfforanceHelper.updatePreviews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,13 +119,16 @@ public class PreviewInflater {
|
|||||||
|
|
||||||
private WidgetInfo getWidgetInfo(Intent intent) {
|
private WidgetInfo getWidgetInfo(Intent intent) {
|
||||||
PackageManager packageManager = mContext.getPackageManager();
|
PackageManager packageManager = mContext.getPackageManager();
|
||||||
|
int flags = PackageManager.MATCH_DEFAULT_ONLY
|
||||||
|
| PackageManager.MATCH_DIRECT_BOOT_AWARE
|
||||||
|
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
|
||||||
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
|
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
|
||||||
intent, PackageManager.MATCH_DEFAULT_ONLY, KeyguardUpdateMonitor.getCurrentUser());
|
intent, flags, KeyguardUpdateMonitor.getCurrentUser());
|
||||||
if (appList.size() == 0) {
|
if (appList.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
|
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
|
||||||
PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA,
|
flags | PackageManager.GET_META_DATA,
|
||||||
KeyguardUpdateMonitor.getCurrentUser());
|
KeyguardUpdateMonitor.getCurrentUser());
|
||||||
if (wouldLaunchResolverActivity(resolved, appList)) {
|
if (wouldLaunchResolverActivity(resolved, appList)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -139,23 +142,32 @@ public class PreviewInflater {
|
|||||||
|
|
||||||
public static boolean wouldLaunchResolverActivity(Context ctx, Intent intent,
|
public static boolean wouldLaunchResolverActivity(Context ctx, Intent intent,
|
||||||
int currentUserId) {
|
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
|
* @return the target activity info of the intent it resolves to a specific package or
|
||||||
* {@code null} if it resolved to the resolver activity
|
* {@code null} if it resolved to the resolver activity
|
||||||
*/
|
*/
|
||||||
public static ActivityInfo getTargetActivityInfo(Context ctx, Intent intent,
|
public static ActivityInfo getTargetActivityInfo(Context ctx, Intent intent,
|
||||||
int currentUserId) {
|
int currentUserId, boolean onlyDirectBootAware) {
|
||||||
PackageManager packageManager = ctx.getPackageManager();
|
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<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
|
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
|
||||||
intent, PackageManager.MATCH_DEFAULT_ONLY, currentUserId);
|
intent, flags, currentUserId);
|
||||||
if (appList.size() == 0) {
|
if (appList.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
|
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)) {
|
if (resolved == null || wouldLaunchResolverActivity(resolved, appList)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user