Merge "Add non-system overlay flag for usb perm dialog" into sc-v2-dev
This commit is contained in:
@@ -36,6 +36,7 @@ import android.os.UserHandle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -63,6 +64,8 @@ public class UsbPermissionActivity extends AlertActivity
|
|||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
getWindow().addPrivateFlags(
|
||||||
|
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
mDevice = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
mDevice = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||||
mAccessory = (UsbAccessory)intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
|
mAccessory = (UsbAccessory)intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
|
||||||
|
|||||||
@@ -93,6 +93,13 @@
|
|||||||
<activity android:name="com.android.systemui.screenshot.RecyclerViewActivity"
|
<activity android:name="com.android.systemui.screenshot.RecyclerViewActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
|
<!-- started from UsbDeviceSettingsManager -->
|
||||||
|
<activity android:name=".usb.UsbPermissionActivityTest$UsbPermissionActivityTestable"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.SystemUI.Dialog.Alert"
|
||||||
|
android:finishOnCloseSystemDialogs="true"
|
||||||
|
android:excludeFromRecents="true" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer"
|
android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer"
|
||||||
tools:replace="android:authorities"
|
tools:replace="android:authorities"
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.android.systemui.usb
|
||||||
|
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.Intent
|
||||||
|
import android.hardware.usb.IUsbSerialReader
|
||||||
|
import android.hardware.usb.UsbAccessory
|
||||||
|
import android.hardware.usb.UsbManager
|
||||||
|
import android.testing.AndroidTestingRunner
|
||||||
|
import android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS
|
||||||
|
import androidx.test.filters.SmallTest
|
||||||
|
import androidx.test.rule.ActivityTestRule
|
||||||
|
import com.android.systemui.SysuiTestCase
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import java.lang.Exception
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UsbPermissionActivityTest
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidTestingRunner::class)
|
||||||
|
@SmallTest
|
||||||
|
class UsbPermissionActivityTest : SysuiTestCase() {
|
||||||
|
|
||||||
|
class UsbPermissionActivityTestable : UsbPermissionActivity()
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
@JvmField
|
||||||
|
var activityRule = ActivityTestRule<UsbPermissionActivityTestable>(
|
||||||
|
UsbPermissionActivityTestable::class.java, false, false)
|
||||||
|
|
||||||
|
private val activityIntent = Intent(mContext, UsbPermissionActivityTestable::class.java)
|
||||||
|
.apply {
|
||||||
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
putExtra(UsbManager.EXTRA_PACKAGE, "com.android.systemui")
|
||||||
|
putExtra(Intent.EXTRA_INTENT, PendingIntent.getBroadcast(
|
||||||
|
mContext,
|
||||||
|
334,
|
||||||
|
Intent("NO_ACTION"),
|
||||||
|
PendingIntent.FLAG_MUTABLE))
|
||||||
|
putExtra(UsbManager.EXTRA_ACCESSORY, UsbAccessory(
|
||||||
|
"manufacturer",
|
||||||
|
"model",
|
||||||
|
"description",
|
||||||
|
"version",
|
||||||
|
"uri",
|
||||||
|
object : IUsbSerialReader.Stub() {
|
||||||
|
override fun getSerial(packageName: String): String {
|
||||||
|
return "serial"
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
activityRule.launchActivity(activityIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun tearDown() {
|
||||||
|
activityRule.finishActivity()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testHideNonSystemOverlay() {
|
||||||
|
assertThat(activityRule.activity.window.attributes.privateFlags and
|
||||||
|
SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
|
||||||
|
.isEqualTo(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user