use of com.android.internal.statusbar.IStatusBarService in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method toggleRecentApps.
private void toggleRecentApps() {
// preloading no longer needs to be canceled
mPreloadedRecentApps = false;
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.toggleRecentApps();
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing recent apps", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
}
}
use of com.android.internal.statusbar.IStatusBarService in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method performKeyAction.
private void performKeyAction(int behavior) {
switch(behavior) {
case KEY_ACTION_NOTHING:
break;
case KEY_ACTION_MENU:
triggerVirtualKeypress(KeyEvent.KEYCODE_MENU);
break;
case KEY_ACTION_APP_SWITCH:
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.toggleRecentApps();
mRecentAppsPreloaded = false;
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing recent apps", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
}
break;
case KEY_ACTION_SEARCH:
launchAssistAction();
break;
case KEY_ACTION_VOICE_SEARCH:
launchAssistLongPressAction();
break;
case KEY_ACTION_IN_APP_SEARCH:
triggerVirtualKeypress(KeyEvent.KEYCODE_SEARCH);
break;
default:
break;
}
}
use of com.android.internal.statusbar.IStatusBarService in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method cancelPreloadRecentApps.
private void cancelPreloadRecentApps() {
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.cancelPreloadRecentApps();
mRecentAppsPreloaded = false;
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing recent apps", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
}
}
use of com.android.internal.statusbar.IStatusBarService in project android_frameworks_base by ResurrectionRemix.
the class PieAction method processActionWithOptions.
public static void processActionWithOptions(Context context, String action, boolean isLongpress, boolean collapseShade) {
if (action == null || action.equals(PieConstants.NULL_BUTTON)) {
return;
}
boolean isKeyguardShowing = false;
try {
isKeyguardShowing = WindowManagerGlobal.getWindowManagerService().isKeyguardLocked();
} catch (RemoteException e) {
Log.w("Action", "Error getting window manager service", e);
}
final IStatusBarService barService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
if (barService == null) {
// ouch
return;
}
final IWindowManager windowManagerService = IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
if (windowManagerService == null) {
// ouch
return;
}
boolean isKeyguardSecure = false;
try {
isKeyguardSecure = windowManagerService.isKeyguardSecure();
} catch (RemoteException e) {
Log.w("Action", "Error getting window manager service", e);
}
if (collapseShade) {
if (!action.equals(PieConstants.SETTINGS_PANEL_BUTTON) && !action.equals(PieConstants.NOTIFICATIONS_BUTTON) && !action.equals(PieConstants.THEME_SWITCH_BUTTON)) {
try {
barService.collapsePanels();
} catch (RemoteException ex) {
}
}
}
// process the actions
if (action.equals(PieConstants.HOME_BUTTON)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_HOME, isLongpress);
return;
} else if (action.equals(PieConstants.BACK_BUTTON)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_BACK, isLongpress);
return;
} else if (action.equals(PieConstants.MENU_BUTTON) || action.equals(PieConstants.MENU_BIG_BUTTON)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_MENU, isLongpress);
return;
} else if (action.equals(PieConstants.KILL_TASK_BUTTON)) {
if (isKeyguardShowing) {
return;
}
try {
barService.toggleKillApp();
} catch (RemoteException e) {
}
return;
} else if (action.equals(PieConstants.NOTIFICATIONS_BUTTON)) {
if (isKeyguardShowing && isKeyguardSecure) {
return;
}
try {
barService.expandNotificationsPanel();
} catch (RemoteException e) {
}
return;
} else if (action.equals(PieConstants.SETTINGS_PANEL_BUTTON)) {
if (isKeyguardShowing && isKeyguardSecure) {
return;
}
try {
barService.expandSettingsPanel(null);
} catch (RemoteException e) {
}
} else if (action.equals(PieConstants.LAST_APP_BUTTON)) {
if (isKeyguardShowing) {
return;
}
try {
barService.toggleLastApp();
} catch (RemoteException e) {
}
return;
} else if (action.equals(PieConstants.RECENT_BUTTON)) {
if (isKeyguardShowing) {
return;
}
try {
barService.toggleRecentApps();
} catch (RemoteException e) {
}
return;
} else if (action.equals(PieConstants.SCREENSHOT_BUTTON)) {
try {
barService.toggleScreenshot();
} catch (RemoteException e) {
}
return;
} else {
// we must have a custom uri
Intent intent = null;
try {
intent = Intent.parseUri(action, 0);
} catch (URISyntaxException e) {
Log.e("PieAction:", "URISyntaxException: [" + action + "]");
return;
}
startActivity(context, intent, barService, isKeyguardShowing);
return;
}
}
use of com.android.internal.statusbar.IStatusBarService in project android_frameworks_base by ResurrectionRemix.
the class Action method processActionWithOptions.
public static void processActionWithOptions(Context context, String action, boolean isLongpress, boolean collapseShade) {
if (action == null || action.equals(ActionConstants.ACTION_NULL)) {
return;
}
boolean isKeyguardShowing = false;
try {
isKeyguardShowing = WindowManagerGlobal.getWindowManagerService().isKeyguardLocked();
} catch (RemoteException e) {
Log.w("Action", "Error getting window manager service", e);
}
IStatusBarService barService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
if (barService == null) {
// ouch
return;
}
// process the actions
if (action.equals(ActionConstants.ACTION_HOME)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_HOME, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_BACK)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_BACK, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_SEARCH)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_SEARCH, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_MENU) || action.equals(ActionConstants.ACTION_MENU_BIG)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_MENU, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_IME_NAVIGATION_LEFT)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_DPAD_LEFT, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_IME_NAVIGATION_RIGHT)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_DPAD_RIGHT, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_IME_NAVIGATION_UP)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_DPAD_UP, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_IME_NAVIGATION_DOWN)) {
triggerVirtualKeypress(KeyEvent.KEYCODE_DPAD_DOWN, isLongpress);
return;
} else if (action.equals(ActionConstants.ACTION_POWER)) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
pm.goToSleep(SystemClock.uptimeMillis());
return;
} else if (action.equals(ActionConstants.ACTION_IME)) {
if (isKeyguardShowing) {
return;
}
context.sendBroadcastAsUser(new Intent("android.settings.SHOW_INPUT_METHOD_PICKER"), new UserHandle(UserHandle.USER_CURRENT));
return;
} else if (action.equals(ActionConstants.ACTION_VOICE_SEARCH)) {
// launch the search activity
Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
// TODO: This only stops the factory-installed search manager.
// Need to formalize an API to handle others
SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
searchManager.stopSearch();
}
startActivity(context, intent, barService, isKeyguardShowing);
} catch (ActivityNotFoundException e) {
Log.e("SlimActions:", "No activity to handle assist long press action.", e);
}
return;
} else if (action.equals(ActionConstants.ACTION_VIB)) {
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (am != null && ActivityManagerNative.isSystemReady()) {
if (am.getRingerMode() != AudioManager.RINGER_MODE_VIBRATE) {
am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (vib != null) {
vib.vibrate(50);
}
} else {
am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, (int) (ToneGenerator.MAX_VOLUME * 0.85));
if (tg != null) {
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
}
}
return;
} else if (action.equals(ActionConstants.ACTION_SILENT)) {
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (am != null && ActivityManagerNative.isSystemReady()) {
if (am.getRingerMode() != AudioManager.RINGER_MODE_SILENT) {
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
} else {
am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, (int) (ToneGenerator.MAX_VOLUME * 0.85));
if (tg != null) {
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
}
}
return;
} else if (action.equals(ActionConstants.ACTION_VIB_SILENT)) {
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (am != null && ActivityManagerNative.isSystemReady()) {
if (am.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (vib != null) {
vib.vibrate(50);
}
} else if (am.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
} else {
am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, (int) (ToneGenerator.MAX_VOLUME * 0.85));
if (tg != null) {
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
}
}
return;
} else if (action.equals(ActionConstants.ACTION_CAMERA)) {
// ToDo: Send for secure keyguard secure camera intent.
// We need to add support for it first.
Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA, null);
startActivity(context, intent, barService, isKeyguardShowing);
return;
} else if (action.equals(ActionConstants.ACTION_MEDIA_PREVIOUS)) {
dispatchMediaKeyWithWakeLock(KeyEvent.KEYCODE_MEDIA_PREVIOUS, context);
return;
} else if (action.equals(ActionConstants.ACTION_MEDIA_NEXT)) {
dispatchMediaKeyWithWakeLock(KeyEvent.KEYCODE_MEDIA_NEXT, context);
return;
} else if (action.equals(ActionConstants.ACTION_MEDIA_PLAY_PAUSE)) {
dispatchMediaKeyWithWakeLock(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, context);
return;
} else if (action.equals(ActionConstants.ACTION_WAKE_DEVICE)) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (!powerManager.isScreenOn()) {
powerManager.wakeUp(SystemClock.uptimeMillis());
}
return;
} else {
// we must have a custom uri
Intent intent = null;
try {
intent = Intent.parseUri(action, 0);
} catch (URISyntaxException e) {
Log.e("SlimActions:", "URISyntaxException: [" + action + "]");
return;
}
startActivity(context, intent, barService, isKeyguardShowing);
return;
}
}
Aggregations