Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a54a4794 authored by Danesh M's avatar Danesh M Committed by Danesh M
Browse files

SystemUI : Ensure previous camera preview is removed

For lockscreen shortcuts, ensure if the camera intent changes,
we remove the previous view.

Change-Id: I7c44353d25ddc47c3d986acf32dd9a3e85915c82
parent 734edc15
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ import com.android.systemui.statusbar.policy.AccessibilityController;
import com.android.systemui.statusbar.policy.FlashlightController;
import com.android.systemui.statusbar.policy.PreviewInflater;

import java.util.Objects;

import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;

@@ -131,6 +133,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private final WindowManager.LayoutParams mWindowLayoutParams;
    private OnInterceptTouchEventListener mInterceptTouchListener;
    private BroadcastReceiver mDevicePolicyReceiver;
    private Intent mLastCameraIntent;

    private final ServiceConnection mPrewarmConnection = new ServiceConnection() {

@@ -721,9 +724,18 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        if (isTargetCustom(Shortcuts.RIGHT_SHORTCUT)) {
            mPreviewContainer.removeView(mCameraPreview);
        } else {
            mCameraPreview = mPreviewInflater.inflatePreview(getCameraIntent());
            Intent cameraIntent = getCameraIntent();
            if (!Objects.equals(cameraIntent, mLastCameraIntent)) {
                if (mCameraPreview != null) {
                    mPreviewContainer.removeView(mCameraPreview);
                }
                mCameraPreview = mPreviewInflater.inflatePreview(cameraIntent);
                if (mCameraPreview != null) {
                    mPreviewContainer.addView(mCameraPreview);
                }
            }
            mLastCameraIntent = cameraIntent;
            if (mCameraPreview != null) {
                mCameraPreview.setVisibility(View.GONE);
            }
        }