diff --git a/build.gradle b/build.gradle
index f36fa68..d9ba4d2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -60,6 +60,7 @@ dependencies {
compileOnly fileTree(dir: "$StudioCompilePath/plugins/android/lib", include: ['*.jar'])
compileOnly fileTree(dir: "$StudioCompilePath/lib", include: ['*.jar'])
compile 'com.google.dagger:dagger:2.6'
+
kapt "com.google.dagger:dagger-compiler:2.6"
testCompile 'junit:junit:4.12'
@@ -68,7 +69,6 @@ dependencies {
testCompile "org.mockito:mockito-core:1.+"
testCompile "com.google.truth:truth:0.30"
-
}
task(verifySetup) {
@@ -81,4 +81,5 @@ task(verifySetup) {
}
+
compileJava.dependsOn verifySetup
diff --git a/gradle.properties.change_me b/gradle.properties.change_me
deleted file mode 100644
index 91c5847..0000000
--- a/gradle.properties.change_me
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copy this file as gradle.properties
-# It will be used for both compiling and running the adb-idea plugin.
-
-
-# Path to a downloaded instance of Android Studio
-# This is used to add the android plugin dependencies to the project.
-# must point to the latest version of Android Studio.
-# You'll know it's right if you can find "$StudioCompilePath/lib/idea.jar"
-StudioCompilePath=/Applications/Android Studio.app/Contents
-
-
-# Determines which IDE to run when using the "./gradlew runIdea" command.
-# This is useful to test the plugin on older versions of Android Studio or Intellij
-# Default value: $StudioCompilePath
-#StudioRunPath=/Applications/Android Studio.app/Contents
\ No newline at end of file
diff --git a/src/main/java/com/developerphil/adbidea/action/DeviceIdleStepAction.java b/src/main/java/com/developerphil/adbidea/action/DeviceIdleStepAction.java
new file mode 100644
index 0000000..4c41b92
--- /dev/null
+++ b/src/main/java/com/developerphil/adbidea/action/DeviceIdleStepAction.java
@@ -0,0 +1,13 @@
+package com.developerphil.adbidea.action;
+
+import com.developerphil.adbidea.adb.AdbFacade;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.project.Project;
+
+public class DeviceIdleStepAction extends AdbAction {
+
+ public void actionPerformed(AnActionEvent e, Project project) {
+ AdbFacade.deviceIdleStep(project);
+ }
+
+}
diff --git a/src/main/java/com/developerphil/adbidea/action/ResetBatteryChargingAction.java b/src/main/java/com/developerphil/adbidea/action/ResetBatteryChargingAction.java
new file mode 100644
index 0000000..f5cc7e2
--- /dev/null
+++ b/src/main/java/com/developerphil/adbidea/action/ResetBatteryChargingAction.java
@@ -0,0 +1,13 @@
+package com.developerphil.adbidea.action;
+
+import com.developerphil.adbidea.adb.AdbFacade;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.project.Project;
+
+public class ResetBatteryChargingAction extends AdbAction {
+
+ public void actionPerformed(AnActionEvent e, Project project) {
+ AdbFacade.resetBatteryCharging(project);
+ }
+
+}
diff --git a/src/main/java/com/developerphil/adbidea/action/UnplugBatteryChargingAction.java b/src/main/java/com/developerphil/adbidea/action/UnplugBatteryChargingAction.java
new file mode 100644
index 0000000..08d9b3d
--- /dev/null
+++ b/src/main/java/com/developerphil/adbidea/action/UnplugBatteryChargingAction.java
@@ -0,0 +1,13 @@
+package com.developerphil.adbidea.action;
+
+import com.developerphil.adbidea.adb.AdbFacade;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.project.Project;
+
+public class UnplugBatteryChargingAction extends AdbAction {
+
+ public void actionPerformed(AnActionEvent e, Project project) {
+ AdbFacade.unplugBatteryCharging(project);
+ }
+
+}
diff --git a/src/main/java/com/developerphil/adbidea/adb/AdbFacade.java b/src/main/java/com/developerphil/adbidea/adb/AdbFacade.java
index 9ab35b0..7f473f0 100644
--- a/src/main/java/com/developerphil/adbidea/adb/AdbFacade.java
+++ b/src/main/java/com/developerphil/adbidea/adb/AdbFacade.java
@@ -2,7 +2,20 @@
import com.android.ddmlib.IDevice;
import com.developerphil.adbidea.ObjectGraph;
-import com.developerphil.adbidea.adb.command.*;
+import com.developerphil.adbidea.adb.command.ClearDataAndRestartCommand;
+import com.developerphil.adbidea.adb.command.ClearDataCommand;
+import com.developerphil.adbidea.adb.command.Command;
+import com.developerphil.adbidea.adb.command.CommandList;
+import com.developerphil.adbidea.adb.command.DeviceIdleStepCommand;
+import com.developerphil.adbidea.adb.command.GrantPermissionsCommand;
+import com.developerphil.adbidea.adb.command.KillCommand;
+import com.developerphil.adbidea.adb.command.ResetBatteryChargingCommand;
+import com.developerphil.adbidea.adb.command.RestartPackageCommand;
+import com.developerphil.adbidea.adb.command.RevokePermissionsAndRestartCommand;
+import com.developerphil.adbidea.adb.command.RevokePermissionsCommand;
+import com.developerphil.adbidea.adb.command.StartDefaultActivityCommand;
+import com.developerphil.adbidea.adb.command.UninstallCommand;
+import com.developerphil.adbidea.adb.command.UnplugBatteryCharging;
import com.developerphil.adbidea.ui.NotificationHelper;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.intellij.openapi.project.Project;
@@ -61,6 +74,19 @@ public static void clearDataAndRestart(Project project) {
executeOnDevice(project, new ClearDataAndRestartCommand());
}
+ public static void unplugBatteryCharging(Project project) {
+ executeOnDevice(project, new UnplugBatteryCharging());
+ }
+
+ public static void resetBatteryCharging(Project project) {
+ executeOnDevice(project, new ResetBatteryChargingCommand());
+ }
+
+ public static void deviceIdleStep(Project project) {
+ executeOnDevice(project, new DeviceIdleStepCommand());
+ }
+
+
private static void executeOnDevice(final Project project, final Command runnable) {
if (isGradleSyncInProgress(project)) {
diff --git a/src/main/java/com/developerphil/adbidea/adb/command/DeviceIdleStepCommand.java b/src/main/java/com/developerphil/adbidea/adb/command/DeviceIdleStepCommand.java
new file mode 100644
index 0000000..6b0e420
--- /dev/null
+++ b/src/main/java/com/developerphil/adbidea/adb/command/DeviceIdleStepCommand.java
@@ -0,0 +1,33 @@
+package com.developerphil.adbidea.adb.command;
+
+import com.android.ddmlib.IDevice;
+import com.developerphil.adbidea.adb.command.receiver.GenericReceiver;
+import com.intellij.openapi.project.Project;
+
+import org.jetbrains.android.facet.AndroidFacet;
+
+import java.util.concurrent.TimeUnit;
+
+import static com.developerphil.adbidea.adb.AdbUtil.isAppInstalled;
+import static com.developerphil.adbidea.ui.NotificationHelper.error;
+import static com.developerphil.adbidea.ui.NotificationHelper.info;
+
+public class DeviceIdleStepCommand implements Command {
+ @Override
+ public boolean run(Project project, IDevice device, AndroidFacet facet, String packageName) {
+ try {
+ if (isAppInstalled(device, packageName)) {
+ GenericReceiver receiver = new GenericReceiver();
+ device.executeShellCommand("dumpsys deviceidle step", receiver, 15L, TimeUnit.SECONDS);
+ receiver.getAdbOutputLines().stream().filter(s -> s.toLowerCase().contains("stepped")).forEach(s ->
+ info(String.format(s, packageName, device.getName())));
+ return true;
+ } else {
+ error(String.format("%s is not installed on %s", packageName, device.getName()));
+ }
+ } catch (Exception e1) {
+ error("dumpsys deviceidle step... " + e1.getMessage());
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/com/developerphil/adbidea/adb/command/ResetBatteryChargingCommand.java b/src/main/java/com/developerphil/adbidea/adb/command/ResetBatteryChargingCommand.java
new file mode 100644
index 0000000..9725089
--- /dev/null
+++ b/src/main/java/com/developerphil/adbidea/adb/command/ResetBatteryChargingCommand.java
@@ -0,0 +1,31 @@
+package com.developerphil.adbidea.adb.command;
+
+import com.android.ddmlib.IDevice;
+import com.developerphil.adbidea.adb.command.receiver.GenericReceiver;
+import com.intellij.openapi.project.Project;
+
+import org.jetbrains.android.facet.AndroidFacet;
+
+import java.util.concurrent.TimeUnit;
+
+import static com.developerphil.adbidea.adb.AdbUtil.isAppInstalled;
+import static com.developerphil.adbidea.ui.NotificationHelper.error;
+import static com.developerphil.adbidea.ui.NotificationHelper.info;
+
+public class ResetBatteryChargingCommand implements Command {
+ @Override
+ public boolean run(Project project, IDevice device, AndroidFacet facet, String packageName) {
+ try {
+ if (isAppInstalled(device, packageName)) {
+ device.executeShellCommand("dumpsys battery reset", new GenericReceiver(), 15L, TimeUnit.SECONDS);
+ info(String.format("Reset battery charging on %s", device.getName()));
+ return true;
+ } else {
+ error(String.format("%s is not installed on %s", packageName, device.getName()));
+ }
+ } catch (Exception e1) {
+ error("dumpsys battery reset... " + e1.getMessage());
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/com/developerphil/adbidea/adb/command/UnplugBatteryCharging.java b/src/main/java/com/developerphil/adbidea/adb/command/UnplugBatteryCharging.java
new file mode 100644
index 0000000..d224505
--- /dev/null
+++ b/src/main/java/com/developerphil/adbidea/adb/command/UnplugBatteryCharging.java
@@ -0,0 +1,31 @@
+package com.developerphil.adbidea.adb.command;
+
+import com.android.ddmlib.IDevice;
+import com.developerphil.adbidea.adb.command.receiver.GenericReceiver;
+import com.intellij.openapi.project.Project;
+
+import org.jetbrains.android.facet.AndroidFacet;
+
+import java.util.concurrent.TimeUnit;
+
+import static com.developerphil.adbidea.adb.AdbUtil.isAppInstalled;
+import static com.developerphil.adbidea.ui.NotificationHelper.error;
+import static com.developerphil.adbidea.ui.NotificationHelper.info;
+
+public class UnplugBatteryCharging implements Command {
+ @Override
+ public boolean run(Project project, IDevice device, AndroidFacet facet, String packageName) {
+ try {
+ if (isAppInstalled(device, packageName)) {
+ device.executeShellCommand("dumpsys battery unplug", new GenericReceiver(), 15L, TimeUnit.SECONDS);
+ info(String.format("Unplugging battery charging. on %s", packageName, device.getName()));
+ return true;
+ } else {
+ error(String.format("%s is not installed on %s", packageName, device.getName()));
+ }
+ } catch (Exception e1) {
+ error("dumpsys battery unplug... " + e1.getMessage());
+ }
+ return false;
+ }
+}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index bd5b1fc..aacd3cf 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -1,7 +1,7 @@
com.developerphil.adbidea
ADB Idea
- 1.5.2
+ 1.5.3
Philippe Breault
ADB Revoke Permissions
ADB Start App With Debugger
ADB Restart App With Debugger
+ Battery Unplug Battery Charging
+ Battery Reset Battery Charging
+ Battery Step into idle state
There are two basic ways to invoke a command:
@@ -27,6 +30,10 @@
1.5.3
+
+ - FEATURE: Added Battery and idle state commands
+
1.5.2
- BUGFIX: Show the name of the devices in addition to the serial number when multiple devices are connected
@@ -118,83 +125,91 @@
-
+
com.intellij.modules.platform
org.jetbrains.android
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+