Merge "Bump the Material3 library versions." into androidx-main
diff --git a/benchmark/benchmark-common/api/current.txt b/benchmark/benchmark-common/api/current.txt
index f6a0775..9df6fae 100644
--- a/benchmark/benchmark-common/api/current.txt
+++ b/benchmark/benchmark-common/api/current.txt
@@ -67,8 +67,8 @@
public static final class ProfilerConfig.MethodTracing extends androidx.benchmark.ProfilerConfig {
ctor public ProfilerConfig.MethodTracing();
+ field public static final boolean AFFECTS_MEASUREMENTS_ON_THIS_DEVICE;
field public static final androidx.benchmark.ProfilerConfig.MethodTracing.Companion Companion;
- field public static final boolean affectsMeasurementOnThisDevice;
}
public static final class ProfilerConfig.MethodTracing.Companion {
diff --git a/benchmark/benchmark-common/api/restricted_current.txt b/benchmark/benchmark-common/api/restricted_current.txt
index 21fd82e..e2bfb40 100644
--- a/benchmark/benchmark-common/api/restricted_current.txt
+++ b/benchmark/benchmark-common/api/restricted_current.txt
@@ -69,8 +69,8 @@
public static final class ProfilerConfig.MethodTracing extends androidx.benchmark.ProfilerConfig {
ctor public ProfilerConfig.MethodTracing();
+ field public static final boolean AFFECTS_MEASUREMENTS_ON_THIS_DEVICE;
field public static final androidx.benchmark.ProfilerConfig.MethodTracing.Companion Companion;
- field public static final boolean affectsMeasurementOnThisDevice;
}
public static final class ProfilerConfig.MethodTracing.Companion {
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/ProfilerConfig.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/ProfilerConfig.kt
index b7e560c..10e79f3 100644
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/ProfilerConfig.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/ProfilerConfig.kt
@@ -61,7 +61,7 @@
*/
@Suppress("GetterSetterNames")
@JvmField
- val affectsMeasurementOnThisDevice: Boolean =
+ val AFFECTS_MEASUREMENTS_ON_THIS_DEVICE: Boolean =
DeviceInfo.methodTracingAffectsMeasurements
}
}
diff --git a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SampleCustomBenchmark.kt b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SampleCustomBenchmark.kt
index 49e8f51..0021009 100644
--- a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SampleCustomBenchmark.kt
+++ b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SampleCustomBenchmark.kt
@@ -82,7 +82,7 @@
)
@Test
fun sample() {
- assumeFalse(ProfilerConfig.MethodTracing.affectsMeasurementOnThisDevice)
+ assumeFalse(ProfilerConfig.MethodTracing.AFFECTS_MEASUREMENTS_ON_THIS_DEVICE)
benchmarkRule.measureRepeated {
repeat(20) {
counter++
diff --git a/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/impl/State3AControl.kt b/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/impl/State3AControl.kt
index 7bb63fa..4edbea2 100644
--- a/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/impl/State3AControl.kt
+++ b/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/impl/State3AControl.kt
@@ -71,6 +71,7 @@
}
private val lock = Any()
+ private val invalidateLock = Any()
@GuardedBy("lock")
private val updateSignals = mutableSetOf<CompletableDeferred<Unit>>()
@@ -98,6 +99,12 @@
private fun <T> updateOnPropertyChange(
initialValue: T
) = object : ObservableProperty<T>(initialValue) {
+ override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
+ synchronized(invalidateLock) {
+ super.setValue(thisRef, property, value)
+ }
+ }
+
override fun afterChange(property: KProperty<*>, oldValue: T, newValue: T) {
if (newValue != oldValue) {
invalidate()
@@ -133,28 +140,30 @@
fun invalidate() {
// TODO(b/276779600): Refactor and move the setting of these parameter to
// CameraGraph.Config(requiredParameters = mapOf(....)).
- val preferAeMode = getFinalPreferredAeMode()
- val preferAfMode = preferredFocusMode ?: getDefaultAfMode()
+ synchronized(invalidateLock) {
+ val preferAeMode = getFinalPreferredAeMode()
+ val preferAfMode = preferredFocusMode ?: getDefaultAfMode()
- val parameters: MutableMap<CaptureRequest.Key<*>, Any> = mutableMapOf(
- CaptureRequest.CONTROL_AE_MODE to cameraProperties.metadata.getSupportedAeMode(
- preferAeMode
- ),
- CaptureRequest.CONTROL_AF_MODE to cameraProperties.metadata.getSupportedAfMode(
- preferAfMode
- ),
- CaptureRequest.CONTROL_AWB_MODE to cameraProperties.metadata.getSupportedAwbMode(
- CaptureRequest.CONTROL_AWB_MODE_AUTO
+ val parameters: MutableMap<CaptureRequest.Key<*>, Any> = mutableMapOf(
+ CaptureRequest.CONTROL_AE_MODE to cameraProperties.metadata.getSupportedAeMode(
+ preferAeMode
+ ),
+ CaptureRequest.CONTROL_AF_MODE to cameraProperties.metadata.getSupportedAfMode(
+ preferAfMode
+ ),
+ CaptureRequest.CONTROL_AWB_MODE to cameraProperties.metadata.getSupportedAwbMode(
+ CaptureRequest.CONTROL_AWB_MODE_AUTO
+ )
)
- )
- preferredAeFpsRange?.let {
- parameters[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = it
- }
+ preferredAeFpsRange?.let {
+ parameters[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = it
+ }
- useCaseCamera?.requestControl?.addParametersAsync(
- values = parameters
- )?.apply {
+ useCaseCamera?.requestControl?.addParametersAsync(
+ values = parameters
+ )
+ }?.apply {
toCompletableDeferred().also { signal ->
synchronized(lock) {
updateSignals.add(signal)
diff --git a/compose/material/material/integration-tests/material-catalog/src/main/java/androidx/compose/material/catalog/library/ui/common/CatalogTopAppBar.kt b/compose/material/material/integration-tests/material-catalog/src/main/java/androidx/compose/material/catalog/library/ui/common/CatalogTopAppBar.kt
index 25a42bb..963b6ee 100644
--- a/compose/material/material/integration-tests/material-catalog/src/main/java/androidx/compose/material/catalog/library/ui/common/CatalogTopAppBar.kt
+++ b/compose/material/material/integration-tests/material-catalog/src/main/java/androidx/compose/material/catalog/library/ui/common/CatalogTopAppBar.kt
@@ -29,6 +29,7 @@
import androidx.compose.material.catalog.library.R
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
+import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -73,7 +74,7 @@
}
IconButton(onClick = { moreMenuExpanded = true }) {
Icon(
- imageVector = Icons.AutoMirrored.Default.ArrowBack,
+ imageVector = Icons.Default.MoreVert,
contentDescription = null
)
}
diff --git a/compose/material3/material3/samples/src/main/java/androidx/compose/material3/samples/DrawerSamples.kt b/compose/material3/material3/samples/src/main/java/androidx/compose/material3/samples/DrawerSamples.kt
index 6d07a51..8d8df43 100644
--- a/compose/material3/material3/samples/src/main/java/androidx/compose/material3/samples/DrawerSamples.kt
+++ b/compose/material3/material3/samples/src/main/java/androidx/compose/material3/samples/DrawerSamples.kt
@@ -104,7 +104,7 @@
items.forEach { item ->
NavigationDrawerItem(
icon = { Icon(item, contentDescription = null) },
- label = { Text(item.name) },
+ label = { Text(item.name.substringAfterLast(".")) },
selected = item == selectedItem.value,
onClick = {
scope.launch { drawerState.close() }
@@ -167,7 +167,7 @@
items.forEach { item ->
NavigationDrawerItem(
icon = { Icon(item, contentDescription = null) },
- label = { Text(item.name) },
+ label = { Text(item.name.substringAfterLast(".")) },
selected = item == selectedItem.value,
onClick = {
selectedItem.value = item
@@ -229,7 +229,7 @@
items.forEach { item ->
NavigationDrawerItem(
icon = { Icon(item, contentDescription = null) },
- label = { Text(item.name) },
+ label = { Text(item.name.substringAfterLast(".")) },
selected = item == selectedItem.value,
onClick = {
scope.launch { drawerState.close() }
diff --git a/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/NavigationDrawerItemTest.kt b/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/NavigationDrawerItemTest.kt
index 3ecd26f..af1eb3a 100644
--- a/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/NavigationDrawerItemTest.kt
+++ b/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/NavigationDrawerItemTest.kt
@@ -29,18 +29,20 @@
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertHasClickAction
-import androidx.compose.ui.test.assertHeightIsAtLeast
+import androidx.compose.ui.test.assertHeightIsEqualTo
import androidx.compose.ui.test.assertIsEqualTo
import androidx.compose.ui.test.assertIsNotSelected
import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.compose.ui.test.assertWidthIsEqualTo
import androidx.compose.ui.test.getBoundsInRoot
+import androidx.compose.ui.test.getUnclippedBoundsInRoot
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.height
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.google.common.truth.Truth.assertThat
@@ -50,7 +52,6 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
-@OptIn(ExperimentalMaterial3Api::class)
class NavigationDrawerItemTest {
@get:Rule
@@ -74,7 +75,27 @@
rule.onNodeWithTag(DrawerItemTag)
.assertWidthIsEqualTo(264.dp)
- .assertHeightIsAtLeast(NavigationDrawerTokens.ActiveIndicatorHeight)
+ .assertHeightIsEqualTo(NavigationDrawerTokens.ActiveIndicatorHeight)
+ }
+
+ @Test
+ fun navigationDrawerItem_size_withLargeContent() {
+ rule.setMaterialContent(lightColorScheme()) {
+ Column(Modifier.width(264.dp)) {
+ NavigationDrawerItem(
+ icon = {},
+ label = { Text("Multi \nline \nlabel \nis \ntall") },
+ selected = true,
+ onClick = {},
+ modifier = Modifier.testTag(DrawerItemTag)
+ )
+ }
+ }
+
+ rule.onNodeWithTag(DrawerItemTag).assertWidthIsEqualTo(264.dp)
+ rule.onNodeWithTag(DrawerItemTag).getUnclippedBoundsInRoot().let {
+ assertThat(it.height).isGreaterThan(NavigationDrawerTokens.ActiveIndicatorHeight)
+ }
}
@Test
diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationDrawer.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationDrawer.kt
index 88d5dd4..46dba83 100644
--- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationDrawer.kt
+++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationDrawer.kt
@@ -35,7 +35,7 @@
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
@@ -951,7 +951,7 @@
onClick = onClick,
modifier = modifier
.semantics { role = Role.Tab }
- .height(NavigationDrawerTokens.ActiveIndicatorHeight)
+ .heightIn(min = NavigationDrawerTokens.ActiveIndicatorHeight)
.fillMaxWidth(),
shape = shape,
color = colors.containerColor(selected).value,
diff --git a/docs-public/build.gradle b/docs-public/build.gradle
index d6775c43..48d6a4b 100644
--- a/docs-public/build.gradle
+++ b/docs-public/build.gradle
@@ -349,25 +349,25 @@
docs("androidx.startup:startup-runtime:1.2.0-alpha02")
docs("androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01")
// androidx.test is not hosted in androidx
- docsWithoutApiSince("androidx.test:core:1.6.0-alpha06")
- docsWithoutApiSince("androidx.test:core-ktx:1.6.0-alpha06")
- docsWithoutApiSince("androidx.test:monitor:1.7.0-alpha05")
- docsWithoutApiSince("androidx.test:rules:1.6.0-alpha04")
- docsWithoutApiSince("androidx.test:runner:1.6.0-alpha07")
- docsWithoutApiSince("androidx.test.espresso:espresso-accessibility:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso:espresso-contrib:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso:espresso-core:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso:espresso-device:1.0.0-alpha09")
- docsWithoutApiSince("androidx.test.espresso:espresso-idling-resource:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso:espresso-intents:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso:espresso-remote:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso:espresso-web:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso.idling:idling-concurrent:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.espresso.idling:idling-net:3.6.0-alpha04")
- docsWithoutApiSince("androidx.test.ext:junit:1.2.0-alpha04")
- docsWithoutApiSince("androidx.test.ext:junit-ktx:1.2.0-alpha04")
- docsWithoutApiSince("androidx.test.ext:truth:1.6.0-alpha04")
- docsWithoutApiSince("androidx.test.services:storage:1.5.0-alpha04")
+ docsWithoutApiSince("androidx.test:core:1.6.0-beta01")
+ docsWithoutApiSince("androidx.test:core-ktx:1.6.0-beta01")
+ docsWithoutApiSince("androidx.test:monitor:1.7.0-beta01")
+ docsWithoutApiSince("androidx.test:rules:1.6.0-beta01")
+ docsWithoutApiSince("androidx.test:runner:1.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-accessibility:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-contrib:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-core:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-device:1.0.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-idling-resource:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-intents:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-remote:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso:espresso-web:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso.idling:idling-concurrent:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.espresso.idling:idling-net:3.6.0-beta01")
+ docsWithoutApiSince("androidx.test.ext:junit:1.2.0-beta01")
+ docsWithoutApiSince("androidx.test.ext:junit-ktx:1.2.0-beta01")
+ docsWithoutApiSince("androidx.test.ext:truth:1.6.0-beta01")
+ docsWithoutApiSince("androidx.test.services:storage:1.5.0-beta01")
docsWithoutApiSince("androidx.test.uiautomator:uiautomator:2.3.0")
// androidx.textclassifier is not hosted in androidx
docsWithoutApiSince("androidx.textclassifier:textclassifier:1.0.0-alpha04")
diff --git a/docs/open_source.md b/docs/open_source.md
index 29b4f7e..90bbf19 100644
--- a/docs/open_source.md
+++ b/docs/open_source.md
@@ -28,9 +28,15 @@
#### Closed-source dependencies
-In specific cases, libraries *may* include closed-source dependencies. See the
+In specific cases, libraries *may* include closed-source dependencies; however,
+we **strongly recommend** that closed-source dependencies like Play Services be
+paired with an open-source alternative provided directly in Jetpack, in the
+Android SDK, or as part of a Mainline module.
+
+See the
[Open-source compatibility](/docs/api_guidelines/index.md#dependencies-aosp)
-section of the API Guidelines for implementation details.
+section of the API Guidelines for details on integrating closed-source
+components.
### Examples of products that are _not_ open-source
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 0fe391a..60fc80d 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -14,12 +14,12 @@
androidGradlePluginMin = "7.0.4"
androidLintMin = "30.0.4"
androidLintMinCompose = "30.0.0"
-androidxTestRunner = "1.6.0-alpha07"
-androidxTestRules = "1.6.0-alpha04"
-androidxTestMonitor = "1.7.0-alpha05"
-androidxTestCore = "1.6.0-alpha06"
-androidxTestExtJunit = "1.2.0-alpha04"
-androidxTestExtTruth = "1.6.0-alpha04"
+androidxTestRunner = "1.6.0-beta01"
+androidxTestRules = "1.6.0-beta01"
+androidxTestMonitor = "1.7.0-beta01"
+androidxTestCore = "1.6.0-beta01"
+androidxTestExtJunit = "1.2.0-beta01"
+androidxTestExtTruth = "1.6.0-beta01"
annotationVersion = "1.7.0"
atomicFu = "0.17.0"
autoService = "1.0-rc6"
@@ -32,8 +32,8 @@
dagger = "2.49"
dexmaker = "2.28.3"
dokka = "1.8.20-dev-214"
-espresso = "3.6.0-alpha04"
-espressoDevice = "1.0.0-alpha09"
+espresso = "3.6.0-beta01"
+espressoDevice = "1.0.0-beta01"
grpc = "1.52.0"
guavaJre = "31.1-jre"
hilt = "2.49"
diff --git a/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImplTest.kt b/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImplTest.kt
index 63bbd51..6cc0ff1 100644
--- a/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImplTest.kt
+++ b/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImplTest.kt
@@ -24,6 +24,7 @@
import androidx.health.connect.client.HealthConnectClient
import androidx.health.connect.client.changes.DeletionChange
import androidx.health.connect.client.changes.UpsertionChange
+import androidx.health.connect.client.impl.converters.datatype.RECORDS_CLASS_NAME_MAP
import androidx.health.connect.client.permission.HealthPermission.Companion.PERMISSION_PREFIX
import androidx.health.connect.client.readRecord
import androidx.health.connect.client.records.BloodPressureRecord
@@ -103,9 +104,9 @@
@After
fun tearDown() = runTest {
- healthConnectClient.deleteRecords(StepsRecord::class, TimeRangeFilter.none())
- healthConnectClient.deleteRecords(HeartRateRecord::class, TimeRangeFilter.none())
- healthConnectClient.deleteRecords(NutritionRecord::class, TimeRangeFilter.none())
+ for (recordType in RECORDS_CLASS_NAME_MAP.keys) {
+ healthConnectClient.deleteRecords(recordType, TimeRangeFilter.none())
+ }
}
@Test
diff --git a/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/platform/aggregate/HealthConnectClientAggregationExtensionsTest.kt b/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/platform/aggregate/HealthConnectClientAggregationExtensionsTest.kt
index 76952af..8ddc8bf 100644
--- a/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/platform/aggregate/HealthConnectClientAggregationExtensionsTest.kt
+++ b/health/connect/connect-client/src/androidTest/java/androidx/health/connect/client/impl/platform/aggregate/HealthConnectClientAggregationExtensionsTest.kt
@@ -18,11 +18,13 @@
import android.annotation.TargetApi
import android.content.Context
+import android.content.pm.PackageManager
import android.os.Build
import android.os.ext.SdkExtensions
import androidx.health.connect.client.HealthConnectClient
import androidx.health.connect.client.impl.HealthConnectClientUpsideDownImpl
-import androidx.health.connect.client.permission.HealthPermission
+import androidx.health.connect.client.impl.converters.datatype.RECORDS_CLASS_NAME_MAP
+import androidx.health.connect.client.permission.HealthPermission.Companion.PERMISSION_PREFIX
import androidx.health.connect.client.records.BloodPressureRecord
import androidx.health.connect.client.records.NutritionRecord
import androidx.health.connect.client.records.StepsRecord
@@ -65,20 +67,24 @@
LocalDate.now().minusDays(5).atStartOfDay().toInstant(ZoneOffset.UTC)
}
+ private val allHealthPermissions =
+ context.packageManager
+ .getPackageInfo(
+ context.packageName,
+ PackageManager.PackageInfoFlags.of(PackageManager.GET_PERMISSIONS.toLong())
+ )
+ .requestedPermissions
+ .filter { it.startsWith(PERMISSION_PREFIX) }
+ .toTypedArray()
+
@get:Rule
- val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
- HealthPermission.getWritePermission(BloodPressureRecord::class),
- HealthPermission.getReadPermission(BloodPressureRecord::class),
- HealthPermission.getWritePermission(NutritionRecord::class),
- HealthPermission.getReadPermission(NutritionRecord::class),
- HealthPermission.getWritePermission(StepsRecord::class),
- HealthPermission.getReadPermission(StepsRecord::class)
- )
+ val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(*allHealthPermissions)
@After
fun tearDown() = runTest {
- healthConnectClient.deleteRecords(NutritionRecord::class, TimeRangeFilter.none())
- healthConnectClient.deleteRecords(StepsRecord::class, TimeRangeFilter.none())
+ for (recordType in RECORDS_CLASS_NAME_MAP.keys) {
+ healthConnectClient.deleteRecords(recordType, TimeRangeFilter.none())
+ }
}
@Test
diff --git a/wear/compose/compose-material3/benchmark/src/androidTest/java/androidx/wear/compose/material3/benchmark/IconBenchmark.kt b/wear/compose/compose-material3/benchmark/src/androidTest/java/androidx/wear/compose/material3/benchmark/IconBenchmark.kt
new file mode 100644
index 0000000..12f524f
--- /dev/null
+++ b/wear/compose/compose-material3/benchmark/src/androidTest/java/androidx/wear/compose/material3/benchmark/IconBenchmark.kt
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2024 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 androidx.wear.compose.material3.benchmark
+
+import androidx.compose.runtime.Composable
+import androidx.compose.testutils.LayeredComposeTestCase
+import androidx.compose.testutils.benchmark.ComposeBenchmarkRule
+import androidx.compose.testutils.benchmark.benchmarkDrawPerf
+import androidx.compose.testutils.benchmark.benchmarkFirstCompose
+import androidx.compose.testutils.benchmark.benchmarkFirstDraw
+import androidx.compose.testutils.benchmark.benchmarkFirstLayout
+import androidx.compose.testutils.benchmark.benchmarkFirstMeasure
+import androidx.compose.testutils.benchmark.benchmarkLayoutPerf
+import androidx.compose.testutils.benchmark.benchmarkToFirstPixel
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ImageBitmap
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.graphics.painter.Painter
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.unit.dp
+import androidx.test.filters.LargeTest
+import androidx.wear.compose.material3.Icon
+import androidx.wear.compose.material3.MaterialTheme
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+/**
+ * Benchmark for Wear Compose Material 3 [Icon].
+ */
+@LargeTest
+@RunWith(Parameterized::class)
+class IconBenchmark(private val iconType: IconType) {
+
+ companion object {
+ @Parameterized.Parameters(name = "{0}")
+ @JvmStatic
+ fun parameters() = IconType.values()
+ }
+
+ @get:Rule
+ val benchmarkRule = ComposeBenchmarkRule()
+
+ private val iconCaseFactory = { IconTestCase(iconType) }
+
+ @Test
+ fun first_pixel() {
+ benchmarkRule.benchmarkToFirstPixel(iconCaseFactory)
+ }
+
+ @Test
+ fun first_compose() {
+ benchmarkRule.benchmarkFirstCompose(iconCaseFactory)
+ }
+
+ @Test
+ fun first_measure() {
+ benchmarkRule.benchmarkFirstMeasure(iconCaseFactory)
+ }
+
+ @Test
+ fun first_layout() {
+ benchmarkRule.benchmarkFirstLayout(iconCaseFactory)
+ }
+
+ @Test
+ fun first_draw() {
+ benchmarkRule.benchmarkFirstDraw(iconCaseFactory)
+ }
+
+ @Test
+ fun layout() {
+ benchmarkRule.benchmarkLayoutPerf(iconCaseFactory)
+ }
+
+ @Test
+ fun draw() {
+ benchmarkRule.benchmarkDrawPerf(iconCaseFactory)
+ }
+}
+
+internal class IconTestCase(
+ private val iconType: IconType
+) : LayeredComposeTestCase() {
+ private val width = 24.dp
+ private val height = 24.dp
+ private val imageVector = ImageVector.Builder(
+ defaultWidth = width, defaultHeight = height,
+ viewportWidth = width.value, viewportHeight = height.value
+ ).build()
+ private val imageBitmap = ImageBitmap(
+ width = width.value.toInt(),
+ height = height.value.toInt()
+ )
+ private val painter = object : Painter() {
+ override fun DrawScope.onDraw() {
+ drawRect(color = Color.Black)
+ }
+
+ override val intrinsicSize: Size
+ get() = Size(width.value, height.value)
+ }
+
+ @Composable
+ override fun MeasuredContent() {
+ when (iconType) {
+ IconType.ImageVector -> Icon(
+ imageVector = imageVector,
+ contentDescription = "vector"
+ )
+
+ IconType.Bitmap -> Icon(
+ bitmap = imageBitmap,
+ contentDescription = "bitmap"
+ )
+
+ IconType.Painter -> Icon(
+ painter = painter,
+ contentDescription = "painter"
+ )
+ }
+ }
+
+ @Composable
+ override fun ContentWrappers(content: @Composable () -> Unit) {
+ MaterialTheme {
+ content()
+ }
+ }
+}
+
+enum class IconType {
+ ImageVector, Bitmap, Painter
+}
diff --git a/wear/compose/compose-material3/benchmark/src/androidTest/java/androidx/wear/compose/material3/benchmark/TextBenchmark.kt b/wear/compose/compose-material3/benchmark/src/androidTest/java/androidx/wear/compose/material3/benchmark/TextBenchmark.kt
new file mode 100644
index 0000000..2532b47
--- /dev/null
+++ b/wear/compose/compose-material3/benchmark/src/androidTest/java/androidx/wear/compose/material3/benchmark/TextBenchmark.kt
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2024 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 androidx.wear.compose.material3.benchmark
+
+import androidx.compose.runtime.Composable
+import androidx.compose.testutils.LayeredComposeTestCase
+import androidx.compose.testutils.benchmark.ComposeBenchmarkRule
+import androidx.compose.testutils.benchmark.benchmarkDrawPerf
+import androidx.compose.testutils.benchmark.benchmarkFirstCompose
+import androidx.compose.testutils.benchmark.benchmarkFirstDraw
+import androidx.compose.testutils.benchmark.benchmarkFirstLayout
+import androidx.compose.testutils.benchmark.benchmarkFirstMeasure
+import androidx.compose.testutils.benchmark.benchmarkLayoutPerf
+import androidx.compose.testutils.benchmark.benchmarkToFirstPixel
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.LargeTest
+import androidx.wear.compose.material3.MaterialTheme
+import androidx.wear.compose.material3.Text
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Benchmark for Wear Compose Material 3 [Text].
+ */
+@LargeTest
+@RunWith(AndroidJUnit4::class)
+class TextBenchmark {
+
+ @get:Rule
+ val benchmarkRule = ComposeBenchmarkRule()
+
+ private val textCaseFactory = { TextTestCase() }
+
+ @Test
+ fun first_pixel() {
+ benchmarkRule.benchmarkToFirstPixel(textCaseFactory)
+ }
+
+ @Test
+ fun first_compose() {
+ benchmarkRule.benchmarkFirstCompose(textCaseFactory)
+ }
+
+ @Test
+ fun first_measure() {
+ benchmarkRule.benchmarkFirstMeasure(textCaseFactory)
+ }
+
+ @Test
+ fun first_layout() {
+ benchmarkRule.benchmarkFirstLayout(textCaseFactory)
+ }
+
+ @Test
+ fun first_draw() {
+ benchmarkRule.benchmarkFirstDraw(textCaseFactory)
+ }
+
+ @Test
+ fun layout() {
+ benchmarkRule.benchmarkLayoutPerf(textCaseFactory)
+ }
+
+ @Test
+ fun draw() {
+ benchmarkRule.benchmarkDrawPerf(textCaseFactory)
+ }
+}
+
+internal class TextTestCase : LayeredComposeTestCase() {
+ @Composable
+ override fun MeasuredContent() {
+ Text(text = "Lorem ipsum")
+ }
+
+ @Composable
+ override fun ContentWrappers(content: @Composable () -> Unit) {
+ MaterialTheme {
+ content()
+ }
+ }
+}
diff --git a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/ButtonTest.kt b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/ButtonTest.kt
index a7e67ae..224e22e 100644
--- a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/ButtonTest.kt
+++ b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/ButtonTest.kt
@@ -571,7 +571,7 @@
val status = Status.Disabled
rule.verifyButtonBorderColor(
expectedBorderColor = {
- MaterialTheme.colorScheme.onSurface.copy(alpha = DisabledBorderAlpha)
+ MaterialTheme.colorScheme.outline.copy(alpha = DisabledBorderAlpha)
},
content = { modifier: Modifier ->
OutlinedButton(
diff --git a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/IconButtonTest.kt b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/IconButtonTest.kt
index 4c33129..ff27305 100644
--- a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/IconButtonTest.kt
+++ b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/IconButtonTest.kt
@@ -199,7 +199,9 @@
rule.setContentWithTheme {
IconButton(
onClick = {},
- modifier = Modifier.testTag(TEST_TAG).semantics { role = overrideRole }
+ modifier = Modifier
+ .testTag(TEST_TAG)
+ .semantics { role = overrideRole }
) {
TestImage()
}
@@ -349,7 +351,7 @@
status = Status.Enabled,
colors = { IconButtonDefaults.iconButtonColors() },
expectedContainerColor = { Color.Transparent },
- expectedContentColor = { MaterialTheme.colorScheme.onBackground }
+ expectedContentColor = { MaterialTheme.colorScheme.onSurface }
)
}
@@ -425,7 +427,7 @@
status = Status.Enabled,
colors = { IconButtonDefaults.outlinedIconButtonColors() },
expectedContainerColor = { Color.Transparent },
- expectedContentColor = { MaterialTheme.colorScheme.primary }
+ expectedContentColor = { MaterialTheme.colorScheme.onSurface }
)
}
@@ -464,7 +466,7 @@
val status = Status.Disabled
rule.verifyButtonBorderColor(
expectedBorderColor = {
- MaterialTheme.colorScheme.onSurface.copy(alpha = DisabledBorderAlpha)
+ MaterialTheme.colorScheme.outline.copy(alpha = DisabledBorderAlpha)
},
content = { modifier: Modifier ->
OutlinedIconButton(
diff --git a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/TextButtonTest.kt b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/TextButtonTest.kt
index f00b3af..ff11878 100644
--- a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/TextButtonTest.kt
+++ b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/TextButtonTest.kt
@@ -229,7 +229,9 @@
rule.setContentWithTheme {
TextButton(
onClick = {},
- modifier = Modifier.testTag(TEST_TAG).semantics { role = overrideRole }
+ modifier = Modifier
+ .testTag(TEST_TAG)
+ .semantics { role = overrideRole }
) {
Text("Test")
}
@@ -338,7 +340,7 @@
status = Status.Enabled,
colors = { TextButtonDefaults.textButtonColors() },
expectedContainerColor = { Color.Transparent },
- expectedContentColor = { MaterialTheme.colorScheme.onBackground }
+ expectedContentColor = { MaterialTheme.colorScheme.onSurface }
)
}
@@ -388,7 +390,7 @@
status = Status.Enabled,
colors = { TextButtonDefaults.filledTonalTextButtonColors() },
expectedContainerColor = { MaterialTheme.colorScheme.surfaceContainer },
- expectedContentColor = { MaterialTheme.colorScheme.onSurface }
+ expectedContentColor = { MaterialTheme.colorScheme.onSurfaceVariant }
)
}
@@ -414,7 +416,7 @@
status = Status.Enabled,
colors = { TextButtonDefaults.outlinedTextButtonColors() },
expectedContainerColor = { Color.Transparent },
- expectedContentColor = { MaterialTheme.colorScheme.onBackground }
+ expectedContentColor = { MaterialTheme.colorScheme.onSurface }
)
}
@@ -455,7 +457,7 @@
val status = Status.Disabled
rule.verifyButtonBorderColor(
expectedBorderColor = {
- MaterialTheme.colorScheme.onSurface.copy(alpha = DisabledBorderAlpha)
+ MaterialTheme.colorScheme.outline.copy(alpha = DisabledBorderAlpha)
},
content = { modifier: Modifier ->
TextButton(
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Button.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Button.kt
index 3755e89..06a8513 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Button.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Button.kt
@@ -1282,7 +1282,8 @@
return defaultButtonColorsCached ?: ButtonColors(
containerColor = fromToken(FilledButtonTokens.ContainerColor),
contentColor = fromToken(FilledButtonTokens.LabelColor),
- secondaryContentColor = fromToken(FilledButtonTokens.SecondaryLabelColor),
+ secondaryContentColor = fromToken(FilledButtonTokens.SecondaryLabelColor)
+ .copy(alpha = FilledButtonTokens.SecondaryLabelOpacity),
iconColor = fromToken(FilledButtonTokens.IconColor),
disabledContainerColor = fromToken(FilledButtonTokens.DisabledContainerColor)
.toDisabledColor(disabledAlpha = FilledButtonTokens.DisabledContainerOpacity),
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/IconButton.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/IconButton.kt
index 81c849a..298671f 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/IconButton.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/IconButton.kt
@@ -344,20 +344,23 @@
*
* @param size The size of the icon button
*/
- fun iconSizeFor(size: Dp): Dp = max(SmallIconSize, size / 2f)
+ fun iconSizeFor(size: Dp): Dp = if (size >= LargeButtonSize) {
+ LargeIconSize
+ } else {
+ max(SmallIconSize, size / 2f)
+ }
/**
- * Creates a [ButtonColors] with the colors for [FilledIconButton] - by default,
- * a colored background with a contrasting icon color.
- * If the icon button is disabled then the colors will default to
- * the MaterialTheme onSurface color with suitable alpha values applied.
- *
- */
+ * Creates a [IconButtonColors] with the colors for [FilledIconButton] - by default,
+ * a colored background with a contrasting icon color.
+ * If the icon button is disabled then the colors will default to
+ * the MaterialTheme onSurface color with suitable alpha values applied.
+ */
@Composable
fun filledIconButtonColors() = MaterialTheme.colorScheme.defaultFilledIconButtonColors
/**
- * Creates a [ButtonColors] with the colors for [FilledIconButton] - by default,
+ * Creates a [IconButtonColors] with the colors for [FilledIconButton] - by default,
* a colored background with a contrasting icon color.
* If the icon button is disabled then the colors will default to
* the MaterialTheme onSurface color with suitable alpha values applied.
@@ -381,7 +384,7 @@
)
/**
- * Creates a [ButtonColors] with the colors for [FilledTonalIconButton]- by default,
+ * Creates a [IconButtonColors] with the colors for [FilledTonalIconButton]- by default,
* a muted colored background with a contrasting icon color.
* If the icon button is disabled then the colors will default to
* the MaterialTheme onSurface color with suitable alpha values applied.
@@ -390,7 +393,7 @@
fun filledTonalIconButtonColors() = MaterialTheme.colorScheme.defaultFilledTonalIconButtonColors
/**
- * Creates a [ButtonColors] with the colors for [FilledTonalIconButton]- by default,
+ * Creates a [IconButtonColors] with the colors for [FilledTonalIconButton]- by default,
* a muted colored background with a contrasting icon color.
* If the icon button is disabled then the colors will default to
* the MaterialTheme onSurface color with suitable alpha values applied.
@@ -414,7 +417,7 @@
)
/**
- * Creates a [ButtonColors] with the colors for [OutlinedIconButton]- by default,
+ * Creates a [IconButtonColors] with the colors for [OutlinedIconButton]- by default,
* a transparent background with contrasting icon color.
* If the icon button is disabled then the colors will default to
* the MaterialTheme onSurface color with suitable alpha values applied.
@@ -423,7 +426,7 @@
fun outlinedIconButtonColors() = MaterialTheme.colorScheme.defaultOutlinedIconButtonColors
/**
- * Creates a [ButtonColors] with the colors for [OutlinedIconButton]- by default,
+ * Creates a [IconButtonColors] with the colors for [OutlinedIconButton]- by default,
* a transparent background with contrasting icon color.
* If the icon button is disabled then the colors will default to
* the MaterialTheme onSurface color with suitable alpha values applied.
@@ -443,7 +446,7 @@
)
/**
- * Creates a [ButtonColors] with the colors for [IconButton] - by default,
+ * Creates a [IconButtonColors] with the colors for [IconButton] - by default,
* a transparent background with a contrasting icon color.
* If the icon button is disabled then the colors will default to
* the MaterialTheme onSurface color with suitable alpha values applied.
@@ -452,7 +455,7 @@
fun iconButtonColors() = MaterialTheme.colorScheme.defaultIconButtonColors
/**
- * Creates a [ButtonColors] with the colors for [IconButton] - by default,
+ * Creates a [IconButtonColors] with the colors for [IconButton] - by default,
* a transparent background with a contrasting icon color.
* If the icon button is disabled then the colors will default to
* the MaterialTheme onSurface color with suitable alpha values applied.
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/TextButton.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/TextButton.kt
index 12d23b7..c479bc5 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/TextButton.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/TextButton.kt
@@ -293,6 +293,11 @@
disabledContentColor = disabledContentColor
)
+ /**
+ * Creates a [TextButtonColors] for a text button - by default, a transparent
+ * background with contrasting content color. If the button is disabled
+ * then the colors default to [ColorScheme.onSurface] with suitable alpha values applied.
+ */
@Composable
fun textButtonColors() = MaterialTheme.colorScheme.defaultTextButtonColors
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/FilledTonalTextButtonTokens.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/FilledTonalTextButtonTokens.kt
index 8459b18..876fbb5 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/FilledTonalTextButtonTokens.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/FilledTonalTextButtonTokens.kt
@@ -22,7 +22,7 @@
internal object FilledTonalTextButtonTokens {
val ContainerColor = ColorSchemeKeyTokens.SurfaceContainer
val ContainerShape = ShapeKeyTokens.CornerFull
- val ContentColor = ColorSchemeKeyTokens.OnSurface
+ val ContentColor = ColorSchemeKeyTokens.OnSurfaceVariant
val ContentFont = TypographyKeyTokens.LabelMedium
val DisabledContainerColor = ColorSchemeKeyTokens.OnSurface
val DisabledContainerOpacity = 0.12f
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/IconButtonTokens.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/IconButtonTokens.kt
index 2eb7943..1b7d093 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/IconButtonTokens.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/IconButtonTokens.kt
@@ -27,10 +27,10 @@
val ContainerLargeSize = 60.0.dp
val ContainerShape = ShapeKeyTokens.CornerFull
val ContainerSmallSize = 48.0.dp
- val ContentColor = ColorSchemeKeyTokens.OnBackground
+ val ContentColor = ColorSchemeKeyTokens.OnSurface
val DisabledContentColor = ColorSchemeKeyTokens.OnSurface
val DisabledContentOpacity = 0.38f
val IconDefaultSize = 26.0.dp
- val IconLargeSize = 30.0.dp
+ val IconLargeSize = 32.0.dp
val IconSmallSize = 24.0.dp
}
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedButtonTokens.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedButtonTokens.kt
index 75f8220..51371a0 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedButtonTokens.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedButtonTokens.kt
@@ -26,7 +26,7 @@
val ContainerBorderWidth = 1.0.dp
val ContainerHeight = 52.0.dp
val ContainerShape = ShapeKeyTokens.CornerLarge
- val DisabledContainerBorderColor = ColorSchemeKeyTokens.OnSurface
+ val DisabledContainerBorderColor = ColorSchemeKeyTokens.Outline
val DisabledContainerBorderOpacity = 0.2f
val DisabledContentColor = ColorSchemeKeyTokens.OnSurface
val DisabledContentOpacity = 0.38f
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedIconButtonTokens.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedIconButtonTokens.kt
index e32f5b5..60e343b 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedIconButtonTokens.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedIconButtonTokens.kt
@@ -20,7 +20,7 @@
package androidx.wear.compose.material3.tokens
internal object OutlinedIconButtonTokens {
- val ContentColor = ColorSchemeKeyTokens.Primary
+ val ContentColor = ColorSchemeKeyTokens.OnSurface
val DisabledContentColor = ColorSchemeKeyTokens.OnSurface
val DisabledContentOpacity = 0.38f
}
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedTextButtonTokens.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedTextButtonTokens.kt
index 1f8d5be..1012cb3 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedTextButtonTokens.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/OutlinedTextButtonTokens.kt
@@ -21,7 +21,7 @@
internal object OutlinedTextButtonTokens {
val ContainerShape = ShapeKeyTokens.CornerFull
- val ContentColor = ColorSchemeKeyTokens.OnBackground
+ val ContentColor = ColorSchemeKeyTokens.OnSurface
val ContentFont = TypographyKeyTokens.LabelMedium
val DisabledContentColor = ColorSchemeKeyTokens.OnSurface
val DisabledContentOpacity = 0.38f
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/TextButtonTokens.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/TextButtonTokens.kt
index 27fbfaa..adffcf5 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/TextButtonTokens.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/tokens/TextButtonTokens.kt
@@ -26,7 +26,7 @@
val ContainerLargeSize = 60.0.dp
val ContainerShape = ShapeKeyTokens.CornerFull
val ContainerSmallSize = 48.0.dp
- val ContentColor = ColorSchemeKeyTokens.OnBackground
+ val ContentColor = ColorSchemeKeyTokens.OnSurface
val ContentFont = TypographyKeyTokens.LabelMedium
val DisabledContentColor = ColorSchemeKeyTokens.OnSurface
val DisabledContentOpacity = 0.38f
diff --git a/wear/compose/integration-tests/demos/build.gradle b/wear/compose/integration-tests/demos/build.gradle
index d68e962..69212c9 100644
--- a/wear/compose/integration-tests/demos/build.gradle
+++ b/wear/compose/integration-tests/demos/build.gradle
@@ -25,8 +25,8 @@
defaultConfig {
applicationId "androidx.wear.compose.integration.demos"
minSdk 25
- versionCode 24
- versionName "1.24"
+ versionCode 26
+ versionName "1.26"
}
buildTypes {
diff --git a/webkit/integration-tests/instrumentation/lint-baseline.xml b/webkit/integration-tests/instrumentation/lint-baseline.xml
deleted file mode 100644
index d08c143..0000000
--- a/webkit/integration-tests/instrumentation/lint-baseline.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.4.0-alpha12" type="baseline" client="gradle" dependencies="false" name="AGP (8.4.0-alpha12)" variant="all" version="8.4.0-alpha12">
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1="@SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP)"
- errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1="@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)"
- errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatDarkThemeTest.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1="@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)"
- errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatLightThemeTest.java"/>
- </issue>
-
-</issues>
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java
index 2283a2e..c881bda 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java
@@ -17,7 +17,6 @@
package androidx.webkit;
import android.net.Uri;
-import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -26,7 +25,6 @@
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.filters.SdkSuppress;
import androidx.webkit.WebMessagePortCompat.WebMessageCallbackCompat;
import org.junit.After;
@@ -40,7 +38,6 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class PostMessageTest {
public static final long TIMEOUT = 6000L;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java
index 5d23fb0..8a5ff6d 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java
@@ -23,12 +23,9 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import android.os.Build;
-
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import androidx.webkit.internal.ProxyControllerImpl;
import org.junit.After;
@@ -46,7 +43,6 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class ProxyControllerTest {
private WebViewOnUiThread mWebViewOnUiThread;
private MockWebServer mContentServer;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java
index 180fea3..292a28a 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java
@@ -19,7 +19,6 @@
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
-import android.os.Build;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
@@ -27,10 +26,8 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assume;
@@ -46,8 +43,6 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
-@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public class ServiceWorkerClientCompatTest {
// This test relies on
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerWebSettingsCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerWebSettingsCompatTest.java
index e7f9feb..4588df3 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerWebSettingsCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerWebSettingsCompatTest.java
@@ -19,13 +19,11 @@
import static androidx.webkit.WebViewFeature.isFeatureSupported;
import android.annotation.SuppressLint;
-import android.os.Build;
import android.os.SystemClock;
import android.webkit.WebSettings;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assert;
@@ -46,7 +44,6 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class ServiceWorkerWebSettingsCompatTest {
public static final String TEST_APK_NAME = "androidx.webkit.instrumentation.test";
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/TracingControllerTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/TracingControllerTest.java
index 6f15592..cc84a35 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/TracingControllerTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/TracingControllerTest.java
@@ -19,11 +19,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
-import android.os.Build;
-
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assert;
@@ -46,7 +43,6 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class TracingControllerTest {
private TracingController mTracingController;
private WebViewOnUiThread mWebViewOnUiThread;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatTest.java
index 9bd6514..e53c51d 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatTest.java
@@ -24,11 +24,9 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import android.os.Build;
import android.webkit.WebSettings;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.After;
@@ -48,7 +46,6 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebSettingsCompatTest {
public static final String TEST_APK_NAME = "androidx.webkit.instrumentation.test";
WebViewOnUiThread mWebViewOnUiThread;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java
index d7f9d73..e71a3ed 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java
@@ -21,7 +21,6 @@
import static org.junit.Assert.assertNotNull;
-import android.os.Build;
import android.webkit.CookieManager;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
@@ -29,7 +28,6 @@
import android.webkit.WebView;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.After;
@@ -48,7 +46,6 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebSettingsCompatUserAgentMetadataTest {
private static final String[] USER_AGENT_CLIENT_HINTS = {"sec-ch-ua", "sec-ch-ua-arch",
"sec-ch-ua-platform", "sec-ch-ua-model", "sec-ch-ua-mobile", "sec-ch-ua-full-version",
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewApkTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewApkTest.java
index 11a63c6..048c74c8 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewApkTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewApkTest.java
@@ -16,10 +16,7 @@
package androidx.webkit;
-import android.os.Build;
-
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
@@ -28,12 +25,9 @@
import org.junit.runner.RunWith;
/**
- * Tests related to the state of the WebView APK on the device. These tests only makes sense on L+
- * (21+) devices where the WebView implementation is provided by a WebView APK rather than the
- * framework itself.
+ * Tests related to the state of the WebView APK on the device.
*/
@SmallTest
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
@RunWith(AndroidJUnit4.class)
public class WebViewApkTest {
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java
index fb9b636..227eb31 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java
@@ -18,18 +18,15 @@
import android.graphics.Bitmap;
import android.net.Uri;
-import android.os.Build;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assert;
@@ -51,8 +48,6 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
-@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public class WebViewClientCompatTest {
private WebViewOnUiThread mWebViewOnUiThread;
private MockWebServer mWebServer;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java
index ab4b790..dcfc8f6 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java
@@ -65,7 +65,6 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebViewCompatTest {
WebViewOnUiThread mWebViewOnUiThread;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
index 0ed9655..a8c9aee 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
@@ -17,13 +17,11 @@
package androidx.webkit;
import android.net.Uri;
-import android.os.Build;
import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assert;
@@ -45,7 +43,6 @@
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebViewDocumentStartJavaScriptTest {
private static final String BASE_URI = "http://www.example.com";
private static final String JS_OBJECT_NAME = "myObject";
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java
index 8289f40..3e0c15f 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java
@@ -16,18 +16,15 @@
package androidx.webkit;
-import android.os.Build;
import android.view.KeyEvent;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assert;
@@ -42,8 +39,6 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
-@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public class WebViewRenderProcessClientTest {
WebViewOnUiThread mWebViewOnUiThread;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessTest.java
index a935e52..e46b89f 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessTest.java
@@ -38,7 +38,6 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebViewRenderProcessTest {
private boolean terminateRenderProcessOnUiThread(
final WebViewRenderProcess renderer) {
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java
index 2216034..254764a 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java
@@ -18,11 +18,9 @@
import android.content.Context;
import android.content.pm.PackageInfo;
-import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.test.core.app.ApplicationProvider;
import java.util.Arrays;
@@ -33,7 +31,6 @@
* Represents a WebView version. Is comparable. This supports version numbers following the
* scheme outlined at https://www.chromium.org/developers/version-numbers.
*/
-@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
class WebViewVersion implements Comparable<WebViewVersion> {
private static final Pattern CHROMIUM_VERSION_REGEX =
Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$");
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java
index 8eaeebd..3104db2 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java
@@ -17,7 +17,6 @@
package androidx.webkit;
import android.net.Uri;
-import android.os.Build;
import android.os.Handler;
import android.os.Looper;
@@ -25,7 +24,6 @@
import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assert;
@@ -45,7 +43,6 @@
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebViewWebMessageCompatTest {
private static final String BASE_URI = "http://www.example.com";
private static final String ECHO_MESSAGE = "<!DOCTYPE html><html><body>"
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
index d49f962..37f689b 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
@@ -17,13 +17,11 @@
package androidx.webkit;
import android.net.Uri;
-import android.os.Build;
import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.After;
import org.junit.Assert;
@@ -46,7 +44,6 @@
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebViewWebMessageListenerTest {
private static final String BASE_URI = "http://www.example.com";
private static final String JS_OBJECT_NAME = "myWebMessageListener";
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java
index 62bd52e..182f10e 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java
@@ -20,7 +20,6 @@
import android.os.Looper;
import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
import androidx.concurrent.futures.ResolvableFuture;
import com.google.common.util.concurrent.ListenableFuture;
@@ -165,15 +164,8 @@
* <p>
* Note that this method is AndroidX-specific, and is not reflected in the CTS class.
*
- * <p>
- * This method does not actually require API 21, but it will always fail for API < 21, so the
- * annotation has been added to make it easier to spot instances where this is being called
- * in a test. AffectedTests should be annotated with
- * {@code @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)}
- *
* @param featureName the feature to be checked
*/
- @RequiresApi(21)
public static void checkFeature(@NonNull String featureName) {
final String msg = "This device does not have the feature '" + featureName + "'";
final boolean hasFeature = WebViewFeature.isFeatureSupported(featureName);
diff --git a/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java b/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
index f7085fe..426bcd0 100644
--- a/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
@@ -21,12 +21,9 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import android.os.Build.VERSION_CODES;
-
import androidx.core.graphics.ColorUtils;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.Assert;
import org.junit.Test;
@@ -38,7 +35,6 @@
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP)
public class WebSettingsCompatForceDarkTest extends
WebSettingsCompatDarkModeTestBase<WebViewLightThemeTestActivity> {
public WebSettingsCompatForceDarkTest() {
diff --git a/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatDarkThemeTest.java b/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatDarkThemeTest.java
index 2e7f311..88ae337 100644
--- a/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatDarkThemeTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatDarkThemeTest.java
@@ -20,12 +20,9 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import android.os.Build;
-
import androidx.core.graphics.ColorUtils;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,7 +32,6 @@
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebSettingsCompatDarkThemeTest extends
WebSettingsCompatDarkModeTestBase<WebViewDarkThemeTestActivity> {
public WebSettingsCompatDarkThemeTest() {
diff --git a/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatLightThemeTest.java b/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatLightThemeTest.java
index 68ae3ff..f4e42f4 100644
--- a/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatLightThemeTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTestTargetSdkLatest/java/androidx/webkit/WebSettingsCompatLightThemeTest.java
@@ -24,7 +24,6 @@
import androidx.core.graphics.ColorUtils;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.filters.SdkSuppress;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,7 +33,6 @@
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public class WebSettingsCompatLightThemeTest extends
WebSettingsCompatDarkModeTestBase<WebViewLightThemeTestActivity> {
public WebSettingsCompatLightThemeTest() {
diff --git a/webkit/integration-tests/testapp/lint-baseline.xml b/webkit/integration-tests/testapp/lint-baseline.xml
index 9eb73549..0bc7d09 100644
--- a/webkit/integration-tests/testapp/lint-baseline.xml
+++ b/webkit/integration-tests/testapp/lint-baseline.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.4.0-alpha12" type="baseline" client="gradle" dependencies="false" name="AGP (8.4.0-alpha12)" variant="all" version="8.4.0-alpha12">
+<issues format="6" by="lint 8.5.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.5.0-alpha06)" variant="all" version="8.5.0-alpha06">
<issue
id="RestrictedApiAndroidX"
@@ -10,103 +10,4 @@
file="src/main/java/com/example/androidx/webkit/RequestedWithHeaderActivity.java"/>
</issue>
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1="@RequiresApi(21)"
- errorLine2="~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/Api21Impl.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21) // This won't be called on < L, so we can safely apply @RequiresApi."
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21) // for WebResourceRequest"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; SDK_INT is always >= 21"
- errorLine1=" @RequiresApi(21)"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java"/>
- </issue>
-
</issues>
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/Api21Impl.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/Api21Impl.java
deleted file mode 100644
index 2b12229..0000000
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/Api21Impl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2022 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.example.androidx.webkit;
-
-import android.net.Uri;
-import android.webkit.WebResourceRequest;
-
-import androidx.annotation.DoNotInline;
-import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
-
-/**
- * Helper class to avoid class verification failures for APIs introduced in version 21.
- */
-@RequiresApi(21)
-class Api21Impl {
- private Api21Impl() {
- // This class is not instantiable.
- }
-
- @NonNull
- @DoNotInline
- static Uri getUrl(@NonNull WebResourceRequest webResourceRequest) {
- return webResourceRequest.getUrl();
- }
-
-}
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java
index 56e3f0b..6acd859 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java
@@ -28,7 +28,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AppCompatActivity;
import androidx.test.espresso.idling.net.UriIdlingResource;
@@ -61,10 +60,9 @@
}
@Override
- @RequiresApi(21)
public WebResourceResponse shouldInterceptRequest(WebView view,
WebResourceRequest request) {
- Uri url = Api21Impl.getUrl(request);
+ Uri url = request.getUrl();
mUriIdlingResource.beginLoad(url.toString());
WebResourceResponse response = mAssetLoader.shouldInterceptRequest(url);
mUriIdlingResource.endLoad(url.toString());
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
index 701a90d..bc683d9 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
@@ -30,7 +30,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewAssetLoader;
import androidx.webkit.WebViewAssetLoader.InternalStoragePathHandler;
@@ -67,10 +66,9 @@
}
@Override
- @RequiresApi(21)
public WebResourceResponse shouldInterceptRequest(WebView view,
WebResourceRequest request) {
- return mAssetLoader.shouldInterceptRequest(Api21Impl.getUrl(request));
+ return mAssetLoader.shouldInterceptRequest(request.getUrl());
}
/** @noinspection RedundantSuppression*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java
index 7b47287..594acdb 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java
@@ -26,7 +26,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewAssetLoader;
@@ -50,10 +49,9 @@
}
@Override
- @RequiresApi(21)
public WebResourceResponse shouldInterceptRequest(WebView view,
WebResourceRequest request) {
- return mAssetLoader.shouldInterceptRequest(Api21Impl.getUrl(request));
+ return mAssetLoader.shouldInterceptRequest(request.getUrl());
}
@Override
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java
index 92b7c0c..070268c 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java
@@ -25,7 +25,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.SafeBrowsingResponseCompat;
import androidx.webkit.WebViewClientCompat;
@@ -90,7 +89,6 @@
}
@Override
- @RequiresApi(21) // This won't be called on < L, so we can safely apply @RequiresApi.
public void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
int threatType, @NonNull SafeBrowsingResponseCompat callback) {
mSafeBrowsingResponseMap.put(mActivityRequestCounter, callback);
@@ -98,12 +96,11 @@
mActivityRequestCounter++;
}
- @RequiresApi(21) // for WebResourceRequest
private void createInterstitial(int threatType, @NonNull WebResourceRequest request) {
Intent myIntent = new Intent(mActivity, PopupInterstitialActivity.class);
myIntent.putExtra(PopupInterstitialActivity.THREAT_TYPE, threatType);
myIntent.putExtra(PopupInterstitialActivity.THREAT_URL,
- Api21Impl.getUrl(request).toString());
+ request.getUrl().toString());
mActivity.startActivityForResult(myIntent, mActivityRequestCounter);
}
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java
index e5b08aa..4238793 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java
@@ -30,7 +30,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.JavaScriptReplyProxy;
import androidx.webkit.WebMessageCompat;
@@ -63,10 +62,9 @@
}
@Override
- @RequiresApi(21)
public WebResourceResponse shouldInterceptRequest(WebView view,
WebResourceRequest request) {
- return mAssetLoader.shouldInterceptRequest(Api21Impl.getUrl(request));
+ return mAssetLoader.shouldInterceptRequest(request.getUrl());
}
@Override
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java
index fdc427b..4ab8da4 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java
@@ -21,7 +21,6 @@
import android.widget.TextView;
import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
import androidx.webkit.WebResourceErrorCompat;
import androidx.webkit.WebViewClientCompat;
import androidx.webkit.WebViewFeature;
@@ -40,11 +39,10 @@
}
@Override
- @RequiresApi(21)
public void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
@NonNull WebResourceErrorCompat error) {
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_ERROR_GET_CODE)) {
- logErrors(Api21Impl.getUrl(request).toString(), error.getErrorCode());
+ logErrors(request.getUrl().toString(), error.getErrorCode());
}
}
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java
index b81460e..78114cd 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java
@@ -27,9 +27,6 @@
/**
* A {@link ListView} which serves as a menu of elements firing {@link Intent}s to other Activities.
- *
- * Not overriding {@link ListView#ListView(Context, AttributeSet, int, int)} since it only
- * applies to API version 21, and we compile this apk for 19.
*/
public class MenuListView extends ListView {
public MenuListView(@NonNull Context context) {
@@ -42,6 +39,11 @@
super(context, attrs, defStyleAttr);
}
+ public MenuListView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
/**
* An item in the {@link MenuListView}.
*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java
index e3c908f..1cb19f1 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java
@@ -30,7 +30,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.UserAgentMetadata;
import androidx.webkit.WebSettingsCompat;
@@ -63,10 +62,9 @@
}
@Override
- @RequiresApi(21)
public WebResourceResponse shouldInterceptRequest(WebView view,
WebResourceRequest request) {
- return mAssetLoader.shouldInterceptRequest(Api21Impl.getUrl(request));
+ return mAssetLoader.shouldInterceptRequest(request.getUrl());
}
@Override
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java
index 627af50..c604d9e 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java
@@ -38,7 +38,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.JavaScriptReplyProxy;
import androidx.webkit.WebMessageCompat;
@@ -73,10 +72,9 @@
}
@Override
- @RequiresApi(21)
public WebResourceResponse shouldInterceptRequest(WebView view,
WebResourceRequest request) {
- return mAssetLoader.shouldInterceptRequest(Api21Impl.getUrl(request));
+ return mAssetLoader.shouldInterceptRequest(request.getUrl());
}
@Override
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java
index 1fcd28f..b72ca5b 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java
@@ -30,7 +30,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.JavaScriptReplyProxy;
import androidx.webkit.WebMessageCompat;
@@ -58,12 +57,11 @@
}
@Override
- @RequiresApi(21)
public WebResourceResponse shouldInterceptRequest(WebView view,
WebResourceRequest request) {
for (WebViewAssetLoader loader : mAssetLoaders) {
WebResourceResponse response = loader.shouldInterceptRequest(
- Api21Impl.getUrl(request));
+ request.getUrl());
if (response != null) {
return response;
}
diff --git a/webkit/webkit/api/current.txt b/webkit/webkit/api/current.txt
index 311b33d..b44d1a0 100644
--- a/webkit/webkit/api/current.txt
+++ b/webkit/webkit/api/current.txt
@@ -300,9 +300,9 @@
public class WebViewClientCompat extends android.webkit.WebViewClient {
ctor public WebViewClientCompat();
- method @RequiresApi(23) public final void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
- method @RequiresApi(21) @UiThread public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, androidx.webkit.WebResourceErrorCompat);
- method @RequiresApi(27) public final void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.SafeBrowsingResponse);
+ method @RequiresApi(android.os.Build.VERSION_CODES.M) public final void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
+ method @UiThread public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, androidx.webkit.WebResourceErrorCompat);
+ method @RequiresApi(android.os.Build.VERSION_CODES.O_MR1) public final void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.SafeBrowsingResponse);
method @UiThread public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, androidx.webkit.SafeBrowsingResponseCompat);
}
diff --git a/webkit/webkit/api/restricted_current.txt b/webkit/webkit/api/restricted_current.txt
index 311b33d..b44d1a0 100644
--- a/webkit/webkit/api/restricted_current.txt
+++ b/webkit/webkit/api/restricted_current.txt
@@ -300,9 +300,9 @@
public class WebViewClientCompat extends android.webkit.WebViewClient {
ctor public WebViewClientCompat();
- method @RequiresApi(23) public final void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
- method @RequiresApi(21) @UiThread public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, androidx.webkit.WebResourceErrorCompat);
- method @RequiresApi(27) public final void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.SafeBrowsingResponse);
+ method @RequiresApi(android.os.Build.VERSION_CODES.M) public final void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
+ method @UiThread public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, androidx.webkit.WebResourceErrorCompat);
+ method @RequiresApi(android.os.Build.VERSION_CODES.O_MR1) public final void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.SafeBrowsingResponse);
method @UiThread public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, androidx.webkit.SafeBrowsingResponseCompat);
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java b/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java
index e8e0d93..50bf858 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java
@@ -35,7 +35,7 @@
* WebView provides partial support for Android
* <a href="https://developer.android.com/develop/ui/views/touch-and-input/drag-drop">
* Drag and Drop</a> allowing images, text and links to be dragged out of a WebView.
- *
+ * <p>
* The content provider is required to make the images drag work, to enable, you should add this
* class to your manifest, for example:
*
diff --git a/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java b/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java
index 40fb9e3..0ba3e26 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java
@@ -22,7 +22,7 @@
/**
* This class represents the JavaScript object injected by {@link
- * WebViewCompat#addWebMessageListener(android.webkit.WebView, String, Set,
+ * WebViewCompat#addWebMessageListener(android.webkit.WebView, String, java.util.Set,
* WebViewCompat.WebMessageListener) WebViewCompat#addWebMessageListener}. An instance will be given
* by {@link WebViewCompat.WebMessageListener#onPostMessage(android.webkit.WebView,
* WebMessageCompat, android.net.Uri, boolean, JavaScriptReplyProxy)
@@ -32,7 +32,7 @@
* <p>
* There is a 1:1 relationship between this object and the JavaScript object in a frame.
*
- * @see WebViewCompat#addWebMessageListener(android.webkit.WebView, String, Set,
+ * @see WebViewCompat#addWebMessageListener(android.webkit.WebView, String, java.util.Set,
* WebViewCompat.WebMessageListener).
*/
public abstract class JavaScriptReplyProxy {
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java b/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java
index 2a6ea4c..b03c494 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java
@@ -34,7 +34,7 @@
/**
* Process Global Configuration for WebView.
- *
+ * <p>
* WebView has some process-global configuration parameters that cannot be changed once WebView has
* been loaded. This class allows apps to set these parameters.
* <p>
@@ -61,7 +61,7 @@
*/
public class ProcessGlobalConfig {
private static final AtomicReference<HashMap<String, Object>> sProcessGlobalConfig =
- new AtomicReference<HashMap<String, Object>>();
+ new AtomicReference<>();
private static final Object sLock = new Object();
@GuardedBy("sLock")
private static boolean sApplyCalled = false;
@@ -77,7 +77,7 @@
/**
* Define the directory used to store WebView data for the current process.
- *
+ * <p>
* The provided suffix will be used when constructing data and cache
* directory paths. If this API is not called, no suffix will be used.
* Each directory can be used by only one process in the application. If more
@@ -132,7 +132,7 @@
/**
* Set the base directories that WebView will use for the current process.
- *
+ * <p>
* If this method is not used, WebView uses the default base paths defined by the Android
* framework.
* <p>
@@ -192,7 +192,7 @@
/**
* Applies the configuration to be used by WebView on loading.
- *
+ * <p>
* This method can only be called once.
* <p>
* Calling this method will not cause WebView to be loaded and will not block the calling
@@ -223,7 +223,7 @@
}
sApplyCalled = true;
}
- HashMap<String, Object> configMap = new HashMap<String, Object>();
+ HashMap<String, Object> configMap = new HashMap<>();
if (webViewCurrentlyLoaded()) {
throw new IllegalStateException("WebView has already been loaded in the current "
+ "process, so any attempt to apply the settings in ProcessGlobalConfig will "
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java b/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java
index 66f0d13..887e910 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java
@@ -32,13 +32,13 @@
* <p>Example usage:
* <pre class="prettyprint">
* ProfileStore profileStore = ProfileStore.getInstance();
- *
+ * <p>
* // Use this store instance to manage Profiles.
* Profile createdProfile = profileStore.getOrCreateProfile("test_profile");
* createdProfile.getGeolocationPermissions().clear("example");
* //...
* profileStore.deleteProfile("profile_test");
- *
+ * <p>
* </pre>
*/
@UiThread
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java b/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java
index 5cb93e7..f1772c6 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java
@@ -66,9 +66,9 @@
private static final String BYPASS_RULE_SIMPLE_NAMES = "<local>";
private static final String BYPASS_RULE_REMOVE_IMPLICIT = "<-loopback>";
- private List<ProxyRule> mProxyRules;
- private List<String> mBypassRules;
- private boolean mReverseBypass;
+ private final List<ProxyRule> mProxyRules;
+ private final List<String> mBypassRules;
+ private final boolean mReverseBypass;
/**
*/
@@ -124,8 +124,8 @@
* Class that holds a scheme filter and a proxy URL.
*/
public static final class ProxyRule {
- private String mSchemeFilter;
- private String mUrl;
+ private final String mSchemeFilter;
+ private final String mUrl;
/**
*/
@@ -173,8 +173,8 @@
* connections to be made directly.
*/
public static final class Builder {
- private List<ProxyRule> mProxyRules;
- private List<String> mBypassRules;
+ private final List<ProxyRule> mProxyRules;
+ private final List<String> mBypassRules;
private boolean mReverseBypass = false;
/**
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java
index 2d5031b..2b4fc34 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java
@@ -81,7 +81,7 @@
/**
*
* Sets the client to capture service worker related callbacks.
- *
+ * <p>
* A {@link ServiceWorkerClientCompat} should be set before any service workers are
* active, e.g. a safe place is before any WebView instances are created or
* pages loaded.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java
index 68035ec..545e92d 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java
@@ -205,7 +205,7 @@
* discontinued.
* <p>
* Apps can use this method to restore the legacy behavior for servers that still rely on
- * the deprecated header, but it should not be used to identify the webview to first-party
+ * the deprecated header, but it should not be used to identify the WebView to first-party
* servers under the control of the app developer.
* <p>
* The format of the strings in the allow-list follows the origin rules of
diff --git a/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java b/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java
index 901017a..78bc157 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java
@@ -30,7 +30,7 @@
/**
* Holds tracing configuration information and predefined settings
* for {@link TracingController}.
- *
+ * <p>
* This class is functionally equivalent to {@link android.webkit.TracingConfig}.
*/
public class TracingConfig {
@@ -102,7 +102,7 @@
/**
* Record trace events until the internal tracing buffer is full.
- *
+ * <p>
* Typically the buffer memory usage is larger than {@link #RECORD_CONTINUOUSLY}.
* Depending on the implementation typically allows up to 256k events to be stored.
*/
@@ -110,16 +110,16 @@
/**
* Record trace events continuously using an internal ring buffer. Default tracing mode.
- *
+ * <p>
* Overwrites old events if they exceed buffer capacity. Uses less memory than the
* {@link #RECORD_UNTIL_FULL} mode. Depending on the implementation typically allows
* up to 64k events to be stored.
*/
public static final int RECORD_CONTINUOUSLY = android.webkit.TracingConfig.RECORD_CONTINUOUSLY;
- private @PredefinedCategories int mPredefinedCategories;
+ private final @PredefinedCategories int mPredefinedCategories;
private final List<String> mCustomIncludedCategories = new ArrayList<>();
- private @TracingMode int mTracingMode;
+ private final @TracingMode int mTracingMode;
@RestrictTo(RestrictTo.Scope.LIBRARY)
public TracingConfig(@PredefinedCategories int predefinedCategories,
@@ -168,24 +168,24 @@
* // Create a configuration with default options: {@link #CATEGORIES_NONE},
* // {@link #RECORD_CONTINUOUSLY}.
* <code>new TracingConfig.Builder().build()</code>
- *
+ * <p>
* // Record trace events from the "web developer" predefined category sets.
* // Uses a ring buffer (the default {@link #RECORD_CONTINUOUSLY} mode) for
* // internal storage during tracing.
* <code>new TracingConfig.Builder().addCategories(CATEGORIES_WEB_DEVELOPER).build()</code>
- *
+ * <p>
* // Record trace events from the "rendering" and "input latency" predefined
* // category sets.
* <code>new TracingConfig.Builder().addCategories(CATEGORIES_RENDERING,
* CATEGORIES_INPUT_LATENCY).build()</code>
- *
+ * <p>
* // Record only the trace events from the "browser" category.
* <code>new TracingConfig.Builder().addCategories("browser").build()</code>
- *
+ * <p>
* // Record only the trace events matching the "blink*" and "renderer*" patterns
* // (e.g. "blink.animations", "renderer_host" and "renderer.scheduler" categories).
* <code>new TracingConfig.Builder().addCategories("blink*","renderer*").build()</code>
- *
+ * <p>
* // Record events from the "web developer" predefined category set and events from
* // the "disabled-by-default-v8.gc" category to understand where garbage collection
* // is being triggered. Uses a limited size buffer for internal storage during tracing.
@@ -218,7 +218,7 @@
/**
* Adds predefined sets of categories to be included in the trace output.
- *
+ * <p>
* A predefined category set can be one of
* {@link TracingConfig#CATEGORIES_NONE},
* {@link TracingConfig#CATEGORIES_ALL},
@@ -242,7 +242,7 @@
/**
* Adds custom categories to be included in trace output.
- *
+ * <p>
* Note that the categories are defined by the currently-in-use version of WebView. They
* live in chromium code and are not part of the Android API.
* See <a href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">
@@ -260,7 +260,7 @@
/**
* Adds custom categories to be included in trace output.
- *
+ * <p>
* Same as {@link #addCategories(String...)} but allows to pass a Collection as a parameter.
*
* @param categories A list of category patterns.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/TracingController.java b/webkit/webkit/src/main/java/androidx/webkit/TracingController.java
index 478590e..86b6016 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/TracingController.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/TracingController.java
@@ -74,7 +74,7 @@
}
/**
- * Starts tracing all webviews. Depending on the trace mode in traceConfig
+ * Starts tracing all WebViews. Depending on the trace mode in traceConfig
* specifies how the trace events are recorded.
*
* <p>
@@ -97,7 +97,7 @@
/**
* Stops tracing and flushes tracing data to the specified outputStream.
- *
+ * <p>
* The data is sent to the specified output stream in json format typically in chunks
* by invoking {@link OutputStream#write(byte[])}.
* On completion the {@link OutputStream#close()} method is called.
@@ -110,7 +110,7 @@
* If {@code null} the tracing data will be discarded.
* @param executor The Executor on which the outputStream {@link OutputStream#write(byte[])} and
* {@link OutputStream#close()} methods will be invoked.
- *
+ * <p>
* Callback and listener events are dispatched through this Executor,
* providing an easy way to control which thread is used.
* To dispatch events through the main thread of your application,
diff --git a/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java b/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java
index 1517f41..b9ee81e 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java
@@ -376,7 +376,7 @@
* <pre class="prettyprint">
* // Create a setting with default options.
* new UserAgentMetadata.Builder().build();
- *
+ * <p>
* // Create a setting with a brand version contains brand name: myBrand, major version: 100,
* // full version: 100.1.1.1.
* BrandVersion brandVersion = new BrandVersion.Builder().setBrand("myBrand")
@@ -385,7 +385,7 @@
* .build();
* new UserAgentMetadata.Builder().setBrandVersionList(Collections.singletonList(brandVersion))
* .build();
- *
+ * <p>
* // Create a setting brand version, platform, platform version and bitness.
* new UserAgentMetadata.Builder().setBrandVersionList(Collections.singletonList(brandVersion))
* .setPlatform("myPlatform")
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java
index d382c22..aee9e29 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java
@@ -28,7 +28,8 @@
/**
* The Java representation of the HTML5 PostMessage event. See
- * https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces
+ * <a href="https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces">
+ * https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces</a>
* for definition of a MessageEvent in HTML5.
*/
public class WebMessageCompat {
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java
index 3518eb5..91a3cfd 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java
@@ -33,7 +33,7 @@
* HTML5 message ports.</a>
*
* <p>A Message port represents one endpoint of a Message Channel. In Android
- * webview, there is no separate Message Channel object. When a message channel
+ * WebView, there is no separate Message Channel object. When a message channel
* is created, both ports are tangled to each other and started, and then
* returned in a MessagePort array, see {@link WebViewCompat#createWebMessageChannel}
* for creating a message channel.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java
index 5c15f3a..aa8c02e 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java
@@ -678,7 +678,7 @@
* discontinued.
* <p>
* Apps can use this method to restore the legacy behavior for servers that still rely on
- * the deprecated header, but it should not be used to identify the webview to first-party
+ * the deprecated header, but it should not be used to identify the WebView to first-party
* servers under the control of the app developer.
* <p>
* The format of the strings in the allow-list follows the origin rules of
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java
index d9a60d6..3a8a7fa 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java
@@ -62,21 +62,20 @@
* final WebViewAssetLoader assetLoader = new WebViewAssetLoader.Builder()
* .addPathHandler("/assets/", new AssetsPathHandler(this))
* .build();
- *
+ * <p>
* webView.setWebViewClient(new WebViewClientCompat() {
* {@literal @}Override
- * {@literal @}RequiresApi(21)
* public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
* return assetLoader.shouldInterceptRequest(request.getUrl());
* }
- *
+ * <p>
* {@literal @}Override
* {@literal @}SuppressWarnings("deprecation") // for API < 21
* public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
* return assetLoader.shouldInterceptRequest(Uri.parse(url));
* }
* });
- *
+ * <p>
* WebSettings webViewSettings = webView.getSettings();
* // Setting this off for security. Off by default for SDK versions >= 16.
* webViewSettings.setAllowFileAccessFromFileURLs(false);
@@ -86,7 +85,7 @@
* // using file:// or content:// URLs.
* webViewSettings.setAllowFileAccess(false);
* webViewSettings.setAllowContentAccess(false);
- *
+ * <p>
* // Assets are hosted under http(s)://appassets.androidplatform.net/assets/... .
* // If the application's assets are in the "main/assets" folder this will read the file
* // from "main/assets/www/index.html" and load it as if it were hosted on:
@@ -149,7 +148,7 @@
* Handler class to open a file from assets directory in the application APK.
*/
public static final class AssetsPathHandler implements PathHandler {
- private AssetHelper mAssetHelper;
+ private final AssetHelper mAssetHelper;
/**
* @param context {@link Context} used to resolve assets.
@@ -200,7 +199,7 @@
* Handler class to open a file from resources directory in the application APK.
*/
public static final class ResourcesPathHandler implements PathHandler {
- private AssetHelper mAssetHelper;
+ private final AssetHelper mAssetHelper;
/**
* @param context {@link Context} used to resolve resources.
@@ -427,7 +426,7 @@
/**
* Match against registered scheme, authority and path prefix.
- *
+ * <p>
* Match happens when:
* <ul>
* <li>Scheme is "https" <b>or</b> the scheme is "http" and http is enabled.</li>
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java
index 1210b3c..8a452e2 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java
@@ -30,7 +30,6 @@
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
-import androidx.webkit.internal.ApiHelperForLollipop;
import androidx.webkit.internal.SafeBrowsingResponseImpl;
import androidx.webkit.internal.WebResourceErrorImpl;
import androidx.webkit.internal.WebViewFeatureInternal;
@@ -45,10 +44,6 @@
/**
* Compatibility version of {@link android.webkit.WebViewClient}.
*/
-// Note: some methods are marked as RequiresApi 21, because only an up-to-date WebView APK would
-// ever invoke these methods (and WebView can only be updated on Lollipop and above). The app can
-// still construct a WebViewClientCompat on a pre-Lollipop devices, and explicitly invoke these
-// methods, so each of these methods must also handle this case.
@SuppressWarnings("HiddenSuperclass")
public class WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface {
private static final String[] sSupportedFeatures = new String[] {
@@ -126,7 +121,6 @@
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
@Override
- @RequiresApi(21)
public final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
/* WebResourceError */ @NonNull InvocationHandler handler) {
onReceivedError(view, request, new WebResourceErrorImpl(handler));
@@ -140,10 +134,10 @@
* #onReceivedError(WebView, WebResourceRequest, WebResourceErrorCompat)} method.
*/
@Override
- @RequiresApi(23)
+ @RequiresApi(Build.VERSION_CODES.M)
public final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
@NonNull WebResourceError error) {
- if (Build.VERSION.SDK_INT < 23) return;
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
onReceivedError(view, request, new WebResourceErrorImpl(error));
}
@@ -162,21 +156,19 @@
* @param error Information about the error occurred.
*/
@SuppressWarnings("deprecation") // for invoking the old onReceivedError.
- @RequiresApi(21)
@UiThread
public void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
@NonNull WebResourceErrorCompat error) {
- if (Build.VERSION.SDK_INT < 21) return;
if (!WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_ERROR_GET_CODE)
|| !WebViewFeature.isFeatureSupported(
WebViewFeature.WEB_RESOURCE_ERROR_GET_DESCRIPTION)) {
// If the WebView APK drops supports for these APIs in the future, simply do nothing.
return;
}
- if (ApiHelperForLollipop.isForMainFrame(request)) {
+ if (request.isForMainFrame()) {
onReceivedError(view,
error.getErrorCode(), error.getDescription().toString(),
- ApiHelperForLollipop.getUrl(request).toString());
+ request.getUrl().toString());
}
}
@@ -223,7 +215,7 @@
* #onSafeBrowsingHit(WebView, WebResourceRequest, int, SafeBrowsingResponseCompat)} method.
*/
@Override
- @RequiresApi(27)
+ @RequiresApi(Build.VERSION_CODES.O_MR1)
public final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
@SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponse response) {
onSafeBrowsingHit(view, request, threatType, new SafeBrowsingResponseImpl(response));
@@ -231,10 +223,10 @@
/**
* Notify the host application that a loading URL has been flagged by Safe Browsing.
- *
+ * <p>
* The application must invoke the callback to indicate the preferred response. The default
* behavior is to show an interstitial to the user, with the reporting checkbox visible.
- *
+ * <p>
* If the application needs to show its own custom interstitial UI, the callback can be invoked
* asynchronously with {@link SafeBrowsingResponseCompat#backToSafety} or {@link
* SafeBrowsingResponseCompat#proceed}, depending on user response.
@@ -287,12 +279,10 @@
*/
@Override
@SuppressWarnings("deprecation") // for invoking the old shouldOverrideUrlLoading.
- @RequiresApi(21)
@UiThread
public boolean shouldOverrideUrlLoading(@NonNull WebView view,
@NonNull WebResourceRequest request) {
- if (Build.VERSION.SDK_INT < 21) return false;
- return shouldOverrideUrlLoading(view, ApiHelperForLollipop.getUrl(request).toString());
+ return shouldOverrideUrlLoading(view, request.getUrl().toString());
}
/**
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java
index de2c728..4096f1f 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java
@@ -345,12 +345,6 @@
// this feature is not dependent on the WebView APK.
@Nullable
public static PackageInfo getCurrentWebViewPackage(@NonNull Context context) {
- // There was no WebView Package before Lollipop, the WebView code was part of the framework
- // back then.
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- return null;
- }
-
PackageInfo info = getCurrentLoadedWebViewPackage();
if (info != null) return info;
@@ -367,19 +361,13 @@
@Nullable
@RestrictTo(RestrictTo.Scope.LIBRARY)
public static PackageInfo getCurrentLoadedWebViewPackage() {
- // There was no WebView Package before Lollipop, the WebView code was part of the framework
- // back then.
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- return null;
- }
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return ApiHelperForO.getCurrentWebViewPackage();
} else { // L-N
try {
return getLoadedWebViewPackageInfo();
} catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException
- | NoSuchMethodException e) {
+ | NoSuchMethodException ignored) {
}
}
return null;
@@ -407,8 +395,7 @@
private static PackageInfo getNotYetLoadedWebViewPackageInfo(Context context) {
String webviewPackageName;
try {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
- && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
Class<?> webViewFactoryClass = Class.forName("android.webkit.WebViewFactory");
webviewPackageName = (String) webViewFactoryClass.getMethod(
@@ -419,13 +406,8 @@
webviewPackageName = (String) webviewUpdateServiceClass.getMethod(
"getCurrentWebViewPackageName").invoke(null);
}
- } catch (ClassNotFoundException e) {
- return null;
- } catch (IllegalAccessException e) {
- return null;
- } catch (InvocationTargetException e) {
- return null;
- } catch (NoSuchMethodException e) {
+ } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException
+ | NoSuchMethodException e) {
return null;
}
if (webviewPackageName == null) return null;
@@ -543,7 +525,7 @@
*
* <table>
* <tr><th>Rule</th><th>Description</th><th>Example</th></tr>
- *
+ * <p>
* <tr>
* <td>http/https with hostname</td>
* <td>{@code SCHEME} is http or https; {@code HOSTNAME_PATTERN} is a regular hostname; {@code
@@ -556,7 +538,7 @@
* is www.example.com.</li>
* </ul></td>
* </tr>
- *
+ * <p>
* <tr>
* <td>http/https with pattern matching</td>
* <td>{@code SCHEME} is http or https; {@code HOSTNAME_PATTERN} is a sub-domain matching
@@ -569,7 +551,7 @@
* <li>{@code https://*.example.com:8080} - Matches https://calendar.example.com:8080</li>
* </ul></td>
* </tr>
- *
+ * <p>
* <tr>
* <td>http/https with IP literal</td>
* <td>{@code SCHEME} is https or https; {@code HOSTNAME_PATTERN} is IP literal; {@code PORT} is
@@ -584,7 +566,7 @@
* <li>{@code https://[::1]:99} - Matches any https:// URL to the IPv6 loopback on port 99.</li>
* </ul></td>
* </tr>
- *
+ * <p>
* <tr>
* <td>Custom scheme</td>
* <td>{@code SCHEME} is a custom scheme; {@code HOSTNAME_PATTERN} and {@code PORT} must not be
@@ -593,7 +575,7 @@
* <li>{@code my-app-scheme://} - Matches any my-app-scheme:// URL.</li>
* </ul></td>
* </tr>
- *
+ * <p>
* <tr><td>{@code *}</td>
* <td>Wildcard rule, matches any origin.</td>
* <td><ul><li>{@code *}</li></ul></td>
@@ -619,18 +601,18 @@
* // message needs to be a JavaScript String or ArrayBuffer, MessagePorts is an optional
* // parameter.
* myObject.postMessage(message[, MessagePorts])
- *
+ * <p>
* // To receive messages posted from the app side, assign a function to the "onmessage"
* // property. This function should accept a single "event" argument. "event" has a "data"
* // property, which is the message String or ArrayBuffer from the app side.
* myObject.onmessage = function(event) { ... }
- *
+ * <p>
* // To be compatible with DOM EventTarget's addEventListener, it accepts type and listener
* // parameters, where type can be only "message" type and listener can only be a JavaScript
* // function for myObject. An event object will be passed to listener with a "data" property,
* // which is the message String or ArrayBuffer from the app side.
* myObject.addEventListener(type, listener)
- *
+ * <p>
* // To be compatible with DOM EventTarget's removeEventListener, it accepts type and listener
* // parameters, where type can be only "message" type and listener can only be a JavaScript
* // function for myObject.
@@ -1058,10 +1040,11 @@
* <p>The app is responsible for adding the X-Client-Data header to any request that may use
* variations metadata, such as requests to Google web properties. The returned string will be a
* base64 encoded ClientVariations proto:
- * https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/client_variations.proto
+ * <a href="https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/client_variations.proto">
+ * https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/client_variations.proto</a>
*
* @return the variations header. The string may be empty if the header is not available.
- * @see WebView#loadUrl(String, java.util.Map<String, String>)
+ * @see WebView#loadUrl(String, java.util.Map)
*/
@RequiresFeature(
name = WebViewFeature.GET_VARIATIONS_HEADER,
@@ -1151,10 +1134,10 @@
}
/**
- * Mute or unmute this WebView.
+ * Mute or un-mute this WebView.
*
* @param webView the WebView for which to control muting.
- * @param mute true to mute the WebView; false to unmute the WebView.
+ * @param mute true to mute the WebView; false to un-mute the WebView.
*/
@RequiresFeature(name = WebViewFeature.MUTE_AUDIO,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@@ -1178,7 +1161,7 @@
@SuppressWarnings({"JavaReflectionMemberAccess", "PrivateApi"})
private static void checkThread(WebView webview) {
- if (Build.VERSION.SDK_INT >= 28) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Looper webViewLooper = ApiHelperForP.getWebViewLooper(webview);
if (webViewLooper != Looper.myLooper()) {
throw new RuntimeException("A WebView method was called on thread '"
@@ -1195,11 +1178,7 @@
// WebView.checkThread() performs some logging and potentially throws an exception
// if WebView is used on the wrong thread.
checkThreadMethod.invoke(webview);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java
index 58b768c..2f0cef2 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java
@@ -597,14 +597,12 @@
public static final String WEB_AUTHENTICATION = "WEB_AUTHENTICATION";
/**
- * Return whether a feature is supported at run-time. On devices running Android version {@link
- * android.os.Build.VERSION_CODES#LOLLIPOP} and higher, this will check whether a feature is
+ * Return whether a feature is supported at run-time. This will check whether a feature is
* supported, depending on the combination of the desired feature, the Android version of
- * device, and the WebView APK on the device. If running on a device with a lower API level,
- * this will always return {@code false}.
+ * device, and the WebView APK on the device.
*
* <p class="note"><b>Note:</b> This method is different from
- * {@link #isStartupFeatureSupported(String, Context)} and this method only accepts
+ * {@link WebViewFeature#isStartupFeatureSupported(Context, String)} and this method only accepts
* certain features. Please verify that the correct feature checking method is used for a
* particular feature.
*
@@ -613,20 +611,17 @@
* for a particular feature, any callback guarded by that feature will not be invoked.
*
* @param feature the feature to be checked
- * @return whether the feature is supported given the current platform SDK and webview version
+ * @return whether the feature is supported given the current platform SDK and WebView version
*/
public static boolean isFeatureSupported(@NonNull @WebViewSupportFeature String feature) {
return WebViewFeatureInternal.isSupported(feature);
}
/**
- * Return whether a startup feature is supported at run-time. On devices running Android
- * version {@link
- * android.os.Build.VERSION_CODES#LOLLIPOP} and higher, this will check whether a startup
+ * Return whether a startup feature is supported at run-time. This will check whether a startup
* feature is
* supported, depending on the combination of the desired feature, the Android version of
- * device, and the WebView APK on the device. If running on a device with a lower API level,
- * this will always return {@code false}.
+ * device, and the WebView APK on the device.
*
* <p class="note"><b>Note:</b> This method is different from
* {@link #isFeatureSupported(String)} and this method only accepts startup features. Please
@@ -638,7 +633,7 @@
*
* @param context a Context to access application assets This value cannot be null.
* @param startupFeature the startup feature to be checked
- * @return whether the feature is supported given the current platform SDK and webview version
+ * @return whether the feature is supported given the current platform SDK and WebView version
*/
public static boolean isStartupFeatureSupported(@NonNull Context context,
@NonNull @WebViewStartupFeature String startupFeature) {
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java
index 817aa01..110e7bd 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java
@@ -78,8 +78,8 @@
public static final int WEBVIEW_MEDIA_INTEGRITY_API_DISABLED =
WebSettingsBoundaryInterface.WebViewMediaIntegrityApiStatus.DISABLED;
- private @WebViewMediaIntegrityApiStatus int mDefaultStatus;
- private Map<String, @WebViewMediaIntegrityApiStatus Integer> mOverrideRules;
+ private final @WebViewMediaIntegrityApiStatus int mDefaultStatus;
+ private final Map<String, @WebViewMediaIntegrityApiStatus Integer> mOverrideRules;
public WebViewMediaIntegrityApiStatusConfig(@NonNull Builder builder) {
this.mDefaultStatus = builder.mDefaultStatus;
@@ -101,7 +101,7 @@
* </pre>
*/
public static final class Builder {
- private @WebViewMediaIntegrityApiStatus int mDefaultStatus;
+ private final @WebViewMediaIntegrityApiStatus int mDefaultStatus;
private Map<String, @WebViewMediaIntegrityApiStatus Integer> mOverrideRules;
/**
@@ -133,10 +133,10 @@
/**
* Set all required override rules at once using a map of origin patterns to
* desired API statuses. This overwrites existing rules.
- *
+ * <p>
* If two or more origin patterns match a given origin site, the least permissive option
* will be chosen.
- *
+ * <p>
* This is only meant for internal use within the library.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java
index 0344066..0c8d80d 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java
@@ -23,11 +23,12 @@
/**
* Used to receive callbacks on {@link WebView} renderer events.
- *
+ * <p>
* WebViewRenderProcessClient instances may be set or retrieved via {@link
- * WebViewCompat#setWebViewRenderProcessClient(WebView,Executor,WebViewRenderProcessClient)}
+ * WebViewCompat#setWebViewRenderProcessClient(WebView, java.util.concurrent.Executor,
+ * WebViewRenderProcessClient)}
* and {@link WebViewCompat#getWebViewRenderProcessClient(WebView)}.
- *
+ * <p>
* Instances may be attached to multiple WebViews, and thus a single renderer event may cause
* a callback to be called multiple times with different WebView parameters.
*/
@@ -50,7 +51,7 @@
*
* <p>No action is taken by WebView as a result of this method call. Applications may
* choose to terminate the associated renderer via the object that is passed to this callback,
- * if in multiprocess mode, however this must be accompanied by correctly handling
+ * if in multi-process mode, however this must be accompanied by correctly handling
* {@link android.webkit.WebViewClient#onRenderProcessGone} for this WebView, and all other
* WebViews associated with the same renderer. Failure to do so will result in application
* termination.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java
index 1a15645..d467ac5 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java
@@ -18,7 +18,6 @@
import android.os.Build;
-import androidx.annotation.ChecksSdkIntAtLeast;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -30,17 +29,17 @@
import java.util.Set;
/**
- * Enum-like class to represent features that are supported by the AndroidX webview API.
- *
+ * Enum-like class to represent features that are supported by the AndroidX WebView API.
+ * <p>
* Features that have framework support should be represented by the appropriate subclass
* matching the SDK version where the feature became available, which allows static analysis to
* verify that calling the feature is safe through the {@link #isSupportedByFramework()} method.
- *
+ * <p>
* To gain this benefit, variables containing {@link ApiFeature} should always be declared as the
* specific subtype.
- *
+ * <p>
* To add support for a new API version, add a new subclass representing the desired API level.
- *
+ * <p>
* This class should only be instantiated as constants in {@link WebViewFeatureInternal} and is
* meant to act as enum values for that class.
*/
@@ -82,12 +81,7 @@
/**
* Return whether this {@link ApiFeature} is supported by the current WebView APK.
- *
- * <p>WebView updates were only supported starting in Android L and the preinstalled WebView in
- * earlier OS versions is not compatible with this library. If this returns true, then that
- * implies we're on Android L or above.
*/
- @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
public boolean isSupportedByWebView() {
return BoundaryInterfaceReflectionUtil.containsFeature(LAZY_HOLDER.WEBVIEW_APK_FEATURES,
mInternalFeatureValue);
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForLollipop.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForLollipop.java
deleted file mode 100644
index 6a77a82..0000000
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForLollipop.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2022 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 androidx.webkit.internal;
-
-import android.net.Uri;
-import android.os.Build;
-import android.webkit.WebResourceRequest;
-
-import androidx.annotation.DoNotInline;
-import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
-
-/**
- * Utility class to use new APIs that were added in Lollipop (API level 21).
- * These need to exist in a separate class so that Android framework can successfully verify
- * classes without encountering the new APIs.
- */
-@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
-public class ApiHelperForLollipop {
- private ApiHelperForLollipop() {
- }
-
- /**
- * @see WebResourceRequest#isForMainFrame()
- */
- @DoNotInline
- public static boolean isForMainFrame(@NonNull WebResourceRequest webResourceRequest) {
- return webResourceRequest.isForMainFrame();
- }
-
- /**
- * @see WebResourceRequest#getUrl()
- */
- @DoNotInline
- @NonNull
- public static Uri getUrl(@NonNull WebResourceRequest webResourceRequest) {
- return webResourceRequest.getUrl();
- }
-}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java b/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java
index 6a09ee4..8f582559 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java
@@ -35,7 +35,7 @@
/**
* A Utility class for opening resources, assets and files for
* {@link androidx.webkit.WebViewAssetLoader}.
- * Forked from the chromuim project org.chromium.android_webview.AndroidProtocolHandler
+ * Forked from the chromium project org.chromium.android_webview.AndroidProtocolHandler
*/
public class AssetHelper {
@@ -44,7 +44,7 @@
*/
public static final String DEFAULT_MIME_TYPE = "text/plain";
- @NonNull private Context mContext;
+ @NonNull private final Context mContext;
public AssetHelper(@NonNull Context context) {
this.mContext = context;
@@ -66,8 +66,7 @@
private int getFieldId(@NonNull String resourceType, @NonNull String resourceName) {
String packageName = mContext.getPackageName();
- int id = mContext.getResources().getIdentifier(resourceName, resourceType, packageName);
- return id;
+ return mContext.getResources().getIdentifier(resourceName, resourceType, packageName);
}
private int getValueType(int fieldId) {
@@ -137,7 +136,7 @@
/**
* Resolves the given relative child string path against the given parent directory.
- *
+ * <p>
* It resolves the given child path and creates a {@link File} object using the canonical path
* of that file if its canonical path starts with the canonical path of the parent directory.
*
@@ -160,7 +159,7 @@
/**
* Returns the canonical path for the given directory with a {@code "/"} at the end if doesn't
* have one.
- *
+ * <p>
* Having a slash {@code "/"} at the end of a directory path is important when checking if a
* directory is a parent of another child directory or a file.
* E.g: the directory {@code "/some/path/to"} is not a parent of "/some/path/to_file". However,
@@ -192,10 +191,10 @@
/**
* Use {@link MimeUtil#getMimeFromFileName} to guess MIME type or return the
- * {@link DEFAULT_MIME_TYPE} if it can't guess.
+ * {@link AssetHelper#DEFAULT_MIME_TYPE} if it can't guess.
*
* @param filePath path of the file to guess its MIME type.
- * @return MIME type guessed from file extension or {@link DEFAULT_MIME_TYPE}.
+ * @return MIME type guessed from file extension or {@link AssetHelper#DEFAULT_MIME_TYPE}.
*/
@NonNull
public static String guessMimeType(@NonNull String filePath) {
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java
index 2ca4c03..e3793f4 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java
@@ -24,13 +24,12 @@
import java.lang.reflect.InvocationHandler;
import java.util.Objects;
-import java.util.concurrent.Callable;
/**
* Internal implementation of {@link androidx.webkit.JavaScriptReplyProxy}.
*/
public class JavaScriptReplyProxyImpl extends JavaScriptReplyProxy {
- private JsReplyProxyBoundaryInterface mBoundaryInterface;
+ private final JsReplyProxyBoundaryInterface mBoundaryInterface;
public JavaScriptReplyProxyImpl(@NonNull JsReplyProxyBoundaryInterface boundaryInterface) {
mBoundaryInterface = boundaryInterface;
@@ -46,12 +45,7 @@
BoundaryInterfaceReflectionUtil.castToSuppLibClass(
JsReplyProxyBoundaryInterface.class, invocationHandler);
return (JavaScriptReplyProxyImpl) boundaryInterface.getOrCreatePeer(
- new Callable<Object>() {
- @Override
- public Object call() {
- return new JavaScriptReplyProxyImpl(boundaryInterface);
- }
- });
+ () -> new JavaScriptReplyProxyImpl(boundaryInterface));
}
@Override
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java b/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java
index 4aeafa3..85a81f5 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java
@@ -24,7 +24,6 @@
import android.os.Build;
import android.os.Bundle;
-import androidx.annotation.ChecksSdkIntAtLeast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
@@ -35,20 +34,20 @@
import java.util.Set;
/**
- * Enum-like class to represent startup features that are supported by the AndroidX webview API.
- *
+ * Enum-like class to represent startup features that are supported by the AndroidX WebView API.
+ * <p>
* Features that have framework support should be represented by the appropriate subclass
* matching the SDK version where the feature became available, which allows static analysis to
* verify that calling the feature is safe through the {@link #isSupportedByFramework()} method.
- *
+ * <p>
* To gain this benefit, variables containing {@link StartupApiFeature} should always be declared as
* the specific subtype.
- *
+ * <p>
* To add support for a new API version, add a new subclass representing the desired API level.
- *
+ * <p>
* This class should only be instantiated as constants in {@link WebViewFeatureInternal} and is
* meant to act as enum values for that class.
- *
+ * <p>
* Startup API feature checks if a feature is supported in WebView by looking for metadata entries
* in the WebView manifest. Calling this method does not lead to WebView being loaded into the
* calling process.
@@ -98,15 +97,10 @@
/**
* Return whether this {@link StartupApiFeature} is supported by the current WebView APK.
*
- * <p>WebView updates were only supported starting in Android L and the preinstalled WebView in
- * earlier OS versions is not compatible with this library. If this returns true, then that
- * implies we're on Android L or above.
- *
* <p>It checks if a feature is supported in WebView by looking for metadata entries
* in the WebView manifest. Calling this method does not lead to WebView being loaded into the
* calling process.
*/
- @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
public boolean isSupportedByWebView(@NonNull Context context) {
Bundle bundle = getMetaDataFromWebViewManifestOrNull(context);
if (bundle == null) {
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java
index 4c0492b..050e123 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java
@@ -37,7 +37,7 @@
* This class is used to pass a PostMessage from the app to Chromium.
*/
public class WebMessageAdapter implements WebMessageBoundaryInterface {
- private WebMessageCompat mWebMessageCompat;
+ private final WebMessageCompat mWebMessageCompat;
private static final String[] sFeatures = {Features.WEB_MESSAGE_ARRAY_BUFFER};
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java
index 062fc21..701f316 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java
@@ -36,7 +36,7 @@
* corresponding interface shared with the support library glue in the WebView APK).
*/
public class WebMessageListenerAdapter implements WebMessageListenerBoundaryInterface {
- private WebViewCompat.WebMessageListener mWebMessageListener;
+ private final WebViewCompat.WebMessageListener mWebMessageListener;
public WebMessageListenerAdapter(@NonNull WebViewCompat.WebMessageListener webMessageListener) {
mWebMessageListener = webMessageListener;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java
index ba0431a..124f24b 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java
@@ -42,7 +42,6 @@
import androidx.webkit.WebMessagePortCompat;
import androidx.webkit.WebResourceErrorCompat;
import androidx.webkit.WebResourceRequestCompat;
-import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewClientCompat;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
@@ -106,12 +105,12 @@
Features.START_SAFE_BROWSING);
/**
- * This feature covers {@link androidx.webkit.WebViewCompat#setSafeBrowsingWhitelist(Set,
- * ValueCallback)}, plumbing through the deprecated boundary interface.
+ * This feature covers {@link androidx.webkit.WebViewCompat#setSafeBrowsingWhitelist(
+ * java.util.List, ValueCallback)}, plumbing through the deprecated boundary interface.
*
- * <p>Don't use this value directly. This exists only so {@link WebViewFeature#isSupported}
- * supports the <b>deprecated</b> public feature when running against <b>old</b> WebView
- * versions.
+ * <p>Don't use this value directly. This exists only so
+ * {@link WebViewFeatureInternal#isSupported(String)} supports the <b>deprecated</b> public
+ * feature when running against <b>old</b> WebView versions.
*
* @deprecated use {@link #SAFE_BROWSING_ALLOWLIST_PREFERRED_TO_DEPRECATED} to test for the
* <b>old</b> boundary interface
@@ -122,12 +121,12 @@
Features.SAFE_BROWSING_WHITELIST);
/**
- * This feature covers {@link androidx.webkit.WebViewCompat#setSafeBrowsingWhitelist(Set,
- * ValueCallback)}, plumbing through the new boundary interface.
+ * This feature covers {@link androidx.webkit.WebViewCompat#setSafeBrowsingWhitelist(
+ * java.util.List, ValueCallback)}, plumbing through the new boundary interface.
*
- * <p>Don't use this value directly. This exists only so {@link WebViewFeature#isSupported}
- * supports the <b>deprecated</b> public feature when running against <b>new</b> WebView
- * versions.
+ * <p>Don't use this value directly. This exists only so
+ * {@link WebViewFeatureInternal#isSupported(String)} supports the <b>deprecated</b> public
+ * feature when running against <b>new</b> WebView versions.
*
* @deprecated use {@link #SAFE_BROWSING_ALLOWLIST_PREFERRED_TO_PREFERRED} to test for the
* <b>new</b> boundary interface.
@@ -402,10 +401,10 @@
/**
* This feature covers
- * {@link WebViewCompat#getWebViewRenderProcessClient()},
- * {@link WebViewCompat#setWebViewRenderProcessClient(WebViewRenderProcessClient)},
- * {@link WebViewRenderProcessClient#onRenderProcessUnresponsive(WebView, WebViewRenderProcess)},
- * {@link WebViewRenderProcessClient#onRenderProcessResponsive(WebView, WebViewRenderProcess)}
+ * {@link WebViewCompat#getWebViewRenderProcessClient(android.webkit.WebView)},
+ * {@link WebViewCompat#setWebViewRenderProcessClient(WebView, androidx.webkit.WebViewRenderProcessClient)},
+ * {@link android.webkit.WebViewRenderProcessClient#onRenderProcessUnresponsive(WebView, android.webkit.WebViewRenderProcess)},
+ * {@link android.webkit.WebViewRenderProcessClient#onRenderProcessResponsive(WebView, android.webkit.WebViewRenderProcess)}
*/
public static final ApiFeature.Q WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE =
new ApiFeature.Q(WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE,
@@ -438,10 +437,8 @@
/**
* This feature covers
- * {@link ProxyController#setProxyOverride(ProxyConfig, Executor, Runnable)},
- * {@link ProxyController#setProxyOverride(ProxyConfig, Runnable)},
- * {@link ProxyController#clearProxyOverride(Executor, Runnable)}, and
- * {@link ProxyController#clearProxyOverride(Runnable)}.
+ * {@link ProxyController#setProxyOverride(ProxyConfig, Executor, Runnable)}, and
+ * {@link ProxyController#clearProxyOverride(Executor, Runnable)}.
*/
public static final ApiFeature.NoFramework PROXY_OVERRIDE = new ApiFeature.NoFramework(
WebViewFeature.PROXY_OVERRIDE, Features.PROXY_OVERRIDE);
@@ -472,9 +469,8 @@
/**
* This feature covers
- * {@link androidx.webkit.WebViewCompat#setWebMessageListener(android.webkit.WebView,
- * androidx.webkit.WebViewCompat.WebMessageListener, String, String[])} and
- * {@link androidx.webkit.WebViewCompat#removeWebMessageListener()}
+ * {@link androidx.webkit.WebViewCompat#addWebMessageListener(WebView, String, Set, WebViewCompat.WebMessageListener)} and
+ * {@link androidx.webkit.WebViewCompat#removeWebMessageListener(WebView, String)}
*/
public static final ApiFeature.NoFramework WEB_MESSAGE_LISTENER =
new ApiFeature.NoFramework(WebViewFeature.WEB_MESSAGE_LISTENER,
@@ -491,7 +487,8 @@
Features.DOCUMENT_START_SCRIPT);
/**
- * This feature covers {@link androidx.webkit.ProxyConfig.Builder.setReverseBypass(boolean)}
+ * This feature covers {@link
+ * androidx.webkit.ProxyConfig.Builder#setReverseBypassEnabled(boolean)}
*/
public static final ApiFeature.NoFramework PROXY_OVERRIDE_REVERSE_BYPASS =
new ApiFeature.NoFramework(WebViewFeature.PROXY_OVERRIDE_REVERSE_BYPASS,
@@ -516,13 +513,12 @@
/**
* This feature covers
- * {@link androidx.webkit.CookieManager#getCookieInfo(CookieManager, String)}.
+ * {@link androidx.webkit.CookieManagerCompat#getCookieInfo(android.webkit.CookieManager, String)}.
*/
public static final ApiFeature.NoFramework GET_COOKIE_INFO =
new ApiFeature.NoFramework(WebViewFeature.GET_COOKIE_INFO, Features.GET_COOKIE_INFO);
/**
- * Feature for {@link #isFeatureSupported(String)}.
* This feature covers
* {@link androidx.webkit.WebSettingsCompat#getRequestedWithHeaderOriginAllowList(WebSettings)],
* {@link androidx.webkit.WebSettingsCompat#setRequestedWithHeaderAllowList(WebSettings, Set)},
@@ -536,7 +532,7 @@
/**
* This feature covers
- * {@link androidx.webkit.WebSettingsCompat#setUserAgentMetadata(WebSettings, UserAgentMetadata)} and
+ * {@link androidx.webkit.WebSettingsCompat#setUserAgentMetadata(WebSettings, androidx.webkit.UserAgentMetadata)} and
* {@link androidx.webkit.WebSettingsCompat#getUserAgentMetadata(WebSettings)}.
*
*/
@@ -545,7 +541,6 @@
Features.USER_AGENT_METADATA);
/**
- * Feature for {@link #isFeatureSupported(String)}.
* This feature covers
* {@link Profile#getName()}.
* {@link Profile#getWebStorage()}.
@@ -586,7 +581,7 @@
/**
* Feature for {@link WebViewFeature#isFeatureSupported(String)}.
* This feature covers
- * {@link androidx.webkit.WebSettingsCompat#setWebViewMediaIntegrityApiStatus(WebSettings, WebSettingsCompat.WebViewMediaIntegrityApiStatusConfig)}
+ * {@link androidx.webkit.WebSettingsCompat#setWebViewMediaIntegrityApiStatus(WebSettings, androidx.webkit.WebViewMediaIntegrityApiStatusConfig)}
* {@link androidx.webkit.WebSettingsCompat#getWebViewMediaIntegrityApiStatus(WebSettings)}
*/
public static final ApiFeature.NoFramework WEBVIEW_MEDIA_INTEGRITY_API_STATUS =
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java
index 52c9dd5..bb08259 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java
@@ -72,26 +72,18 @@
@SuppressWarnings("WeakerAccess") /* synthetic access */
@NonNull
static WebViewProviderFactory createGlueProviderFactory() {
- // We do not support pre-L devices since their WebView APKs cannot be updated.
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- return new IncompatibleApkWebViewProviderFactory();
- }
InvocationHandler invocationHandler;
try {
invocationHandler = fetchGlueProviderFactoryImpl();
// The only way we should fail to fetch the provider-factory is if the class we are
// calling into doesn't exist - any other kind of failure is unexpected and should cause
// a run-time exception.
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
// If WebView APK support library glue entry point doesn't exist then return a Provider
// factory that declares that there are no features available.
return new IncompatibleApkWebViewProviderFactory();
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
}
return new WebViewProviderFactoryAdapter(BoundaryInterfaceReflectionUtil.castToSuppLibClass(
WebViewProviderFactoryBoundaryInterface.class, invocationHandler));
@@ -115,11 +107,7 @@
Method getFactoryMethod = WebView.class.getDeclaredMethod("getFactory");
getFactoryMethod.setAccessible(true);
return getFactoryMethod.invoke(null);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
index 7475666..74666b1 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
@@ -45,7 +45,7 @@
*/
@SuppressWarnings("JavadocReference") // WebViewProvider is hidden.
public class WebViewProviderAdapter {
- WebViewProviderBoundaryInterface mImpl;
+ final WebViewProviderBoundaryInterface mImpl;
public WebViewProviderAdapter(@NonNull WebViewProviderBoundaryInterface impl) {
mImpl = impl;
@@ -85,7 +85,7 @@
/**
* Adapter method for {@link WebViewCompat#addWebMessageListener(android.webkit.WebView,
- * String, List<String>, androidx.webkit.WebViewCompat.WebMessageListener)}.
+ * String, java.util.List, androidx.webkit.WebViewCompat.WebMessageListener)}.
*/
public void addWebMessageListener(@NonNull String jsObjectName,
@NonNull String[] allowedOriginRules,
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java
index a48b47e..556f527 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java
@@ -80,12 +80,7 @@
if (mExecutor == null) {
client.onRenderProcessUnresponsive(view, rendererObject);
} else {
- mExecutor.execute(new Runnable() {
- @Override
- public void run() {
- client.onRenderProcessUnresponsive(view, rendererObject);
- }
- });
+ mExecutor.execute(() -> client.onRenderProcessUnresponsive(view, rendererObject));
}
}
@@ -103,12 +98,7 @@
if (mExecutor == null) {
client.onRenderProcessResponsive(view, rendererObject);
} else {
- mExecutor.execute(new Runnable() {
- @Override
- public void run() {
- client.onRenderProcessResponsive(view, rendererObject);
- }
- });
+ mExecutor.execute(() -> client.onRenderProcessResponsive(view, rendererObject));
}
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java
index 936275a..d0e5b1c 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java
@@ -29,7 +29,7 @@
@RequiresApi(29)
public class WebViewRenderProcessClientFrameworkAdapter extends
android.webkit.WebViewRenderProcessClient {
- private WebViewRenderProcessClient mWebViewRenderProcessClient;
+ private final WebViewRenderProcessClient mWebViewRenderProcessClient;
public WebViewRenderProcessClientFrameworkAdapter(@NonNull WebViewRenderProcessClient client) {
mWebViewRenderProcessClient = client;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java
index 92d2aa7..c6ebe8f 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java
@@ -25,7 +25,6 @@
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
import java.util.WeakHashMap;
-import java.util.concurrent.Callable;
/**
* Implementation of {@link WebViewRenderProcess}.
@@ -48,7 +47,7 @@
}
/**
- * Get a support library WebViewRenderProcess object that is 1:1 with the webview object.
+ * Get a support library WebViewRenderProcess object that is 1:1 with the WebView object.
*/
public static @NonNull WebViewRenderProcessImpl forInvocationHandler(
@NonNull InvocationHandler invocationHandler) {
@@ -61,12 +60,7 @@
// Ask WebView to either call us back to create the wrapper object, or
// to return a previously created wrapper object.
return (WebViewRenderProcessImpl) boundaryInterface.getOrCreatePeer(
- new Callable<Object>() {
- @Override
- public Object call() {
- return new WebViewRenderProcessImpl(boundaryInterface);
- }
- });
+ () -> new WebViewRenderProcessImpl(boundaryInterface));
}
/**