|
|
@ -17,6 +17,8 @@
|
|
|
|
package com.google.samples.apps.nowinandroid.ui
|
|
|
|
package com.google.samples.apps.nowinandroid.ui
|
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Bitmap
|
|
|
|
import android.graphics.Bitmap
|
|
|
|
|
|
|
|
import android.os.Build
|
|
|
|
|
|
|
|
import android.os.Build.VERSION_CODES
|
|
|
|
import android.util.Log
|
|
|
|
import android.util.Log
|
|
|
|
import androidx.core.view.WindowInsetsCompat
|
|
|
|
import androidx.core.view.WindowInsetsCompat
|
|
|
|
import androidx.test.core.app.takeScreenshot
|
|
|
|
import androidx.test.core.app.takeScreenshot
|
|
|
@ -92,11 +94,26 @@ class EdgeToEdgeTest {
|
|
|
|
fun enableDemoMode() {
|
|
|
|
fun enableDemoMode() {
|
|
|
|
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply {
|
|
|
|
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply {
|
|
|
|
executeShellCommand("settings put global sysui_demo_allowed 1")
|
|
|
|
executeShellCommand("settings put global sysui_demo_allowed 1")
|
|
|
|
executeShellCommand("am broadcast -a com.android.systemui.demo -e command enter")
|
|
|
|
executeShellCommand(
|
|
|
|
executeShellCommand("am broadcast -a com.android.systemui.demo -e command notifications -e visible false")
|
|
|
|
"am broadcast -a com.android.systemui.demo -e command " +
|
|
|
|
executeShellCommand("am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1234")
|
|
|
|
"enter",
|
|
|
|
executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e wifi hide")
|
|
|
|
)
|
|
|
|
executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e mobile hide")
|
|
|
|
executeShellCommand(
|
|
|
|
|
|
|
|
"am broadcast -a com.android.systemui.demo -e command " +
|
|
|
|
|
|
|
|
"notifications -e visible false",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
executeShellCommand(
|
|
|
|
|
|
|
|
"am broadcast -a com.android.systemui.demo -e command " +
|
|
|
|
|
|
|
|
"clock -e hhmm 1234",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
executeShellCommand(
|
|
|
|
|
|
|
|
"am broadcast -a com.android.systemui.demo -e command " +
|
|
|
|
|
|
|
|
"network -e wifi hide",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
executeShellCommand(
|
|
|
|
|
|
|
|
"am broadcast -a com.android.systemui.demo -e command " +
|
|
|
|
|
|
|
|
"network -e mobile hide",
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -154,15 +171,20 @@ class EdgeToEdgeTest {
|
|
|
|
var width: Int? = null
|
|
|
|
var width: Int? = null
|
|
|
|
waitForWindowUpdate()
|
|
|
|
waitForWindowUpdate()
|
|
|
|
activityScenarioRule.scenario.onActivity { activity ->
|
|
|
|
activityScenarioRule.scenario.onActivity { activity ->
|
|
|
|
|
|
|
|
|
|
|
|
val metrics = WindowMetricsCalculator.getOrCreate()
|
|
|
|
val metrics = WindowMetricsCalculator.getOrCreate()
|
|
|
|
.computeCurrentWindowMetrics(activity)
|
|
|
|
.computeMaximumWindowMetrics(activity)
|
|
|
|
topInset = metrics.getWindowInsets().getInsets(
|
|
|
|
// TODO: Get the real inset dimension in <R
|
|
|
|
WindowInsetsCompat.Type.systemBars(),
|
|
|
|
topInset = if (Build.VERSION.SDK_INT >= VERSION_CODES.R) {
|
|
|
|
).bottom
|
|
|
|
metrics.getWindowInsets().getInsets(
|
|
|
|
|
|
|
|
WindowInsetsCompat.Type.systemBars(),
|
|
|
|
|
|
|
|
).bottom
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
}
|
|
|
|
width = metrics.bounds.width()
|
|
|
|
width = metrics.bounds.width()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Log.d("jalc", "width: $width")
|
|
|
|
Log.d("EdgeToEdgeTests", "System bar inset height: $topInset")
|
|
|
|
Log.d("jalc", "topInset: $topInset")
|
|
|
|
|
|
|
|
// Crop the top, adding extra pixels to check continuity
|
|
|
|
// Crop the top, adding extra pixels to check continuity
|
|
|
|
val bitmap = takeScreenshot().let {
|
|
|
|
val bitmap = takeScreenshot().let {
|
|
|
|
Bitmap.createBitmap(it, 0, 0, width!!, (topInset!! * 2))
|
|
|
|
Bitmap.createBitmap(it, 0, 0, width!!, (topInset!! * 2))
|
|
|
@ -177,16 +199,20 @@ class EdgeToEdgeTest {
|
|
|
|
waitForWindowUpdate()
|
|
|
|
waitForWindowUpdate()
|
|
|
|
activityScenarioRule.scenario.onActivity { activity ->
|
|
|
|
activityScenarioRule.scenario.onActivity { activity ->
|
|
|
|
val metrics = WindowMetricsCalculator.getOrCreate()
|
|
|
|
val metrics = WindowMetricsCalculator.getOrCreate()
|
|
|
|
.computeCurrentWindowMetrics(activity)
|
|
|
|
.computeMaximumWindowMetrics(activity)
|
|
|
|
bottomInset = metrics.getWindowInsets().getInsets(
|
|
|
|
// TODO: Get the real inset dimension in <R
|
|
|
|
WindowInsetsCompat.Type.navigationBars(),
|
|
|
|
bottomInset = if (Build.VERSION.SDK_INT >= VERSION_CODES.R) {
|
|
|
|
).bottom
|
|
|
|
metrics.getWindowInsets().getInsets(
|
|
|
|
|
|
|
|
WindowInsetsCompat.Type.navigationBars(),
|
|
|
|
|
|
|
|
).bottom
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
width = metrics.bounds.width()
|
|
|
|
width = metrics.bounds.width()
|
|
|
|
height = metrics.bounds.height()
|
|
|
|
height = metrics.bounds.height()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Log.d("jalc", "height: $height")
|
|
|
|
Log.d("EdgeToEdgeTests", "Navigation bar inset height: $bottomInset")
|
|
|
|
Log.d("jalc", "bottomInset: $bottomInset")
|
|
|
|
|
|
|
|
// Crop the top, adding extra pixels to check continuity
|
|
|
|
// Crop the top, adding extra pixels to check continuity
|
|
|
|
val bitmap = takeScreenshot().let {
|
|
|
|
val bitmap = takeScreenshot().let {
|
|
|
|
Bitmap.createBitmap(it, 0, height!! - (bottomInset!! * 2), width!!, (bottomInset!! * 2))
|
|
|
|
Bitmap.createBitmap(it, 0, height!! - (bottomInset!! * 2), width!!, (bottomInset!! * 2))
|
|
|
|