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

Commit e49a7863 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8014310 from 3486eacd to sc-v2-release

Change-Id: I734f7483c2f01cd1597ea5bf26838920638f54df
parents d559279b 3486eacd
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Intent;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.PersistableBundle;
import android.os.PersistableBundle;
@@ -498,6 +499,28 @@ 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() {
    public static ActivityClient getInstance() {
        return sInstance.get();
        return sInstance.get();
    }
    }
+28 −11
Original line number Original line Diff line number Diff line
@@ -561,8 +561,8 @@ public final class ActivityThread extends ClientTransactionHandler
        private Configuration mPendingOverrideConfig;
        private Configuration mPendingOverrideConfig;
        // Used for consolidating configs before sending on to Activity.
        // Used for consolidating configs before sending on to Activity.
        private Configuration tmpConfig = new Configuration();
        private Configuration tmpConfig = new Configuration();
        // Callback used for updating activity override config.
        // Callback used for updating activity override config and camera compat control state.
        ViewRootImpl.ActivityConfigCallback configCallback;
        ViewRootImpl.ActivityConfigCallback activityConfigCallback;
        ActivityClientRecord nextIdle;
        ActivityClientRecord nextIdle;


        // Indicates whether this activity is currently the topmost resumed one in the system.
        // Indicates whether this activity is currently the topmost resumed one in the system.
@@ -660,13 +660,30 @@ public final class ActivityThread extends ClientTransactionHandler
            stopped = false;
            stopped = false;
            hideForNow = false;
            hideForNow = false;
            nextIdle = null;
            nextIdle = null;
            configCallback = (Configuration overrideConfig, int newDisplayId) -> {
            activityConfigCallback = new ViewRootImpl.ActivityConfigCallback() {
                @Override
                public void onConfigurationChanged(Configuration overrideConfig,
                        int newDisplayId) {
                    if (activity == null) {
                    if (activity == null) {
                        throw new IllegalStateException(
                        throw new IllegalStateException(
                                "Received config update for non-existing activity");
                                "Received config update for non-existing activity");
                    }
                    }
                activity.mMainThread.handleActivityConfigurationChanged(this, overrideConfig,
                    activity.mMainThread.handleActivityConfigurationChanged(
                        newDisplayId);
                            ActivityClientRecord.this, overrideConfig, newDisplayId);
                }

                @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);
                }

            };
            };
        }
        }


@@ -3657,7 +3674,7 @@ public final class ActivityThread extends ClientTransactionHandler
                activity.attach(appContext, this, getInstrumentation(), r.token,
                activity.attach(appContext, this, getInstrumentation(), r.token,
                        r.ident, app, r.intent, r.activityInfo, title, r.parent,
                        r.ident, app, r.intent, r.activityInfo, title, r.parent,
                        r.embeddedID, r.lastNonConfigurationInstances, config,
                        r.embeddedID, r.lastNonConfigurationInstances, config,
                        r.referrer, r.voiceInteractor, window, r.configCallback,
                        r.referrer, r.voiceInteractor, window, r.activityConfigCallback,
                        r.assistToken, r.shareableActivityToken);
                        r.assistToken, r.shareableActivityToken);


                if (customIntent != null) {
                if (customIntent != null) {
@@ -5500,8 +5517,8 @@ public final class ActivityThread extends ClientTransactionHandler
                } else {
                } else {
                    final ViewRootImpl viewRoot = v.getViewRootImpl();
                    final ViewRootImpl viewRoot = v.getViewRootImpl();
                    if (viewRoot != null) {
                    if (viewRoot != null) {
                        // Clear the callback to avoid the destroyed activity from receiving
                        // Clear callbacks to avoid the destroyed activity from receiving
                        // configuration changes that are no longer effective.
                        // configuration or camera compat changes that are no longer effective.
                        viewRoot.setActivityConfigCallback(null);
                        viewRoot.setActivityConfigCallback(null);
                    }
                    }
                    wm.removeViewImmediate(v);
                    wm.removeViewImmediate(v);
+12 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package android.app;
package android.app;


import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ICompatCameraControlCallback;
import android.app.IRequestFinishCallback;
import android.app.IRequestFinishCallback;
import android.app.PictureInPictureParams;
import android.app.PictureInPictureParams;
import android.content.ComponentName;
import android.content.ComponentName;
@@ -143,4 +144,15 @@ interface IActivityClientController {


    /** Reports that the splash screen view has attached to activity.  */
    /** Reports that the splash screen view has attached to activity.  */
    oneway void splashScreenAttached(in IBinder token);
    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);
}
}
+30 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2021 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 android.app;

/**
 * This callback allows ActivityRecord to ask the calling View to apply the treatment for stretched
 * issues affecting camera viewfinders when the user clicks on the camera compat control.
 *
 * {@hide}
 */
oneway interface ICompatCameraControlCallback {

    void applyCameraCompatTreatment();

    void revertCameraCompatTreatment();
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -1259,7 +1259,7 @@ public class Instrumentation {
                info, title, parent, id,
                info, title, parent, id,
                (Activity.NonConfigurationInstances)lastNonConfigurationInstance,
                (Activity.NonConfigurationInstances)lastNonConfigurationInstance,
                new Configuration(), null /* referrer */, null /* voiceInteractor */,
                new Configuration(), null /* referrer */, null /* voiceInteractor */,
                null /* window */, null /* activityConfigCallback */, null /*assistToken*/,
                null /* window */, null /* activityCallback */, null /*assistToken*/,
                null /*shareableActivityToken*/);
                null /*shareableActivityToken*/);
        return activity;
        return activity;
    }
    }
Loading