Loading core/java/android/app/ActivityClient.java +23 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.content.ComponentName; import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.os.IBinder; import android.os.PersistableBundle; Loading Loading @@ -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() { return sInstance.get(); } Loading core/java/android/app/ActivityThread.java +28 −11 Original line number Diff line number Diff line Loading @@ -561,8 +561,8 @@ public final class ActivityThread extends ClientTransactionHandler private Configuration mPendingOverrideConfig; // Used for consolidating configs before sending on to Activity. private Configuration tmpConfig = new Configuration(); // Callback used for updating activity override config. ViewRootImpl.ActivityConfigCallback configCallback; // Callback used for updating activity override config and camera compat control state. ViewRootImpl.ActivityConfigCallback activityConfigCallback; ActivityClientRecord nextIdle; // Indicates whether this activity is currently the topmost resumed one in the system. Loading Loading @@ -660,13 +660,30 @@ public final class ActivityThread extends ClientTransactionHandler stopped = false; hideForNow = false; nextIdle = null; configCallback = (Configuration overrideConfig, int newDisplayId) -> { activityConfigCallback = new ViewRootImpl.ActivityConfigCallback() { @Override public void onConfigurationChanged(Configuration overrideConfig, int newDisplayId) { if (activity == null) { throw new IllegalStateException( "Received config update for non-existing activity"); } activity.mMainThread.handleActivityConfigurationChanged(this, overrideConfig, newDisplayId); activity.mMainThread.handleActivityConfigurationChanged( 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); } }; } Loading Loading @@ -3657,7 +3674,7 @@ public final class ActivityThread extends ClientTransactionHandler activity.attach(appContext, this, getInstrumentation(), r.token, r.ident, app, r.intent, r.activityInfo, title, r.parent, r.embeddedID, r.lastNonConfigurationInstances, config, r.referrer, r.voiceInteractor, window, r.configCallback, r.referrer, r.voiceInteractor, window, r.activityConfigCallback, r.assistToken, r.shareableActivityToken); if (customIntent != null) { Loading Loading @@ -5500,8 +5517,8 @@ public final class ActivityThread extends ClientTransactionHandler } else { final ViewRootImpl viewRoot = v.getViewRootImpl(); if (viewRoot != null) { // Clear the callback to avoid the destroyed activity from receiving // configuration changes that are no longer effective. // Clear callbacks to avoid the destroyed activity from receiving // configuration or camera compat changes that are no longer effective. viewRoot.setActivityConfigCallback(null); } wm.removeViewImmediate(v); Loading core/java/android/app/IActivityClientController.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; import android.app.ActivityManager; import android.app.ICompatCameraControlCallback; import android.app.IRequestFinishCallback; import android.app.PictureInPictureParams; import android.content.ComponentName; Loading Loading @@ -143,4 +144,15 @@ 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); } core/java/android/app/ICompatCameraControlCallback.aidl 0 → 100644 +30 −0 Original line number 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(); } core/java/android/app/Instrumentation.java +1 −1 Original line number Diff line number Diff line Loading @@ -1259,7 +1259,7 @@ public class Instrumentation { info, title, parent, id, (Activity.NonConfigurationInstances)lastNonConfigurationInstance, new Configuration(), null /* referrer */, null /* voiceInteractor */, null /* window */, null /* activityConfigCallback */, null /*assistToken*/, null /* window */, null /* activityCallback */, null /*assistToken*/, null /*shareableActivityToken*/); return activity; } Loading Loading
core/java/android/app/ActivityClient.java +23 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.content.ComponentName; import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.os.IBinder; import android.os.PersistableBundle; Loading Loading @@ -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() { return sInstance.get(); } Loading
core/java/android/app/ActivityThread.java +28 −11 Original line number Diff line number Diff line Loading @@ -561,8 +561,8 @@ public final class ActivityThread extends ClientTransactionHandler private Configuration mPendingOverrideConfig; // Used for consolidating configs before sending on to Activity. private Configuration tmpConfig = new Configuration(); // Callback used for updating activity override config. ViewRootImpl.ActivityConfigCallback configCallback; // Callback used for updating activity override config and camera compat control state. ViewRootImpl.ActivityConfigCallback activityConfigCallback; ActivityClientRecord nextIdle; // Indicates whether this activity is currently the topmost resumed one in the system. Loading Loading @@ -660,13 +660,30 @@ public final class ActivityThread extends ClientTransactionHandler stopped = false; hideForNow = false; nextIdle = null; configCallback = (Configuration overrideConfig, int newDisplayId) -> { activityConfigCallback = new ViewRootImpl.ActivityConfigCallback() { @Override public void onConfigurationChanged(Configuration overrideConfig, int newDisplayId) { if (activity == null) { throw new IllegalStateException( "Received config update for non-existing activity"); } activity.mMainThread.handleActivityConfigurationChanged(this, overrideConfig, newDisplayId); activity.mMainThread.handleActivityConfigurationChanged( 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); } }; } Loading Loading @@ -3657,7 +3674,7 @@ public final class ActivityThread extends ClientTransactionHandler activity.attach(appContext, this, getInstrumentation(), r.token, r.ident, app, r.intent, r.activityInfo, title, r.parent, r.embeddedID, r.lastNonConfigurationInstances, config, r.referrer, r.voiceInteractor, window, r.configCallback, r.referrer, r.voiceInteractor, window, r.activityConfigCallback, r.assistToken, r.shareableActivityToken); if (customIntent != null) { Loading Loading @@ -5500,8 +5517,8 @@ public final class ActivityThread extends ClientTransactionHandler } else { final ViewRootImpl viewRoot = v.getViewRootImpl(); if (viewRoot != null) { // Clear the callback to avoid the destroyed activity from receiving // configuration changes that are no longer effective. // Clear callbacks to avoid the destroyed activity from receiving // configuration or camera compat changes that are no longer effective. viewRoot.setActivityConfigCallback(null); } wm.removeViewImmediate(v); Loading
core/java/android/app/IActivityClientController.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; import android.app.ActivityManager; import android.app.ICompatCameraControlCallback; import android.app.IRequestFinishCallback; import android.app.PictureInPictureParams; import android.content.ComponentName; Loading Loading @@ -143,4 +144,15 @@ 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); }
core/java/android/app/ICompatCameraControlCallback.aidl 0 → 100644 +30 −0 Original line number 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(); }
core/java/android/app/Instrumentation.java +1 −1 Original line number Diff line number Diff line Loading @@ -1259,7 +1259,7 @@ public class Instrumentation { info, title, parent, id, (Activity.NonConfigurationInstances)lastNonConfigurationInstance, new Configuration(), null /* referrer */, null /* voiceInteractor */, null /* window */, null /* activityConfigCallback */, null /*assistToken*/, null /* window */, null /* activityCallback */, null /*assistToken*/, null /*shareableActivityToken*/); return activity; } Loading