Merge "Add vertical type check to prevent non-Automotive Androids from force displaying system bars." into qt-qpr1-dev am: 5a846ed237
Change-Id: Ib251aa6708e958e874a3bf5a5d888f738a5c42bb
This commit is contained in:
@@ -5702,6 +5702,12 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setForceShowSystemBars(boolean show) {
|
public void setForceShowSystemBars(boolean show) {
|
||||||
|
boolean isAutomotive = mContext.getPackageManager().hasSystemFeature(
|
||||||
|
PackageManager.FEATURE_AUTOMOTIVE);
|
||||||
|
if (!isAutomotive) {
|
||||||
|
throw new UnsupportedOperationException("Force showing system bars is only supported"
|
||||||
|
+ "for Automotive use cases.");
|
||||||
|
}
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR)
|
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
throw new SecurityException("Caller does not hold permission "
|
throw new SecurityException("Caller does not hold permission "
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||||
<uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
|
<uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
|
||||||
|
<uses-permission android:name="android.permission.STATUS_BAR" />
|
||||||
|
|
||||||
<!-- TODO: Remove largeHeap hack when memory leak is fixed (b/123984854) -->
|
<!-- TODO: Remove largeHeap hack when memory leak is fixed (b/123984854) -->
|
||||||
<application android:debuggable="true"
|
<application android:debuggable="true"
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 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.wm;
|
||||||
|
|
||||||
|
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||||
|
|
||||||
|
import static org.junit.Assume.assumeFalse;
|
||||||
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.platform.test.annotations.Presubmit;
|
||||||
|
|
||||||
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
@Presubmit
|
||||||
|
public class WindowManagerServiceTests extends WindowTestsBase {
|
||||||
|
@Rule
|
||||||
|
public ExpectedException mExpectedException = ExpectedException.none();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForceShowSystemBarsThrowsExceptionForNonAutomotive() {
|
||||||
|
assumeFalse(isAutomotive());
|
||||||
|
mExpectedException.expect(UnsupportedOperationException.class);
|
||||||
|
|
||||||
|
mWm.setForceShowSystemBars(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForceShowSystemBarsDoesNotThrowExceptionForAutomotiveWithStatusBarPermission() {
|
||||||
|
assumeTrue(isAutomotive());
|
||||||
|
mExpectedException.none();
|
||||||
|
|
||||||
|
mWm.setForceShowSystemBars(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isAutomotive() {
|
||||||
|
return getInstrumentation().getTargetContext().getPackageManager().hasSystemFeature(
|
||||||
|
PackageManager.FEATURE_AUTOMOTIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user