Search in sources :

Example 1 with IWindowManager

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

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 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 {
            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 = ComponentName.unflattenFromString(cnArg);
    if (cn == null)
        throw new IllegalArgumentException("Bad component name: " + cnArg);
    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 (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher, connection, userId)) {
        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 : UiAutomationConnection(android.app.UiAutomationConnection) AndroidException(android.util.AndroidException) IWindowManager(android.view.IWindowManager) Bundle(android.os.Bundle) IInstrumentationWatcher(android.app.IInstrumentationWatcher) ComponentName(android.content.ComponentName)

Example 2 with IWindowManager

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

the class SystemUIService method onCreate.

@Override
public void onCreate() {
    // run as the current user, i.e. run across users.
    try {
        AccessibilityManager.createAsSharedAcrossUsers(this);
    } catch (IllegalStateException e) {
    // AccessibilityManager already created
    }
    // Pick status bar or system bar.
    IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
    try {
        SERVICES[0] = wm.hasSystemNavBar() ? R.string.config_systemBarComponent : R.string.config_statusBarComponent;
    } catch (RemoteException e) {
        Slog.w(TAG, "Failing checking whether status bar can hide", e);
    }
    final int N = SERVICES.length;
    mServices = new SystemUI[N];
    for (int i = 0; i < N; i++) {
        Class cl = chooseClass(SERVICES[i]);
        Slog.d(TAG, "loading: " + cl);
        try {
            mServices[i] = (SystemUI) cl.newInstance();
        } catch (IllegalAccessException ex) {
            throw new RuntimeException(ex);
        } catch (InstantiationException ex) {
            throw new RuntimeException(ex);
        }
        mServices[i].mContext = this;
        Slog.d(TAG, "running: " + mServices[i]);
        mServices[i].start();
    }
}
Also used : IWindowManager(android.view.IWindowManager) RemoteException(android.os.RemoteException)

Example 3 with IWindowManager

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

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() == false) {
        return result;
    }
    SessionParams params = getParams();
    BridgeContext context = getContext();
    RenderResources resources = getParams().getResources();
    DisplayMetrics metrics = getContext().getMetrics();
    // use default of true in case it's not found to use alpha by default
    mIsAlphaChannelImage = getBooleanThemeValue(resources, "windowIsFloating", true);
    mWindowIsFloating = getBooleanThemeValue(resources, "windowIsFloating", true);
    findBackground(resources);
    findStatusBar(resources, metrics);
    findActionBar(resources, metrics);
    findNavigationBar(resources, metrics);
    // FIXME: find those out, and possibly add them to the render params
    boolean hasSystemNavBar = true;
    boolean hasNavigationBar = true;
    IWindowManager iwm = new IWindowManagerImpl(getContext().getConfiguration(), metrics, Surface.ROTATION_0, hasSystemNavBar, hasNavigationBar);
    WindowManagerGlobal_Delegate.setWindowManagerService(iwm);
    // build the inflater and parser.
    mInflater = new BridgeInflater(context, params.getProjectCallback());
    context.setBridgeInflater(mInflater);
    mBlockParser = new BridgeXmlBlockParser(params.getLayoutDescription(), context, false);
    return SUCCESS.createResult();
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) BridgeInflater(android.view.BridgeInflater) IWindowManager(android.view.IWindowManager) IWindowManagerImpl(android.view.IWindowManagerImpl) RenderResources(com.android.ide.common.rendering.api.RenderResources) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) DisplayMetrics(android.util.DisplayMetrics) BridgeXmlBlockParser(com.android.layoutlib.bridge.android.BridgeXmlBlockParser) Result(com.android.ide.common.rendering.api.Result)

Example 4 with IWindowManager

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

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

Example 5 with IWindowManager

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

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)

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