summaryrefslogtreecommitdiffstats
path: root/java/com/android/incallui/answer
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-03-20 20:40:36 +0000
committerEric Erfanian <erfanian@google.com>2017-03-20 20:40:36 +0000
commit30ccc4f3aa6da94f0bb8a01a880a6353b883b263 (patch)
tree2f55365aaf87df9ba7c1fe0be56a7d0988eadf30 /java/com/android/incallui/answer
parent06b6b56e9eaa91ebf757ea641e38a9c885fa40bd (diff)
downloadandroid_packages_apps_Dialer-30ccc4f3aa6da94f0bb8a01a880a6353b883b263.tar.gz
android_packages_apps_Dialer-30ccc4f3aa6da94f0bb8a01a880a6353b883b263.tar.bz2
android_packages_apps_Dialer-30ccc4f3aa6da94f0bb8a01a880a6353b883b263.zip
Revert "Update AOSP Dialer source from internal google3 repository at cl/150622237"
This reverts commit 06b6b56e9eaa91ebf757ea641e38a9c885fa40bd. Change-Id: Ida8c5ee67669524dc63b9adc60a6dd392cb9b9a6
Diffstat (limited to 'java/com/android/incallui/answer')
-rw-r--r--java/com/android/incallui/answer/bindings/AnswerBindings.java8
-rw-r--r--java/com/android/incallui/answer/impl/AnswerFragment.java19
-rw-r--r--java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java86
-rw-r--r--java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java268
-rw-r--r--java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml20
-rw-r--r--java/com/android/incallui/answer/impl/res/values-land/dimens.xml20
-rw-r--r--java/com/android/incallui/answer/impl/res/values/attrs.xml26
-rw-r--r--java/com/android/incallui/answer/impl/res/values/dimens.xml3
8 files changed, 11 insertions, 439 deletions
diff --git a/java/com/android/incallui/answer/bindings/AnswerBindings.java b/java/com/android/incallui/answer/bindings/AnswerBindings.java
index 8be283990..442e207a0 100644
--- a/java/com/android/incallui/answer/bindings/AnswerBindings.java
+++ b/java/com/android/incallui/answer/bindings/AnswerBindings.java
@@ -23,11 +23,7 @@ import com.android.incallui.answer.protocol.AnswerScreen;
public class AnswerBindings {
public static AnswerScreen createAnswerScreen(
- String callId,
- boolean isVideoCall,
- boolean isVideoUpgradeRequest,
- boolean isSelfManagedCamera) {
- return AnswerFragment.newInstance(
- callId, isVideoCall, isVideoUpgradeRequest, isSelfManagedCamera);
+ String callId, boolean isVideoCall, boolean isVideoUpgradeRequest) {
+ return AnswerFragment.newInstance(callId, isVideoCall, isVideoUpgradeRequest);
}
}
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index a6174686c..6874daea3 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -106,9 +106,6 @@ public class AnswerFragment extends Fragment
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
static final String ARG_IS_VIDEO_UPGRADE_REQUEST = "is_video_upgrade_request";
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- static final String ARG_IS_SELF_MANAGED_CAMERA = "is_self_managed_camera";
-
private static final String STATE_HAS_ANIMATED_ENTRY = "hasAnimated";
private static final int HINT_SECONDARY_SHOW_DURATION_MILLIS = 5000;
@@ -291,15 +288,11 @@ public class AnswerFragment extends Fragment
}
public static AnswerFragment newInstance(
- String callId,
- boolean isVideoCall,
- boolean isVideoUpgradeRequest,
- boolean isSelfManagedCamera) {
+ String callId, boolean isVideoCall, boolean isVideoUpgradeRequest) {
Bundle bundle = new Bundle();
bundle.putString(ARG_CALL_ID, Assert.isNotNull(callId));
bundle.putBoolean(ARG_IS_VIDEO_CALL, isVideoCall);
bundle.putBoolean(ARG_IS_VIDEO_UPGRADE_REQUEST, isVideoUpgradeRequest);
- bundle.putBoolean(ARG_IS_SELF_MANAGED_CAMERA, isSelfManagedCamera);
AnswerFragment instance = new AnswerFragment();
instance.setArguments(bundle);
@@ -627,11 +620,7 @@ public class AnswerFragment extends Fragment
view.setSystemUiVisibility(flags);
if (isVideoCall() || isVideoUpgradeRequest()) {
if (VideoUtils.hasCameraPermissionAndAllowedByUser(getContext())) {
- if (isSelfManagedCamera()) {
- answerVideoCallScreen = new SelfManagedAnswerVideoCallScreen(getCallId(), this, view);
- } else {
- answerVideoCallScreen = new AnswerVideoCallScreen(getCallId(), this, view);
- }
+ answerVideoCallScreen = new AnswerVideoCallScreen(getCallId(), this, view);
} else {
view.findViewById(R.id.videocall_video_off).setVisibility(View.VISIBLE);
}
@@ -729,10 +718,6 @@ public class AnswerFragment extends Fragment
return getArguments().getBoolean(ARG_IS_VIDEO_CALL);
}
- public boolean isSelfManagedCamera() {
- return getArguments().getBoolean(ARG_IS_SELF_MANAGED_CAMERA);
- }
-
@Override
public void onAnswerProgressUpdate(@FloatRange(from = -1f, to = 1f) float answerProgress) {
// Don't fade the window background for call waiting or video upgrades. Fading the background
diff --git a/java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java b/java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java
deleted file mode 100644
index ad7d94d95..000000000
--- a/java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.incallui.answer.impl;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.view.SurfaceView;
-import android.view.View;
-import com.android.dialer.common.Assert;
-
-/**
- * A SurfaceView that maintains its aspect ratio to be a desired target value.
- *
- * <p>The FixedAspectSurfaceView will not be able to maintain the requested aspect ratio if both the
- * width and the height are exactly determined by the layout. To avoid this, ensure that either the
- * height or the width is adjustable by the view; for example, by setting the layout parameters to
- * be WRAP_CONTENT for the dimension that is best adjusted to maintain the aspect ratio.
- */
-public class FixedAspectSurfaceView extends SurfaceView {
-
- /** Desired width/height ratio */
- private float mAspectRatio;
-
- private final boolean scaleWidth;
- private final boolean scaleHeight;
-
- public FixedAspectSurfaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- // Get initial aspect ratio from custom attributes
- TypedArray a =
- context.getTheme().obtainStyledAttributes(attrs, R.styleable.FixedAspectSurfaceView, 0, 0);
- scaleHeight = a.getBoolean(R.styleable.FixedAspectSurfaceView_scaleHeight, false);
- scaleWidth = a.getBoolean(R.styleable.FixedAspectSurfaceView_scaleWidth, false);
- Assert.checkArgument(scaleHeight != scaleWidth, "Must either scale width or height");
- setAspectRatio(a.getFloat(R.styleable.FixedAspectSurfaceView_aspectRatio, 1.f));
- a.recycle();
- }
-
- /**
- * Set the desired aspect ratio for this view.
- *
- * @param aspect the desired width/height ratio in the current UI orientation. Must be a positive
- * value.
- */
- public void setAspectRatio(float aspect) {
- Assert.checkArgument(aspect >= 0, "Aspect ratio must be positive");
- mAspectRatio = aspect;
- requestLayout();
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int width = MeasureSpec.getSize(widthMeasureSpec);
- int height = MeasureSpec.getSize(heightMeasureSpec);
-
- // Do the scaling
- if (scaleWidth) {
- width = (int) (height * mAspectRatio);
- } else if (scaleHeight) {
- height = (int) (width / mAspectRatio);
- }
-
- // Override width/height if needed for EXACTLY and AT_MOST specs
- width = View.resolveSizeAndState(width, widthMeasureSpec, 0);
- height = View.resolveSizeAndState(height, heightMeasureSpec, 0);
-
- // Finally set the calculated dimensions
- setMeasuredDimension(width, height);
- }
-}
diff --git a/java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java b/java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java
deleted file mode 100644
index 522d77235..000000000
--- a/java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.incallui.answer.impl;
-
-import android.content.Context;
-import android.hardware.camera2.CameraAccessException;
-import android.hardware.camera2.CameraCaptureSession;
-import android.hardware.camera2.CameraCharacteristics;
-import android.hardware.camera2.CameraDevice;
-import android.hardware.camera2.CameraDevice.StateCallback;
-import android.hardware.camera2.CameraManager;
-import android.hardware.camera2.CameraMetadata;
-import android.hardware.camera2.CaptureRequest;
-import android.hardware.camera2.params.StreamConfigurationMap;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.util.Size;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.View;
-import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
-import com.android.incallui.video.protocol.VideoCallScreen;
-import java.util.Arrays;
-
-/**
- * Shows the local preview for the incoming video call or video upgrade request. This class is used
- * for RCS Video Share where we need to open the camera preview ourselves. For IMS Video the camera
- * is managed by the modem, see {@link AnswerVideoCallScreen}.
- */
-public class SelfManagedAnswerVideoCallScreen extends StateCallback implements VideoCallScreen {
-
- private static final int MAX_WIDTH = 1920;
- private static final float ASPECT_TOLERANCE = 0.1f;
- private static final float TARGET_ASPECT = 16.f / 9.f;
-
- @NonNull private final String callId;
- @NonNull private final Fragment fragment;
- @NonNull private final FixedAspectSurfaceView surfaceView;
- private final Context context;
-
- private String cameraId;
- private CameraDevice camera;
- private CaptureRequest.Builder captureRequestBuilder;
-
- public SelfManagedAnswerVideoCallScreen(
- @NonNull String callId, @NonNull Fragment fragment, @NonNull View view) {
- this.callId = Assert.isNotNull(callId);
- this.fragment = Assert.isNotNull(fragment);
- this.context = Assert.isNotNull(fragment.getContext());
-
- surfaceView =
- Assert.isNotNull(
- (FixedAspectSurfaceView) view.findViewById(R.id.incoming_preview_surface_view));
- surfaceView.setVisibility(View.VISIBLE);
- view.findViewById(R.id.incoming_preview_texture_view_overlay).setVisibility(View.VISIBLE);
- view.setBackgroundColor(0xff000000);
- }
-
- @Override
- public void onVideoScreenStart() {
- openCamera();
- }
-
- @Override
- public void onVideoScreenStop() {
- closeCamera();
- }
-
- @Override
- public void showVideoViews(
- boolean shouldShowPreview, boolean shouldShowRemote, boolean isRemotelyHeld) {}
-
- @Override
- public void onLocalVideoDimensionsChanged() {}
-
- @Override
- public void onLocalVideoOrientationChanged() {}
-
- @Override
- public void onRemoteVideoDimensionsChanged() {}
-
- @Override
- public void updateFullscreenAndGreenScreenMode(
- boolean shouldShowFullscreen, boolean shouldShowGreenScreen) {}
-
- @Override
- public Fragment getVideoCallScreenFragment() {
- return fragment;
- }
-
- @Override
- public String getCallId() {
- return callId;
- }
-
- /**
- * Opens the first front facing camera on the device into a {@link SurfaceView} while preserving
- * aspect ratio.
- */
- private void openCamera() {
- CameraManager manager = context.getSystemService(CameraManager.class);
-
- StreamConfigurationMap configMap = getFrontFacingCameraSizes(manager);
- if (configMap == null) {
- return;
- }
-
- Size previewSize = getOptimalSize(configMap.getOutputSizes(SurfaceHolder.class));
- LogUtil.i("SelfManagedAnswerVideoCallScreen.openCamera", "Optimal size: " + previewSize);
- float outputAspect = (float) previewSize.getWidth() / previewSize.getHeight();
- surfaceView.setAspectRatio(outputAspect);
- surfaceView.getHolder().setFixedSize(previewSize.getWidth(), previewSize.getHeight());
-
- try {
- manager.openCamera(cameraId, this, null);
- } catch (CameraAccessException e) {
- LogUtil.e("SelfManagedAnswerVideoCallScreen.openCamera", "failed to open camera", e);
- }
- }
-
- @Nullable
- private StreamConfigurationMap getFrontFacingCameraSizes(CameraManager manager) {
- String[] cameraIds;
- try {
- cameraIds = manager.getCameraIdList();
- } catch (CameraAccessException e) {
- LogUtil.e(
- "SelfManagedAnswerVideoCallScreen.getFrontFacingCameraSizes",
- "failed to get camera ids",
- e);
- return null;
- }
-
- for (String cameraId : cameraIds) {
- CameraCharacteristics characteristics;
- try {
- characteristics = manager.getCameraCharacteristics(cameraId);
- } catch (CameraAccessException e) {
- LogUtil.e(
- "SelfManagedAnswerVideoCallScreen.getFrontFacingCameraSizes",
- "failed to get camera characteristics",
- e);
- continue;
- }
-
- if (characteristics.get(CameraCharacteristics.LENS_FACING)
- != CameraCharacteristics.LENS_FACING_FRONT) {
- continue;
- }
-
- StreamConfigurationMap configMap =
- characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
- if (configMap == null) {
- continue;
- }
-
- this.cameraId = cameraId;
- return configMap;
- }
- LogUtil.e(
- "SelfManagedAnswerVideoCallScreen.getFrontFacingCameraSizes", "No valid configurations.");
- return null;
- }
-
- /**
- * Given an array of {@link Size}s, tries to find the largest Size such that the aspect ratio of
- * the returned size is within {@code ASPECT_TOLERANCE} of {@code TARGET_ASPECT}. This is useful
- * because it provides us with an adequate size/camera resolution that will experience the least
- * stretching from our fullscreen UI that doesn't match any of the camera sizes.
- */
- private static Size getOptimalSize(Size[] outputSizes) {
- Size bestCandidateSize = outputSizes[0];
- float bestCandidateAspect =
- (float) bestCandidateSize.getWidth() / bestCandidateSize.getHeight();
-
- for (Size candidateSize : outputSizes) {
- if (candidateSize.getWidth() < MAX_WIDTH) {
- float candidateAspect = (float) candidateSize.getWidth() / candidateSize.getHeight();
- boolean isGoodCandidateAspect =
- Math.abs(candidateAspect - TARGET_ASPECT) < ASPECT_TOLERANCE;
- boolean isGoodOutputAspect =
- Math.abs(bestCandidateAspect - TARGET_ASPECT) < ASPECT_TOLERANCE;
-
- if ((isGoodCandidateAspect && !isGoodOutputAspect)
- || candidateSize.getWidth() > bestCandidateSize.getWidth()) {
- bestCandidateSize = candidateSize;
- bestCandidateAspect = candidateAspect;
- }
- }
- }
- return bestCandidateSize;
- }
-
- @Override
- public void onOpened(CameraDevice camera) {
- LogUtil.i("SelfManagedAnswerVideoCallScreen.opOpened", "camera opened.");
- this.camera = camera;
- Surface surface = surfaceView.getHolder().getSurface();
- try {
- captureRequestBuilder = camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
- captureRequestBuilder.addTarget(surface);
- camera.createCaptureSession(Arrays.asList(surface), new CaptureSessionCallback(), null);
- } catch (CameraAccessException e) {
- LogUtil.e(
- "SelfManagedAnswerVideoCallScreen.createCameraPreview", "failed to create preview", e);
- }
- }
-
- @Override
- public void onDisconnected(CameraDevice camera) {
- closeCamera();
- }
-
- @Override
- public void onError(CameraDevice camera, int error) {
- closeCamera();
- }
-
- private void closeCamera() {
- if (camera != null) {
- camera.close();
- camera = null;
- }
- }
-
- private class CaptureSessionCallback extends CameraCaptureSession.StateCallback {
-
- @Override
- public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
- LogUtil.i(
- "SelfManagedAnswerVideoCallScreen.onConfigured", "camera capture session configured.");
- // The camera is already closed.
- if (camera == null) {
- return;
- }
-
- // When the session is ready, we start displaying the preview.
- captureRequestBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
- try {
- cameraCaptureSession.setRepeatingRequest(captureRequestBuilder.build(), null, null);
- } catch (CameraAccessException e) {
- LogUtil.e("CaptureSessionCallback.onConfigured", "failed to configure", e);
- }
- }
-
- @Override
- public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) {
- LogUtil.e("CaptureSessionCallback.onConfigureFailed", "failed to configure");
- }
- }
-}
diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml
index 042e7b82f..aa153dd4b 100644
--- a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml
+++ b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml
@@ -14,6 +14,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
+
<com.android.incallui.answer.impl.AffordanceHolderLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -26,20 +27,11 @@
android:keepScreenOn="true">
<TextureView
- android:id="@+id/incoming_preview_texture_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:importantForAccessibility="no"
- android:visibility="gone"/>
-
- <com.android.incallui.answer.impl.FixedAspectSurfaceView
- android:id="@+id/incoming_preview_surface_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:importantForAccessibility="no"
- android:visibility="gone"
- app:scaleWidth="@bool/scale_width"
- app:scaleHeight="@bool/scale_height"/>
+ android:id="@+id/incoming_preview_texture_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:importantForAccessibility="no"
+ android:visibility="gone"/>
<View
android:id="@+id/incoming_preview_texture_view_overlay"
diff --git a/java/com/android/incallui/answer/impl/res/values-land/dimens.xml b/java/com/android/incallui/answer/impl/res/values-land/dimens.xml
deleted file mode 100644
index 5e2a88ae9..000000000
--- a/java/com/android/incallui/answer/impl/res/values-land/dimens.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<resources>
- <bool name="scale_width">false</bool>
- <bool name="scale_height">true</bool>
-</resources>
diff --git a/java/com/android/incallui/answer/impl/res/values/attrs.xml b/java/com/android/incallui/answer/impl/res/values/attrs.xml
deleted file mode 100644
index 1086e1ca5..000000000
--- a/java/com/android/incallui/answer/impl/res/values/attrs.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <declare-styleable name="FixedAspectSurfaceView">
- <attr name="aspectRatio" format="float" />
- <attr name="scaleWidth" format="boolean"/>
- <attr name="scaleHeight" format="boolean"/>
- </declare-styleable>
-
- <item name="match_parent" type="dimen">-1</item>
- <item name="wrap_content" type="dimen">-2</item>
-</resources> \ No newline at end of file
diff --git a/java/com/android/incallui/answer/impl/res/values/dimens.xml b/java/com/android/incallui/answer/impl/res/values/dimens.xml
index 50aec0328..8329707a6 100644
--- a/java/com/android/incallui/answer/impl/res/values/dimens.xml
+++ b/java/com/android/incallui/answer/impl/res/values/dimens.xml
@@ -14,6 +14,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
+
<resources>
<dimen name="answer_contact_name_text_size">24sp</dimen>
<dimen name="answer_contact_name_min_size">24sp</dimen>
@@ -21,7 +22,5 @@
<dimen name="answer_avatar_size">0dp</dimen>
<dimen name="answer_importance_margin_bottom">0dp</dimen>
<bool name="answer_important_call_allowed">false</bool>
- <bool name="scale_width">true</bool>
- <bool name="scale_height">false</bool>
<integer name="answer_animate_entry_millis">1000</integer>
</resources>