-
Notifications
You must be signed in to change notification settings - Fork 267
Expand file tree
/
Copy pathSwitchLayoutBoundsCommand.kt
More file actions
37 lines (30 loc) · 1.6 KB
/
Copy pathSwitchLayoutBoundsCommand.kt
File metadata and controls
37 lines (30 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.developerphil.adbidea.adb.command
import com.android.ddmlib.IDevice
import com.developerphil.adbidea.adb.command.receiver.GenericReceiver
import com.developerphil.adbidea.adb.command.receiver.ResponseHolder
import com.developerphil.adbidea.adb.command.receiver.ResponseReceiver
import com.developerphil.adbidea.ui.NotificationHelper.error
import com.developerphil.adbidea.ui.NotificationHelper.info
import com.intellij.openapi.project.Project
import org.jetbrains.android.facet.AndroidFacet
import java.util.concurrent.TimeUnit
class SwitchLayoutBoundsCommand() : Command {
override fun run(project: Project, device: IDevice, facet: AndroidFacet, packageName: String): Boolean {
try {
val receiver = ResponseHolder()
device.executeShellCommand("getprop debug.layout", ResponseReceiver(receiver), 30L, TimeUnit.SECONDS)
val isAlreadyOn = receiver.response.contains("true")
val cmd = if(isAlreadyOn){
"setprop debug.layout false && service call activity 1599295570" //SYSPROPS_TRANSACTION
} else {
"setprop debug.layout true && service call activity 1599295570" //SYSPROPS_TRANSACTION
}
device.executeShellCommand(cmd, ResponseReceiver(receiver), 30L, TimeUnit.SECONDS)
info(String.format("<b>%s</b> on %s", if(isAlreadyOn)"Hide layout bound" else "Show layout bound", device.name))
return true
} catch (e: Exception) {
error("Failure while attempting to switch layout bounds on ${device.name}: " + e.message)
}
return false
}
}