summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbigrushdog <randall.rushing@gmail.com>2017-08-11 18:19:50 -0700
committerbigrushdog <randall.rushing@gmail.com>2017-08-11 18:19:50 -0700
commit20b3bf9e280db63ae68adfca37fe116eda8af1db (patch)
tree4a99e39127f5c3890ad0220262508cfab55bb73d
parenta27751b5b9411c56b8e714a6aa0d2ba1b05b14a0 (diff)
DUtils: Migrate from broadcasts to API for some action handling [2/2]
Change-Id: I8734e2ee6d9b6201bf37fd3967067ff58eec85b7
-rw-r--r--src/com/android/internal/utils/du/ActionHandler.java52
1 files changed, 23 insertions, 29 deletions
diff --git a/src/com/android/internal/utils/du/ActionHandler.java b/src/com/android/internal/utils/du/ActionHandler.java
index 4a3c01e..0d65cf7 100644
--- a/src/com/android/internal/utils/du/ActionHandler.java
+++ b/src/com/android/internal/utils/du/ActionHandler.java
@@ -61,9 +61,11 @@ import android.service.wallpaper.WallpaperService;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
+import android.view.IWindowManager;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
+import android.view.WindowManagerGlobal;
import android.view.WindowManagerPolicyControl;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
@@ -139,7 +141,6 @@ public class ActionHandler {
public static final String INTENT_TOGGLE_SCREENRECORD = "action_handler_toggle_screenrecord";
public static final String INTENT_SCREENSHOT = "action_handler_screenshot";
public static final String INTENT_REGION_SCREENSHOT = "action_handler_region_screenshot";
- public static final String INTENT_TOGGLE_FLASHLIGHT = "action_handler_toggle_flashlight";
static enum SystemAction {
NoAction(SYSTEMUI_TASK_NO_ACTION, SYSTEMUI, "label_action_no_action", "ic_sysbar_no_action"),
@@ -315,6 +316,15 @@ public class ActionHandler {
}
}
+ private static void toggleFlashlight() {
+ IStatusBarService service = getStatusBarService();
+ try {
+ service.toggleFlashlight();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
private static void toggleRecentsApps() {
IStatusBarService service = getStatusBarService();
if (service != null) {
@@ -464,13 +474,13 @@ public class ActionHandler {
killProcess(context);
return;
} else if (action.equals(SYSTEMUI_TASK_SCREENSHOT)) {
- takeScreenshot(context);
+ sendCommandToWindowManager(new Intent(INTENT_SCREENSHOT));
return;
} else if (action.equals(SYSTEMUI_TASK_REGION_SCREENSHOT)) {
- takeRegionScreenshot(context);
+ sendCommandToWindowManager(new Intent(INTENT_REGION_SCREENSHOT));
return;
} else if (action.equals(SYSTEMUI_TASK_SCREENRECORD)) {
- takeScreenrecord(context);
+ sendCommandToWindowManager(new Intent(INTENT_TOGGLE_SCREENRECORD));
return;
// } else if (action.equals(SYSTEMUI_TASK_AUDIORECORD)) {
// takeAudiorecord();
@@ -494,10 +504,10 @@ public class ActionHandler {
StatusBarHelper.fireGoogleNowOnTap();
return;
} else if (action.equals(SYSTEMUI_TASK_POWER_MENU)) {
- showPowerMenu(context);
+ sendCommandToWindowManager(new Intent(INTENT_SHOW_POWER_MENU));
return;
} else if (action.equals(SYSTEMUI_TASK_TORCH)) {
- toggleTorch(context);
+ StatusBarHelper.toggleFlashlight();
return;
} else if (action.equals(SYSTEMUI_TASK_CAMERA)) {
launchCamera(context);
@@ -855,24 +865,13 @@ public class ActionHandler {
}
}
- private static void toggleTorch(Context context) {
- context.sendBroadcastAsUser(new Intent(INTENT_TOGGLE_FLASHLIGHT), new UserHandle(
- UserHandle.USER_ALL));
- }
-
- private static void takeScreenshot(Context context) {
- context.sendBroadcastAsUser(new Intent(INTENT_SCREENSHOT), new UserHandle(
- UserHandle.USER_ALL));
- }
-
- private static void takeRegionScreenshot(Context context) {
- context.sendBroadcastAsUser(new Intent(INTENT_REGION_SCREENSHOT), new UserHandle(
- UserHandle.USER_ALL));
- }
-
- private static void takeScreenrecord(Context context) {
- context.sendBroadcastAsUser(new Intent(INTENT_TOGGLE_SCREENRECORD), new UserHandle(
- UserHandle.USER_ALL));
+ private static void sendCommandToWindowManager(Intent intent) {
+ IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
+ try {
+ wm.sendCustomAction(intent);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
private static void killProcess(Context context) {
@@ -1044,11 +1043,6 @@ public class ActionHandler {
return false;
}
- private static void showPowerMenu(Context context) {
- context.sendBroadcastAsUser(new Intent(INTENT_SHOW_POWER_MENU), new UserHandle(
- UserHandle.USER_ALL));
- }
-
public static void volumePanel(Context context) {
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.adjustVolume(AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);