diff options
8 files changed, 162 insertions, 10 deletions
diff --git a/core/java/android/net/VpnManager.java b/core/java/android/net/VpnManager.java index 2e64a74a5d67..ff47f3fc30aa 100644 --- a/core/java/android/net/VpnManager.java +++ b/core/java/android/net/VpnManager.java @@ -444,7 +444,7 @@ public class VpnManager { * Retrieve the VpnProfileState for the profile provisioned by the calling package. * * @return the VpnProfileState with current information, or null if there was no profile - * provisioned by the calling package. + * provisioned and started by the calling package. */ @Nullable public VpnProfileState getProvisionedVpnProfileState() { diff --git a/core/java/android/window/TransitionInfo.java b/core/java/android/window/TransitionInfo.java index 8c05130bf5fe..a92ca8a4d3f2 100644 --- a/core/java/android/window/TransitionInfo.java +++ b/core/java/android/window/TransitionInfo.java @@ -424,8 +424,8 @@ public final class TransitionInfo implements Parcelable { case TRANSIT_NONE: return "NONE"; case TRANSIT_OPEN: return "OPEN"; case TRANSIT_CLOSE: return "CLOSE"; - case TRANSIT_TO_FRONT: return "SHOW"; - case TRANSIT_TO_BACK: return "HIDE"; + case TRANSIT_TO_FRONT: return "TO_FRONT"; + case TRANSIT_TO_BACK: return "TO_BACK"; case TRANSIT_CHANGE: return "CHANGE"; default: return "<unknown:" + mode + ">"; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java index ce8d792ef302..de20c2d90066 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java @@ -29,6 +29,7 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT; import static android.view.WindowManager.fixScale; import static android.window.TransitionInfo.FLAG_IS_OCCLUDED; import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; +import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP; import static android.window.TransitionInfo.FLAG_NO_ANIMATION; import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT; @@ -554,7 +555,10 @@ public class Transitions implements RemoteCallable<Transitions>, layer = -zSplitLine - i; } } else if (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT) { - if (isOpening) { + if (isOpening + // This is for when an activity launches while a different transition is + // collecting. + || change.hasFlags(FLAG_MOVED_TO_TOP)) { // put on top layer = zSplitLine + numChanges - i; } else { diff --git a/services/core/java/com/android/server/VpnManagerService.java b/services/core/java/com/android/server/VpnManagerService.java index 2b43ef48b922..9b4f9683d550 100644 --- a/services/core/java/com/android/server/VpnManagerService.java +++ b/services/core/java/com/android/server/VpnManagerService.java @@ -406,7 +406,7 @@ public class VpnManagerService extends IVpnManager.Stub { * Retrieve the VpnProfileState for the profile provisioned by the given package. * * @return the VpnProfileState with current information, or null if there was no profile - * provisioned by the given package. + * provisioned and started by the given package. * @hide */ @Override diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 8e102041636d..e85eee817d29 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -5012,7 +5012,7 @@ public class Vpn { * Retrieve the VpnProfileState for the profile provisioned by the given package. * * @return the VpnProfileState with current information, or null if there was no profile - * provisioned by the given package. + * provisioned and started by the given package. */ @Nullable public synchronized VpnProfileState getProvisionedVpnProfileState( diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index 2c54e1cea3fa..3eab4b0b1835 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -1579,6 +1579,10 @@ public class HdmiControlService extends SystemService { // If the device is not TV, we can't convert path to port-id, so stop here. return true; } + // Invalidate the physical address if parameters length is too short. + if (params.length < offset + 2) { + return false; + } int path = HdmiUtils.twoBytesToInt(params, offset); if (path != Constants.INVALID_PHYSICAL_ADDRESS && path == getPhysicalAddress()) { return true; diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index b7eaf259ea7a..1a322ff0196f 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -272,15 +272,17 @@ class InsetsSourceProvider { /** @return A new source computed by the specified window frame in the given display frames. */ InsetsSource createSimulatedSource(DisplayFrames displayFrames, Rect frame) { - // Don't copy visible frame because it might not be calculated in the provided display - // frames and it is not significant for this usage. - final InsetsSource source = new InsetsSource(mSource.getId(), mSource.getType()); - source.setVisible(mSource.isVisible()); + final InsetsSource source = new InsetsSource(mSource); mTmpRect.set(frame); if (mFrameProvider != null) { mFrameProvider.apply(displayFrames, mWindowContainer, mTmpRect); } source.setFrame(mTmpRect); + + // Don't copy visible frame because it might not be calculated in the provided display + // frames and it is not significant for this usage. + source.setVisibleFrame(null); + return source; } diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTvTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTvTest.java new file mode 100644 index 000000000000..920c376d5dfb --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTvTest.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2023 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.server.hdmi; + +import static com.android.server.SystemService.PHASE_SYSTEM_SERVICES_READY; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; +import android.hardware.hdmi.HdmiDeviceInfo; +import android.os.Looper; +import android.os.test.TestLooper; +import android.platform.test.annotations.Presubmit; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.util.Collections; + +/** + * TV specific tests for {@link HdmiControlService} class. + */ +@SmallTest +@Presubmit +@RunWith(JUnit4.class) +public class HdmiControlServiceTvTest { + + private static final String TAG = "HdmiControlServiceTvTest"; + private HdmiControlService mHdmiControlService; + private HdmiCecController mHdmiCecController; + private FakeNativeWrapper mNativeWrapper; + private HdmiEarcController mHdmiEarcController; + private FakeEarcNativeWrapper mEarcNativeWrapper; + private Looper mMyLooper; + private TestLooper mTestLooper = new TestLooper(); + + @Before + public void setUp() throws Exception { + Context context = InstrumentationRegistry.getTargetContext(); + mMyLooper = mTestLooper.getLooper(); + + FakeAudioFramework audioFramework = new FakeAudioFramework(); + + mHdmiControlService = + new HdmiControlService(InstrumentationRegistry.getTargetContext(), + Collections.singletonList(HdmiDeviceInfo.DEVICE_TV), + audioFramework.getAudioManager(), + audioFramework.getAudioDeviceVolumeManager()) { + @Override + int pathToPortId(int path) { + return Constants.INVALID_PORT_ID + 1; + } + }; + + mMyLooper = mTestLooper.getLooper(); + mHdmiControlService.setIoLooper(mMyLooper); + mHdmiControlService.setHdmiCecConfig(new FakeHdmiCecConfig(context)); + mHdmiControlService.setDeviceConfig(new FakeDeviceConfigWrapper()); + mHdmiControlService.onBootPhase(PHASE_SYSTEM_SERVICES_READY); + + mNativeWrapper = new FakeNativeWrapper(); + mHdmiCecController = HdmiCecController.createWithNativeWrapper( + mHdmiControlService, mNativeWrapper, mHdmiControlService.getAtomWriter()); + mHdmiControlService.setCecController(mHdmiCecController); + mEarcNativeWrapper = new FakeEarcNativeWrapper(); + mHdmiEarcController = HdmiEarcController.createWithNativeWrapper( + mHdmiControlService, mEarcNativeWrapper); + mHdmiControlService.setEarcController(mHdmiEarcController); + mHdmiControlService.setHdmiMhlController(HdmiMhlControllerStub.create( + mHdmiControlService)); + mHdmiControlService.initService(); + + mTestLooper.dispatchAll(); + } + + @Test + public void onCecMessage_shortPhysicalAddress_featureAbortInvalidOperand() { + // Invalid <Inactive Source> message. + HdmiCecMessage message = HdmiUtils.buildMessage("40:9D:14"); + + mNativeWrapper.onCecMessage(message); + mTestLooper.dispatchAll(); + + HdmiCecMessage featureAbort = HdmiCecMessageBuilder.buildFeatureAbortCommand( + Constants.ADDR_TV, Constants.ADDR_PLAYBACK_1, Constants.MESSAGE_INACTIVE_SOURCE, + Constants.ABORT_INVALID_OPERAND); + assertThat(mNativeWrapper.getResultMessages()).contains(featureAbort); + } + + @Test + public void handleCecCommand_shortPhysicalAddress_returnsAbortInvalidOperand() { + // Invalid <Active Source> message. + HdmiCecMessage message = HdmiUtils.buildMessage("4F:82:10"); + + // In case of a broadcasted message <Feature Abort> is not expected. + // See CEC 1.4b specification, 12.2 Protocol General Rules for detail. + assertThat(mHdmiControlService.handleCecCommand(message)) + .isEqualTo(Constants.ABORT_INVALID_OPERAND); + } + + @Test + public void test_verifyPhysicalAddresses() { + // <Routing Change> + assertThat(mHdmiControlService + .verifyPhysicalAddresses(HdmiUtils.buildMessage("0F:80:10:00:40:00"))).isTrue(); + assertThat(mHdmiControlService + .verifyPhysicalAddresses(HdmiUtils.buildMessage("0F:80:10:00:40"))).isFalse(); + assertThat(mHdmiControlService + .verifyPhysicalAddresses(HdmiUtils.buildMessage("0F:80:10"))).isFalse(); + + // <System Audio Mode Request> + assertThat(mHdmiControlService + .verifyPhysicalAddresses(HdmiUtils.buildMessage("40:70:00:00"))).isTrue(); + assertThat(mHdmiControlService + .verifyPhysicalAddresses(HdmiUtils.buildMessage("40:70:00"))).isFalse(); + + // <Active Source> + assertThat(mHdmiControlService + .verifyPhysicalAddresses(HdmiUtils.buildMessage("4F:82:10:00"))).isTrue(); + assertThat(mHdmiControlService + .verifyPhysicalAddresses(HdmiUtils.buildMessage("4F:82:10"))).isFalse(); + } +} |