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

Commit 9837e28c authored by Mina Granic's avatar Mina Granic
Browse files

Remove unused Camera Compat approach.

This approach was abandoned in favor of force rotate and letterbox.

Flag: NONE removing dead code
Bug: 352486201
Test: build and presubmit
Change-Id: I01ac1aa26e5e7054c7f1927d2dae41e55e2bd883
parent 2c4b5b9c
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.ComponentName;
import android.content.ContentProvider;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
@@ -660,28 +659,6 @@ public class ActivityClient {
        }
    }

    /**
     * Shows or hides a Camera app compat toggle for stretched issues with the requested state.
     *
     * @param token The token for the window that needs a control.
     * @param showControl Whether the control should be shown or hidden.
     * @param transformationApplied Whether the treatment is already applied.
     * @param callback The callback executed when the user clicks on a control.
     */
    void requestCompatCameraControl(Resources res, IBinder token, boolean showControl,
            boolean transformationApplied, ICompatCameraControlCallback callback) {
        if (!res.getBoolean(com.android.internal.R.bool
                .config_isCameraCompatControlForStretchedIssuesEnabled)) {
            return;
        }
        try {
            getActivityClientController().requestCompatCameraControl(
                    token, showControl, transformationApplied, callback);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    public static ActivityClient getInstance() {
        return sInstance.get();
    }
+0 −13
Original line number Diff line number Diff line
@@ -734,19 +734,6 @@ public final class ActivityThread extends ClientTransactionHandler
                            activityWindowInfo,
                            false /* alwaysReportChange */);
                }

                @Override
                public void requestCompatCameraControl(boolean showControl,
                        boolean transformationApplied, ICompatCameraControlCallback callback) {
                    if (activity == null) {
                        throw new IllegalStateException(
                                "Received camera compat control update for non-existing activity");
                    }
                    ActivityClient.getInstance().requestCompatCameraControl(
                            activity.getResources(), token, showControl, transformationApplied,
                            callback);
                }

            };
        }

+1 −2
Original line number Diff line number Diff line
@@ -136,8 +136,7 @@ public class AppCompatTaskInfo implements Parcelable {
     * @return {@value true} if the task has some compat ui.
     */
    public boolean hasCompatUI() {
        return cameraCompatTaskInfo.hasCameraCompatUI() || topActivityInSizeCompat
                || topActivityEligibleForLetterboxEducation
        return topActivityInSizeCompat || topActivityEligibleForLetterboxEducation
                || isLetterboxDoubleTapEnabled
                || topActivityEligibleForUserAspectRatioButton;
    }
+2 −75
Original line number Diff line number Diff line
@@ -30,45 +30,6 @@ import java.lang.annotation.RetentionPolicy;
 * @hide
 */
public class CameraCompatTaskInfo implements Parcelable {
    /**
     * Camera compat control isn't shown because it's not requested by heuristics.
     */
    public static final int CAMERA_COMPAT_CONTROL_HIDDEN = 0;

    /**
     * Camera compat control is shown with the treatment suggested.
     */
    public static final int CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED = 1;

    /**
     * Camera compat control is shown to allow reverting the applied treatment.
     */
    public static final int CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED = 2;

    /**
     * Camera compat control is dismissed by user.
     */
    public static final int CAMERA_COMPAT_CONTROL_DISMISSED = 3;

    /**
     * Enum for the Camera app compat control states.
     */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = { "CAMERA_COMPAT_CONTROL_" }, value = {
            CAMERA_COMPAT_CONTROL_HIDDEN,
            CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED,
            CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED,
            CAMERA_COMPAT_CONTROL_DISMISSED,
    })
    public @interface CameraCompatControlState {}

    /**
     * State of the Camera app compat control which is used to correct stretched viewfinder
     * in apps that don't handle all possible configurations and changes between them correctly.
     */
    @CameraCompatControlState
    public int cameraCompatControlState = CAMERA_COMPAT_CONTROL_HIDDEN;

    /**
     * The value to use when no camera compat treatment should be applied to a windowed task.
     */
@@ -137,7 +98,6 @@ public class CameraCompatTaskInfo implements Parcelable {
     * Reads the CameraCompatTaskInfo from a parcel.
     */
    void readFromParcel(Parcel source) {
        cameraCompatControlState = source.readInt();
        freeformCameraCompatMode = source.readInt();
    }

@@ -146,25 +106,9 @@ public class CameraCompatTaskInfo implements Parcelable {
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(cameraCompatControlState);
        dest.writeInt(freeformCameraCompatMode);
    }

    /**
     * @return {@value true} if the task has camera compat controls.
     */
    public boolean hasCameraCompatControl() {
        return cameraCompatControlState != CAMERA_COMPAT_CONTROL_HIDDEN
                && cameraCompatControlState != CAMERA_COMPAT_CONTROL_DISMISSED;
    }

    /**
     * @return {@value true} if the task has some compat ui.
     */
    public boolean hasCameraCompatUI() {
        return hasCameraCompatControl();
    }

    /**
     * @return  {@code true} if the camera compat parameters that are important for task organizers
     * are equal.
@@ -183,33 +127,16 @@ public class CameraCompatTaskInfo implements Parcelable {
        if (that == null) {
            return false;
        }
        return cameraCompatControlState == that.cameraCompatControlState
                && freeformCameraCompatMode == that.freeformCameraCompatMode;
        return freeformCameraCompatMode == that.freeformCameraCompatMode;
    }

    @Override
    public String toString() {
        return "CameraCompatTaskInfo { cameraCompatControlState="
                + cameraCompatControlStateToString(cameraCompatControlState)
                + " freeformCameraCompatMode="
        return "CameraCompatTaskInfo { freeformCameraCompatMode="
                + freeformCameraCompatModeToString(freeformCameraCompatMode)
                + "}";
    }

    /** Human readable version of the camera control state. */
    @NonNull
    public static String cameraCompatControlStateToString(
            @CameraCompatControlState int cameraCompatControlState) {
        return switch (cameraCompatControlState) {
            case CAMERA_COMPAT_CONTROL_HIDDEN -> "hidden";
            case CAMERA_COMPAT_CONTROL_TREATMENT_SUGGESTED -> "treatment-suggested";
            case CAMERA_COMPAT_CONTROL_TREATMENT_APPLIED -> "treatment-applied";
            case CAMERA_COMPAT_CONTROL_DISMISSED -> "dismissed";
            default -> throw new AssertionError(
                    "Unexpected camera compat control state: " + cameraCompatControlState);
        };
    }

    /** Human readable version of the freeform camera compat mode. */
    @NonNull
    public static String freeformCameraCompatModeToString(
+0 −12
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.app;

import android.app.ActivityManager;
import android.app.ICompatCameraControlCallback;
import android.app.IRequestFinishCallback;
import android.app.PictureInPictureParams;
import android.content.ComponentName;
@@ -171,17 +170,6 @@ interface IActivityClientController {
    /** Reports that the splash screen view has attached to activity.  */
    oneway void splashScreenAttached(in IBinder token);

    /**
     * Shows or hides a Camera app compat toggle for stretched issues with the requested state.
     *
     * @param token The token for the window that needs a control.
     * @param showControl Whether the control should be shown or hidden.
     * @param transformationApplied Whether the treatment is already applied.
     * @param callback The callback executed when the user clicks on a control.
     */
    oneway void requestCompatCameraControl(in IBinder token, boolean showControl,
            boolean transformationApplied, in ICompatCameraControlCallback callback);

    /**
     * If set, any activity launch in the same task will be overridden to the locale of activity
     * that started the task.
Loading