use of android.view.IWindowManager in project android_frameworks_base by AOSPA.
the class DisplayDensityUtils method clearForcedDisplayDensity.
/**
* 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
*/
public static void clearForcedDisplayDensity(final int displayId) {
final int userId = UserHandle.myUserId();
AsyncTask.execute(() -> {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
wm.clearForcedDisplayDensityForUser(displayId, userId);
} catch (RemoteException exc) {
Log.w(LOG_TAG, "Unable to clear forced display density setting");
}
});
}
use of android.view.IWindowManager in project android_frameworks_base by AOSPA.
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 ResurrectionRemix.
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");
}
});
}
use of android.view.IWindowManager 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 android.view.IWindowManager in project android_frameworks_base by crdroidandroid.
the class Am method runInstrument.
private void runInstrument() throws Exception {
String profileFile = null;
boolean wait = false;
boolean rawMode = false;
boolean no_window_animation = false;
int userId = UserHandle.USER_CURRENT;
Bundle args = new Bundle();
String argKey = null, argValue = null;
IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
String abi = null;
String opt;
while ((opt = nextOption()) != null) {
if (opt.equals("-p")) {
profileFile = nextArgRequired();
} else if (opt.equals("-w")) {
wait = true;
} else if (opt.equals("-r")) {
rawMode = true;
} else if (opt.equals("-e")) {
argKey = nextArgRequired();
argValue = nextArgRequired();
args.putString(argKey, argValue);
} else if (opt.equals("--no_window_animation") || opt.equals("--no-window-animation")) {
no_window_animation = true;
} else if (opt.equals("--user")) {
userId = parseUserArg(nextArgRequired());
} else if (opt.equals("--abi")) {
abi = nextArgRequired();
} else {
System.err.println("Error: Unknown option: " + opt);
return;
}
}
if (userId == UserHandle.USER_ALL) {
System.err.println("Error: Can't start instrumentation with user 'all'");
return;
}
String cnArg = nextArgRequired();
ComponentName cn;
if (cnArg.contains("/")) {
cn = ComponentName.unflattenFromString(cnArg);
if (cn == null)
throw new IllegalArgumentException("Bad component name: " + cnArg);
} else {
List<InstrumentationInfo> infos = mPm.queryInstrumentation(null, 0).getList();
final int numInfos = infos == null ? 0 : infos.size();
List<ComponentName> cns = new ArrayList<>();
for (int i = 0; i < numInfos; i++) {
InstrumentationInfo info = infos.get(i);
ComponentName c = new ComponentName(info.packageName, info.name);
if (cnArg.equals(info.packageName)) {
cns.add(c);
}
}
if (cns.size() == 0) {
throw new IllegalArgumentException("No instrumentation found for: " + cnArg);
} else if (cns.size() == 1) {
cn = cns.get(0);
} else {
StringBuilder cnsStr = new StringBuilder();
final int numCns = cns.size();
for (int i = 0; i < numCns; i++) {
cnsStr.append(cns.get(i).flattenToString());
cnsStr.append(", ");
}
// Remove last ", "
cnsStr.setLength(cnsStr.length() - 2);
throw new IllegalArgumentException("Found multiple instrumentations: " + cnsStr.toString());
}
}
InstrumentationWatcher watcher = null;
UiAutomationConnection connection = null;
if (wait) {
watcher = new InstrumentationWatcher();
watcher.setRawOutput(rawMode);
connection = new UiAutomationConnection();
}
float[] oldAnims = null;
if (no_window_animation) {
oldAnims = wm.getAnimationScales();
wm.setAnimationScale(0, 0.0f);
wm.setAnimationScale(1, 0.0f);
}
if (abi != null) {
final String[] supportedAbis = Build.SUPPORTED_ABIS;
boolean matched = false;
for (String supportedAbi : supportedAbis) {
if (supportedAbi.equals(abi)) {
matched = true;
break;
}
}
if (!matched) {
throw new AndroidException("INSTRUMENTATION_FAILED: Unsupported instruction set " + abi);
}
}
if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher, connection, userId, abi)) {
throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString());
}
if (watcher != null) {
if (!watcher.waitForFinish()) {
System.out.println("INSTRUMENTATION_ABORTED: System has crashed.");
}
}
if (oldAnims != null) {
wm.setAnimationScales(oldAnims);
}
}
Aggregations