Search in sources :

Example 21 with IWindowManager

use of android.view.IWindowManager in project android_frameworks_base by crdroidandroid.

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");
        }
    });
}
Also used : IWindowManager(android.view.IWindowManager) RemoteException(android.os.RemoteException)

Example 22 with IWindowManager

use of android.view.IWindowManager in project platform_frameworks_base by android.

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);
        }
    }
}
Also used : IWindowManager(android.view.IWindowManager) UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException)

Example 23 with IWindowManager

use of android.view.IWindowManager in project platform_frameworks_base by android.

the class RotationPolicy method getRotationLockOrientation.

/**
     * Returns the orientation that will be used when locking the orientation from system UI
     * with {@link #setRotationLock}.
     *
     * If the device only supports locking to its natural orientation, this will be either
     * Configuration.ORIENTATION_PORTRAIT or Configuration.ORIENTATION_LANDSCAPE,
     * otherwise Configuration.ORIENTATION_UNDEFINED if any orientation is lockable.
     */
public static int getRotationLockOrientation(Context context) {
    if (!areAllRotationsAllowed(context)) {
        final Point size = new Point();
        final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
        try {
            wm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, size);
            return size.x < size.y ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
        } catch (RemoteException e) {
            Log.w(TAG, "Unable to get the display size");
        }
    }
    return Configuration.ORIENTATION_UNDEFINED;
}
Also used : IWindowManager(android.view.IWindowManager) Point(android.graphics.Point) RemoteException(android.os.RemoteException)

Example 24 with IWindowManager

use of android.view.IWindowManager in project platform_frameworks_base by android.

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);
    }
}
Also used : IWindowManager(android.view.IWindowManager) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) IInstrumentationWatcher(android.app.IInstrumentationWatcher) UiAutomationConnection(android.app.UiAutomationConnection) AndroidException(android.util.AndroidException) InstrumentationInfo(android.content.pm.InstrumentationInfo) ComponentName(android.content.ComponentName)

Example 25 with IWindowManager

use of android.view.IWindowManager in project platform_frameworks_base by android.

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;
}
Also used : IWindowManager(android.view.IWindowManager) RemoteException(android.os.RemoteException)

Aggregations

IWindowManager (android.view.IWindowManager)41 RemoteException (android.os.RemoteException)29 Point (android.graphics.Point)7 IInstrumentationWatcher (android.app.IInstrumentationWatcher)6 UiAutomationConnection (android.app.UiAutomationConnection)6 ComponentName (android.content.ComponentName)6 Bundle (android.os.Bundle)6 AndroidException (android.util.AndroidException)6 BridgeInflater (android.view.BridgeInflater)6 IWindowManagerImpl (android.view.IWindowManagerImpl)6 Result (com.android.ide.common.rendering.api.Result)6 SessionParams (com.android.ide.common.rendering.api.SessionParams)6 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)6 BridgeXmlBlockParser (com.android.layoutlib.bridge.android.BridgeXmlBlockParser)6 InstrumentationInfo (android.content.pm.InstrumentationInfo)5 FrameLayout (android.widget.FrameLayout)5 LinearLayout (android.widget.LinearLayout)5 ArrayList (java.util.ArrayList)5 UserInfo (android.content.pm.UserInfo)4 Intent (android.content.Intent)2