use of android.view.IWindowManager in project android_frameworks_base by crdroidandroid.
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 android.view.IWindowManager in project android_frameworks_base by crdroidandroid.
the class ShellUiAutomatorBridge method getRotation.
@Override
public int getRotation() {
IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
int ret = -1;
try {
ret = wm.getRotation();
} catch (RemoteException e) {
Log.e(LOG_TAG, "Error getting screen rotation", e);
throw new RuntimeException(e);
}
return ret;
}
use of android.view.IWindowManager in project android_frameworks_base by crdroidandroid.
the class TrustManagerService method refreshDeviceLockedForUser.
private void refreshDeviceLockedForUser(int userId) {
if (userId != UserHandle.USER_ALL && userId < UserHandle.USER_SYSTEM) {
Log.e(TAG, "refreshDeviceLockedForUser(userId=" + userId + "): Invalid user handle," + " must be USER_ALL or a specific user.", new Throwable("here"));
userId = UserHandle.USER_ALL;
}
List<UserInfo> userInfos;
if (userId == UserHandle.USER_ALL) {
userInfos = mUserManager.getUsers(true);
} else {
userInfos = new ArrayList<>();
userInfos.add(mUserManager.getUserInfo(userId));
}
IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
for (int i = 0; i < userInfos.size(); i++) {
UserInfo info = userInfos.get(i);
if (info == null || info.partial || !info.isEnabled() || info.guestToRemove || !info.supportsSwitchToByUser()) {
continue;
}
int id = info.id;
boolean secure = mLockPatternUtils.isSecure(id);
boolean trusted = aggregateIsTrusted(id);
boolean showingKeyguard = true;
if (mCurrentUser == id) {
try {
showingKeyguard = wm.isKeyguardLocked();
} catch (RemoteException e) {
}
}
boolean deviceLocked = secure && showingKeyguard && !trusted;
boolean changed;
synchronized (mDeviceLockedForUser) {
changed = isDeviceLockedInner(id) != deviceLocked;
mDeviceLockedForUser.put(id, deviceLocked);
}
if (changed) {
dispatchDeviceLocked(id, deviceLocked);
}
}
}
use of android.view.IWindowManager in project android_frameworks_base by crdroidandroid.
the class RenderSessionImpl method init.
/**
* Initializes and acquires the scene, creating various Android objects such as context,
* inflater, and parser.
*
* @param timeout the time to wait if another rendering is happening.
*
* @return whether the scene was prepared
*
* @see #acquire(long)
* @see #release()
*/
@Override
public Result init(long timeout) {
Result result = super.init(timeout);
if (!result.isSuccess()) {
return result;
}
SessionParams params = getParams();
BridgeContext context = getContext();
// use default of true in case it's not found to use alpha by default
mIsAlphaChannelImage = ResourceHelper.getBooleanThemeValue(params.getResources(), "windowIsFloating", true, true);
mLayoutBuilder = new Layout.Builder(params, context);
// FIXME: find those out, and possibly add them to the render params
boolean hasNavigationBar = true;
//noinspection ConstantConditions
IWindowManager iwm = new IWindowManagerImpl(getContext().getConfiguration(), context.getMetrics(), Surface.ROTATION_0, hasNavigationBar);
WindowManagerGlobal_Delegate.setWindowManagerService(iwm);
// build the inflater and parser.
mInflater = new BridgeInflater(context, params.getLayoutlibCallback());
context.setBridgeInflater(mInflater);
mBlockParser = new BridgeXmlBlockParser(params.getLayoutDescription(), context, false);
return SUCCESS.createResult();
}
use of android.view.IWindowManager in project android_frameworks_base by crdroidandroid.
the class DisplayDensityUtils method setForcedDisplayDensity.
/**
* Asynchronously applies display density changes to the specified display.
* <p>
* The change will be applied to the user specified by the value of
* {@link UserHandle#myUserId()} at the time the method is called.
*
* @param displayId the identifier of the display to modify
* @param density the density to force for the specified display
*/
public static void setForcedDisplayDensity(final int displayId, final int density) {
final int userId = UserHandle.myUserId();
AsyncTask.execute(() -> {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
wm.setForcedDisplayDensityForUser(displayId, density, userId);
} catch (RemoteException exc) {
Log.w(LOG_TAG, "Unable to save forced display density setting");
}
});
}
Aggregations