summaryrefslogtreecommitdiff
path: root/logcat
diff options
context:
space:
mode:
authorAlon Albert <aalbert@google.com>2022-06-23 13:26:17 -0700
committerTreeHugger Robot <treehugger-gerrit@google.com>2022-06-23 22:10:14 +0000
commit61ffa3c8c13bfbf361201e1bce3c96289b4616d2 (patch)
tree9c9c455a41bb22d192f20da022cb1a678b54fc4e /logcat
parent3b7b7657ead1dfa20a0d52cf24458725c7a097c1 (diff)
downloadidea-61ffa3c8c13bfbf361201e1bce3c96289b4616d2.tar.gz
Use Property Names From DevicePropertyNames
Bug: n/a Test: Existing Change-Id: Ie8281e3dd0348767a916d7df8f1eb5a7d59bc4b2
Diffstat (limited to 'logcat')
-rw-r--r--logcat/src/com/android/tools/idea/logcat/LogcatPanelConfig.kt16
-rw-r--r--logcat/src/com/android/tools/idea/logcat/actions/screenrecord/ScreenRecordingSupportedCacheImpl.kt3
-rw-r--r--logcat/src/com/android/tools/idea/logcat/devices/DeviceComboBoxDeviceTracker.kt39
-rw-r--r--logcat/testSrc/com/android/tools/idea/logcat/testing/TestDevice.kt47
4 files changed, 54 insertions, 51 deletions
diff --git a/logcat/src/com/android/tools/idea/logcat/LogcatPanelConfig.kt b/logcat/src/com/android/tools/idea/logcat/LogcatPanelConfig.kt
index 4054358949f..fa2399e75df 100644
--- a/logcat/src/com/android/tools/idea/logcat/LogcatPanelConfig.kt
+++ b/logcat/src/com/android/tools/idea/logcat/LogcatPanelConfig.kt
@@ -15,6 +15,10 @@
*/
package com.android.tools.idea.logcat
+import com.android.adblib.DevicePropertyNames.RO_BUILD_VERSION_RELEASE
+import com.android.adblib.DevicePropertyNames.RO_BUILD_VERSION_SDK
+import com.android.adblib.DevicePropertyNames.RO_PRODUCT_MANUFACTURER
+import com.android.adblib.DevicePropertyNames.RO_PRODUCT_MODEL
import com.android.tools.adtui.toolwindow.splittingtabs.SplittingTabsToolWindowFactory
import com.android.tools.idea.logcat.LogcatPanelConfig.FormattingConfig
import com.android.tools.idea.logcat.devices.Device
@@ -74,8 +78,8 @@ internal data class LogcatPanelConfig(
Device.createEmulator(
oldDevice.serialNumber,
isOnline = false,
- oldDevice.properties["ro.build.version.release"]?.toIntOrNull() ?: 0,
- oldDevice.properties["ro.build.version.sdk"]?.toIntOrNull() ?: 0,
+ oldDevice.properties[RO_BUILD_VERSION_RELEASE]?.toIntOrNull() ?: 0,
+ oldDevice.properties[RO_BUILD_VERSION_SDK]?.toIntOrNull() ?: 0,
oldDevice.avdName,
)
}
@@ -83,10 +87,10 @@ internal data class LogcatPanelConfig(
Device.createPhysical(
oldDevice.serialNumber,
isOnline = false,
- oldDevice.properties["ro.build.version.release"]?.toIntOrNull() ?: 0,
- oldDevice.properties["ro.build.version.sdk"]?.toIntOrNull() ?: 0,
- oldDevice.properties["ro.product.manufacturer"] ?: "",
- oldDevice.properties["ro.product.model"] ?: "",
+ oldDevice.properties[RO_BUILD_VERSION_RELEASE]?.toIntOrNull() ?: 0,
+ oldDevice.properties[RO_BUILD_VERSION_SDK]?.toIntOrNull() ?: 0,
+ oldDevice.properties[RO_PRODUCT_MANUFACTURER] ?: "",
+ oldDevice.properties[RO_PRODUCT_MODEL] ?: "",
)
}
diff --git a/logcat/src/com/android/tools/idea/logcat/actions/screenrecord/ScreenRecordingSupportedCacheImpl.kt b/logcat/src/com/android/tools/idea/logcat/actions/screenrecord/ScreenRecordingSupportedCacheImpl.kt
index 8f399f588d3..5773413f4c9 100644
--- a/logcat/src/com/android/tools/idea/logcat/actions/screenrecord/ScreenRecordingSupportedCacheImpl.kt
+++ b/logcat/src/com/android/tools/idea/logcat/actions/screenrecord/ScreenRecordingSupportedCacheImpl.kt
@@ -17,6 +17,7 @@ package com.android.tools.idea.logcat.actions.screenrecord
import com.android.adblib.AdbLibSession
import com.android.adblib.CoroutineScopeCache.Key
+import com.android.adblib.DevicePropertyNames.RO_BUILD_CHARACTERISTICS
import com.android.adblib.DeviceSelector
import com.android.adblib.deviceCache
import com.android.adblib.shellAsText
@@ -73,7 +74,7 @@ internal class ScreenRecordingSupportedCacheImpl(project: Project) : ScreenRecor
}
private suspend fun isWatch(serialNumber: String): Boolean {
- val out = execute(serialNumber, "getprop ro.build.characteristics")
+ val out = execute(serialNumber, "getprop $RO_BUILD_CHARACTERISTICS")
return out.trim().split(",").contains("watch")
}
diff --git a/logcat/src/com/android/tools/idea/logcat/devices/DeviceComboBoxDeviceTracker.kt b/logcat/src/com/android/tools/idea/logcat/devices/DeviceComboBoxDeviceTracker.kt
index bd821524bcd..44b12bd6c87 100644
--- a/logcat/src/com/android/tools/idea/logcat/devices/DeviceComboBoxDeviceTracker.kt
+++ b/logcat/src/com/android/tools/idea/logcat/devices/DeviceComboBoxDeviceTracker.kt
@@ -17,6 +17,12 @@ package com.android.tools.idea.logcat.devices
import com.android.adblib.AdbLibSession
import com.android.adblib.DeviceInfo
+import com.android.adblib.DevicePropertyNames.RO_BOOT_QEMU_AVD_NAME
+import com.android.adblib.DevicePropertyNames.RO_BUILD_VERSION_RELEASE
+import com.android.adblib.DevicePropertyNames.RO_BUILD_VERSION_SDK
+import com.android.adblib.DevicePropertyNames.RO_KERNEL_QEMU_AVD_NAME
+import com.android.adblib.DevicePropertyNames.RO_PRODUCT_MANUFACTURER
+import com.android.adblib.DevicePropertyNames.RO_PRODUCT_MODEL
import com.android.adblib.DeviceSelector
import com.android.adblib.DeviceState.ONLINE
import com.android.adblib.shellAsText
@@ -39,13 +45,6 @@ import java.io.IOException
import java.time.Duration
import kotlin.coroutines.CoroutineContext
-private const val PROP_RELEASE = "ro.build.version.release"
-private const val PROP_SDK = "ro.build.version.sdk"
-private const val PROP_MANUFACTURER = "ro.product.manufacturer"
-private const val PROP_MODEL = "ro.product.model"
-private const val PROP_AVD_NAME = "ro.boot.qemu.avd_name"
-private const val PROP_AVD_NAME_PRE_31 = "ro.kernel.qemu.avd_name"
-
private val ADB_TIMEOUT = Duration.ofMillis(1000)
/**
@@ -116,11 +115,11 @@ internal class DeviceComboBoxDeviceTracker(
existingDevice.copy(isOnline = true, serialNumber = serialNumber)
}
else {
- val properties = deviceInfo.getProperties(PROP_RELEASE, PROP_SDK)
+ val properties = deviceInfo.getProperties(RO_BUILD_VERSION_RELEASE, RO_BUILD_VERSION_SDK)
existingDevice.copy(
isOnline = true,
- release = properties.getValue(PROP_RELEASE).toIntOrNull() ?: 0,
- sdk = properties.getValue(PROP_SDK).toIntOrNull() ?: 0)
+ release = properties.getValue(RO_BUILD_VERSION_RELEASE).toIntOrNull() ?: 0,
+ sdk = properties.getValue(RO_BUILD_VERSION_SDK).toIntOrNull() ?: 0)
}
onlineDevicesBySerial[serialNumber] = copy
@@ -149,35 +148,35 @@ internal class DeviceComboBoxDeviceTracker(
private suspend fun DeviceInfo.toDevice(): Device {
if (serialNumber.startsWith("emulator-")) {
- val properties = getProperties(PROP_RELEASE, PROP_SDK, PROP_AVD_NAME, PROP_AVD_NAME_PRE_31)
+ val properties = getProperties(RO_BUILD_VERSION_RELEASE, RO_BUILD_VERSION_SDK, RO_BOOT_QEMU_AVD_NAME, RO_KERNEL_QEMU_AVD_NAME)
return Device.createEmulator(
serialNumber,
isOnline = true,
- properties.getValue(PROP_RELEASE).toIntOrNull() ?: 0,
- properties.getValue(PROP_SDK).toIntOrNull() ?: 0,
+ properties.getValue(RO_BUILD_VERSION_RELEASE).toIntOrNull() ?: 0,
+ properties.getValue(RO_BUILD_VERSION_SDK).toIntOrNull() ?: 0,
getAvdName(properties))
}
else {
- val properties = getProperties(PROP_RELEASE, PROP_SDK, PROP_MANUFACTURER, PROP_MODEL)
+ val properties = getProperties(RO_BUILD_VERSION_RELEASE, RO_BUILD_VERSION_SDK, RO_PRODUCT_MANUFACTURER, RO_PRODUCT_MODEL)
return Device.createPhysical(
serialNumber,
isOnline = true,
- properties.getValue(PROP_RELEASE).toIntOrNull() ?: 0,
- properties.getValue(PROP_SDK).toIntOrNull() ?: 0,
- properties.getValue(PROP_MANUFACTURER),
- properties.getValue(PROP_MODEL))
+ properties.getValue(RO_BUILD_VERSION_RELEASE).toIntOrNull() ?: 0,
+ properties.getValue(RO_BUILD_VERSION_SDK).toIntOrNull() ?: 0,
+ properties.getValue(RO_PRODUCT_MANUFACTURER),
+ properties.getValue(RO_PRODUCT_MODEL))
}
}
private fun DeviceInfo.getAvdName(properties: Map<String, String>): String =
- properties.getValue(PROP_AVD_NAME).ifBlank { properties.getValue(PROP_AVD_NAME_PRE_31) }.ifBlank {
+ properties.getValue(RO_BOOT_QEMU_AVD_NAME).ifBlank { properties.getValue(RO_KERNEL_QEMU_AVD_NAME) }.ifBlank {
LOGGER.warn("Emulator has no avd_name property")
serialNumber
}
private suspend fun DeviceInfo.getDeviceId(): String {
return when {
- serialNumber.startsWith("emulator-") -> getAvdName(getProperties(PROP_AVD_NAME, PROP_AVD_NAME_PRE_31))
+ serialNumber.startsWith("emulator-") -> getAvdName(getProperties(RO_BOOT_QEMU_AVD_NAME, RO_KERNEL_QEMU_AVD_NAME))
else -> serialNumber
}
}
diff --git a/logcat/testSrc/com/android/tools/idea/logcat/testing/TestDevice.kt b/logcat/testSrc/com/android/tools/idea/logcat/testing/TestDevice.kt
index 6a29733afb5..81d37129e54 100644
--- a/logcat/testSrc/com/android/tools/idea/logcat/testing/TestDevice.kt
+++ b/logcat/testSrc/com/android/tools/idea/logcat/testing/TestDevice.kt
@@ -17,6 +17,12 @@ package com.android.tools.idea.logcat.testing
import com.android.adblib.DeviceInfo
import com.android.adblib.DeviceList
+import com.android.adblib.DevicePropertyNames.RO_BOOT_QEMU_AVD_NAME
+import com.android.adblib.DevicePropertyNames.RO_BUILD_VERSION_RELEASE
+import com.android.adblib.DevicePropertyNames.RO_BUILD_VERSION_SDK
+import com.android.adblib.DevicePropertyNames.RO_KERNEL_QEMU_AVD_NAME
+import com.android.adblib.DevicePropertyNames.RO_PRODUCT_MANUFACTURER
+import com.android.adblib.DevicePropertyNames.RO_PRODUCT_MODEL
import com.android.adblib.DeviceSelector
import com.android.adblib.DeviceState
import com.android.adblib.DeviceState.ONLINE
@@ -24,13 +30,6 @@ import com.android.adblib.testing.FakeAdbDeviceServices
import com.android.adblib.testing.FakeAdbHostServices
import com.android.tools.idea.logcat.devices.Device
-private const val PROP_RELEASE = "ro.build.version.release"
-private const val PROP_SDK = "ro.build.version.sdk"
-private const val PROP_MANUFACTURER = "ro.product.manufacturer"
-private const val PROP_MODEL = "ro.product.model"
-private const val PROP_AVD_NAME = "ro.boot.qemu.avd_name"
-private const val PROP_AVD_NAME_PRE_31 = "ro.kernel.qemu.avd_name"
-
internal class TestDevice(
val serialNumber: String,
state: DeviceState,
@@ -50,12 +49,12 @@ internal class TestDevice(
}
private val properties = mapOf(
- PROP_RELEASE to "$release",
- PROP_SDK to "$sdk",
- PROP_MANUFACTURER to manufacturer,
- PROP_MODEL to model,
- PROP_AVD_NAME to avdName,
- PROP_AVD_NAME_PRE_31 to avdNamePre31,
+ RO_BUILD_VERSION_RELEASE to "$release",
+ RO_BUILD_VERSION_SDK to "$sdk",
+ RO_PRODUCT_MANUFACTURER to manufacturer,
+ RO_PRODUCT_MODEL to model,
+ RO_BOOT_QEMU_AVD_NAME to avdName,
+ RO_KERNEL_QEMU_AVD_NAME to avdNamePre31,
)
// Return a new TestDevice with a different serial number
@@ -75,25 +74,25 @@ private fun String.isEmulatorSerial() = startsWith("emulator") || isBlank()
internal fun FakeAdbDeviceServices.setupCommandsForDevice(testDevice: TestDevice) {
configureProperties(
testDevice,
- PROP_RELEASE,
- PROP_SDK,
- PROP_MANUFACTURER,
- PROP_MODEL,
+ RO_BUILD_VERSION_RELEASE,
+ RO_BUILD_VERSION_SDK,
+ RO_PRODUCT_MANUFACTURER,
+ RO_PRODUCT_MODEL,
)
configureProperties(
testDevice,
- PROP_RELEASE,
- PROP_SDK,
+ RO_BUILD_VERSION_RELEASE,
+ RO_BUILD_VERSION_SDK,
)
if (testDevice.device.isEmulator) {
configureProperties(
testDevice,
- PROP_RELEASE,
- PROP_SDK,
- PROP_AVD_NAME,
- PROP_AVD_NAME_PRE_31,
+ RO_BUILD_VERSION_RELEASE,
+ RO_BUILD_VERSION_SDK,
+ RO_BOOT_QEMU_AVD_NAME,
+ RO_KERNEL_QEMU_AVD_NAME,
)
- configureProperties(testDevice, PROP_AVD_NAME, PROP_AVD_NAME_PRE_31)
+ configureProperties(testDevice, RO_BOOT_QEMU_AVD_NAME, RO_KERNEL_QEMU_AVD_NAME)
}
}