Commit 1ace1639 authored by Adam Langley's avatar Adam Langley Committed by Chromium LUCI CQ

webauthn: don't reference CameraView from XML.

When isolated splits are enabled the default Context won't find the
class inside the module. It's possible to use a different class loader
but since this View needs custom setup anyway, it's easier to just
handle it in code.

This is currently moot because isolated splits are disabled for the
cablev2_authenticator module, but will matter when that changes.

BUG=1002262

Change-Id: I86477e9f980a3754f3bb2cf9e3ff360e4abaf293
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555584
Commit-Queue: Adam Langley <agl@chromium.org>
Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#832585}
parent 32b38e9f
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/qr_dialog_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
...@@ -15,16 +16,23 @@ ...@@ -15,16 +16,23 @@
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:background ="@color/modern_grey_50"> android:background ="@color/modern_grey_50">
<!--
This will be inserted by QRScanDialog.java when inflated. It's not
referenced directly to avoid issues with reflection inside of split and
isolated modules.
<org.chromium.chrome.browser.webauth.authenticator.CameraView <org.chromium.chrome.browser.webauth.authenticator.CameraView
android:id="@+id/camera_view" android:id="@+id/camera_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="8dp" /> android:paddingBottom="8dp" />
-->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal"
android:paddingTop="8dp">
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
......
...@@ -13,6 +13,7 @@ import android.view.LayoutInflater; ...@@ -13,6 +13,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.LinearLayout;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
...@@ -63,7 +64,16 @@ public class QRScanDialog extends DialogFragment implements Camera.PreviewCallba ...@@ -63,7 +64,16 @@ public class QRScanDialog extends DialogFragment implements Camera.PreviewCallba
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.cablev2_qr_dialog, container, false); View v = inflater.inflate(R.layout.cablev2_qr_dialog, container, false);
mCameraView = v.findViewById(R.id.camera_view); // CameraView is not referenced from the XML in order to avoid issues
// with reflection of custom Views inside of split and isolated
// modules.
mCameraView = new CameraView(getContext(), null);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
((LinearLayout) v.findViewById(R.id.qr_dialog_layout))
.addView(mCameraView, /*index=*/0, params);
mCameraView.setCallback(this); mCameraView.setCallback(this);
mCameraView.setDisplay(getActivity().getWindowManager().getDefaultDisplay()); mCameraView.setDisplay(getActivity().getWindowManager().getDefaultDisplay());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment