Search in sources :

Example 1 with DisplayInfo

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

the class LogicalDisplay method getDisplayInfoLocked.

/**
     * Gets information about the logical display.
     *
     * @return The device info, which should be treated as immutable by the caller.
     * The logical display should allocate a new display info object whenever
     * the data changes.
     */
public DisplayInfo getDisplayInfoLocked() {
    if (mInfo == null) {
        mInfo = new DisplayInfo();
        if (mOverrideDisplayInfo != null) {
            mInfo.copyFrom(mOverrideDisplayInfo);
            mInfo.layerStack = mBaseDisplayInfo.layerStack;
            mInfo.name = mBaseDisplayInfo.name;
        } else {
            mInfo.copyFrom(mBaseDisplayInfo);
        }
    }
    return mInfo;
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 2 with DisplayInfo

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

the class LogicalDisplay method setDisplayInfoOverrideFromWindowManagerLocked.

/**
     * Sets overridden logical display information from the window manager.
     * This method can be used to adjust application insets, rotation, and other
     * properties that the window manager takes care of.
     *
     * @param info The logical display information, may be null.
     */
public void setDisplayInfoOverrideFromWindowManagerLocked(DisplayInfo info) {
    if (info != null) {
        if (mOverrideDisplayInfo == null) {
            mOverrideDisplayInfo = new DisplayInfo(info);
            mInfo = null;
        } else if (!mOverrideDisplayInfo.equals(info)) {
            mOverrideDisplayInfo.copyFrom(info);
            mInfo = null;
        }
    } else if (mOverrideDisplayInfo != null) {
        mOverrideDisplayInfo = null;
        mInfo = null;
    }
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 3 with DisplayInfo

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

the class DimLayer method show.

/**
     * Begin an animation to a new dim value.
     * NOTE: Must be called with Surface transaction open.
     *
     * @param layer The layer to set the surface to.
     * @param alpha The dim value to end at.
     * @param duration How long to take to get there in milliseconds.
     */
void show(int layer, float alpha, long duration) {
    if (DEBUG)
        Slog.v(TAG, "show: layer=" + layer + " alpha=" + alpha + " duration=" + duration);
    if (mDimSurface == null) {
        Slog.e(TAG, "show: no Surface");
        // Make sure isAnimating() returns false.
        mTargetAlpha = mAlpha = 0;
        return;
    }
    // Set surface size to screen size.
    final DisplayInfo info = mDisplayContent.getDisplayInfo();
    // Multiply by 1.5 so that rotating a frozen surface that includes this does not expose a
    // corner.
    final int dw = (int) (info.logicalWidth * 1.5);
    final int dh = (int) (info.logicalHeight * 1.5);
    // back off position so 1/4 of Surface is before and 1/4 is after.
    final float xPos = -1 * dw / 6;
    final float yPos = -1 * dh / 6;
    if (mLastDimWidth != dw || mLastDimHeight != dh || mLayer != layer) {
        try {
            mDimSurface.setPosition(xPos, yPos);
            mDimSurface.setSize(dw, dh);
            mDimSurface.setLayer(layer);
        } catch (RuntimeException e) {
            Slog.w(TAG, "Failure setting size or layer", e);
        }
        mLastDimWidth = dw;
        mLastDimHeight = dh;
        mLayer = layer;
    }
    long curTime = SystemClock.uptimeMillis();
    final boolean animating = isAnimating();
    if ((animating && (mTargetAlpha != alpha || durationEndsEarlier(duration))) || (!animating && mAlpha != alpha)) {
        if (duration <= 0) {
            // No animation required, just set values.
            setAlpha(alpha);
        } else {
            // Start or continue animation with new parameters.
            mStartAlpha = mAlpha;
            mStartTime = curTime;
            mDuration = duration;
        }
    }
    if (DEBUG)
        Slog.v(TAG, "show: mStartAlpha=" + mStartAlpha + " mStartTime=" + mStartTime);
    mTargetAlpha = alpha;
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 4 with DisplayInfo

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

the class WindowManagerService method computeScreenConfigurationLocked.

boolean computeScreenConfigurationLocked(Configuration config) {
    if (!mDisplayReady) {
        return false;
    }
    // TODO(multidisplay): For now, apply Configuration to main screen only.
    final DisplayContent displayContent = getDefaultDisplayContentLocked();
    // Use the effective "visual" dimensions based on current rotation
    final boolean rotated = (mRotation == Surface.ROTATION_90 || mRotation == Surface.ROTATION_270);
    final int realdw = rotated ? displayContent.mBaseDisplayHeight : displayContent.mBaseDisplayWidth;
    final int realdh = rotated ? displayContent.mBaseDisplayWidth : displayContent.mBaseDisplayHeight;
    int dw = realdw;
    int dh = realdh;
    if (mAltOrientation) {
        if (realdw > realdh) {
            // Turn landscape into portrait.
            int maxw = (int) (realdh / 1.3f);
            if (maxw < realdw) {
                dw = maxw;
            }
        } else {
            // Turn portrait into landscape.
            int maxh = (int) (realdw / 1.3f);
            if (maxh < realdh) {
                dh = maxh;
            }
        }
    }
    if (config != null) {
        config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
    }
    // Update application display metrics.
    final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation);
    final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation);
    final DisplayInfo displayInfo = displayContent.getDisplayInfo();
    synchronized (displayContent.mDisplaySizeLock) {
        displayInfo.rotation = mRotation;
        displayInfo.logicalWidth = dw;
        displayInfo.logicalHeight = dh;
        displayInfo.logicalDensityDpi = displayContent.mBaseDisplayDensity;
        displayInfo.appWidth = appWidth;
        displayInfo.appHeight = appHeight;
        displayInfo.getLogicalMetrics(mRealDisplayMetrics, null);
        displayInfo.getAppMetrics(mDisplayMetrics, null);
        mDisplayManagerService.setDisplayInfoOverrideFromWindowManager(displayContent.getDisplayId(), displayInfo);
    }
    if (false) {
        Slog.i(TAG, "Set app display size: " + appWidth + " x " + appHeight);
    }
    final DisplayMetrics dm = mDisplayMetrics;
    mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(dm, mCompatDisplayMetrics);
    if (config != null) {
        config.screenWidthDp = (int) (mPolicy.getConfigDisplayWidth(dw, dh, mRotation) / dm.density);
        config.screenHeightDp = (int) (mPolicy.getConfigDisplayHeight(dw, dh, mRotation) / dm.density);
        computeSizeRangesAndScreenLayout(displayInfo, rotated, dw, dh, dm.density, config);
        config.compatScreenWidthDp = (int) (config.screenWidthDp / mCompatibleScreenScale);
        config.compatScreenHeightDp = (int) (config.screenHeightDp / mCompatibleScreenScale);
        config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dm, dw, dh);
        config.densityDpi = displayContent.mBaseDisplayDensity;
        // Update the configuration based on available input devices, lid switch,
        // and platform configuration.
        config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH;
        config.keyboard = Configuration.KEYBOARD_NOKEYS;
        config.navigation = Configuration.NAVIGATION_NONAV;
        int keyboardPresence = 0;
        int navigationPresence = 0;
        final InputDevice[] devices = mInputManager.getInputDevices();
        final int len = devices.length;
        for (int i = 0; i < len; i++) {
            InputDevice device = devices[i];
            if (!device.isVirtual()) {
                final int sources = device.getSources();
                final int presenceFlag = device.isExternal() ? WindowManagerPolicy.PRESENCE_EXTERNAL : WindowManagerPolicy.PRESENCE_INTERNAL;
                if (mIsTouchDevice) {
                    if ((sources & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
                        config.touchscreen = Configuration.TOUCHSCREEN_FINGER;
                    }
                } else {
                    config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH;
                }
                if ((sources & InputDevice.SOURCE_TRACKBALL) == InputDevice.SOURCE_TRACKBALL) {
                    config.navigation = Configuration.NAVIGATION_TRACKBALL;
                    navigationPresence |= presenceFlag;
                } else if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD && config.navigation == Configuration.NAVIGATION_NONAV) {
                    config.navigation = Configuration.NAVIGATION_DPAD;
                    navigationPresence |= presenceFlag;
                }
                if (device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
                    config.keyboard = Configuration.KEYBOARD_QWERTY;
                    keyboardPresence |= presenceFlag;
                }
            }
        }
        // Determine whether a hard keyboard is available and enabled.
        boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
        if (hardKeyboardAvailable != mHardKeyboardAvailable) {
            mHardKeyboardAvailable = hardKeyboardAvailable;
            mHardKeyboardEnabled = hardKeyboardAvailable;
            mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
            mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
        }
        if (!mHardKeyboardEnabled) {
            config.keyboard = Configuration.KEYBOARD_NOKEYS;
        }
        // Let the policy update hidden states.
        config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
        config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO;
        config.navigationHidden = Configuration.NAVIGATIONHIDDEN_NO;
        mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
    }
    return true;
}
Also used : InputDevice(android.view.InputDevice) DisplayInfo(android.view.DisplayInfo) DisplayMetrics(android.util.DisplayMetrics) Point(android.graphics.Point)

Example 5 with DisplayInfo

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

the class WindowManagerService method stopFreezingDisplayLocked.

private void stopFreezingDisplayLocked() {
    if (!mDisplayFrozen) {
        return;
    }
    if (mWaitingForConfig || mAppsFreezingScreen > 0 || mWindowsFreezingScreen || mClientFreezingScreen) {
        if (DEBUG_ORIENTATION)
            Slog.d(TAG, "stopFreezingDisplayLocked: Returning mWaitingForConfig=" + mWaitingForConfig + ", mAppsFreezingScreen=" + mAppsFreezingScreen + ", mWindowsFreezingScreen=" + mWindowsFreezingScreen + ", mClientFreezingScreen=" + mClientFreezingScreen);
        return;
    }
    mDisplayFrozen = false;
    mLastDisplayFreezeDuration = (int) (SystemClock.elapsedRealtime() - mDisplayFreezeTime);
    StringBuilder sb = new StringBuilder(128);
    sb.append("Screen frozen for ");
    TimeUtils.formatDuration(mLastDisplayFreezeDuration, sb);
    if (mLastFinishedFreezeSource != null) {
        sb.append(" due to ");
        sb.append(mLastFinishedFreezeSource);
    }
    Slog.i(TAG, sb.toString());
    mH.removeMessages(H.APP_FREEZE_TIMEOUT);
    mH.removeMessages(H.CLIENT_FREEZE_TIMEOUT);
    if (PROFILE_ORIENTATION) {
        Debug.stopMethodTracing();
    }
    boolean updateRotation = false;
    final DisplayContent displayContent = getDefaultDisplayContentLocked();
    final int displayId = displayContent.getDisplayId();
    ScreenRotationAnimation screenRotationAnimation = mAnimator.getScreenRotationAnimationLocked(displayId);
    if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null && screenRotationAnimation.hasScreenshot()) {
        if (DEBUG_ORIENTATION)
            Slog.i(TAG, "**** Dismissing screen rotation animation");
        // TODO(multidisplay): rotation on main screen only.
        DisplayInfo displayInfo = displayContent.getDisplayInfo();
        // Get rotation animation again, with new top window
        boolean isDimming = mAnimator.isDimmingLocked(Display.DEFAULT_DISPLAY);
        if (!mPolicy.validateRotationAnimationLw(mExitAnimId, mEnterAnimId, isDimming)) {
            mExitAnimId = mEnterAnimId = 0;
        }
        if (screenRotationAnimation.dismiss(mFxSession, MAX_ANIMATION_DURATION, mTransitionAnimationScale, displayInfo.logicalWidth, displayInfo.logicalHeight, mExitAnimId, mEnterAnimId)) {
            scheduleAnimationLocked();
        } else {
            screenRotationAnimation.kill();
            screenRotationAnimation = null;
            mAnimator.setScreenRotationAnimationLocked(displayId, screenRotationAnimation);
            updateRotation = true;
        }
    } else {
        if (screenRotationAnimation != null) {
            screenRotationAnimation.kill();
            screenRotationAnimation = null;
            mAnimator.setScreenRotationAnimationLocked(displayId, screenRotationAnimation);
        }
        updateRotation = true;
    }
    mInputMonitor.thawInputDispatchingLw();
    boolean configChanged;
    // While the display is frozen we don't re-compute the orientation
    // to avoid inconsistent states.  However, something interesting
    // could have actually changed during that time so re-evaluate it
    // now to catch that.
    configChanged = updateOrientationFromAppTokensLocked(false);
    // A little kludge: a lot could have happened while the
    // display was frozen, so now that we are coming back we
    // do a gc so that any remote references the system
    // processes holds on others can be released if they are
    // no longer needed.
    mH.removeMessages(H.FORCE_GC);
    mH.sendEmptyMessageDelayed(H.FORCE_GC, 2000);
    mScreenFrozenLock.release();
    if (updateRotation) {
        if (DEBUG_ORIENTATION)
            Slog.d(TAG, "Performing post-rotate rotation");
        configChanged |= updateRotationUncheckedLocked(false);
    }
    if (configChanged) {
        mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
    }
}
Also used : DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Aggregations

DisplayInfo (android.view.DisplayInfo)197 Point (android.graphics.Point)55 Rect (android.graphics.Rect)29 RemoteException (android.os.RemoteException)19 Display (android.view.Display)17 WindowManager (android.view.WindowManager)10 Animation (android.view.animation.Animation)10 Bitmap (android.graphics.Bitmap)9 DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)8 DisplayManager (android.hardware.display.DisplayManager)7 DisplayMetrics (android.util.DisplayMetrics)7 Canvas (android.graphics.Canvas)6 SurfaceControl (android.view.SurfaceControl)6 LayoutParams (android.view.WindowManager.LayoutParams)6 Surface (android.view.Surface)5 InputDevice (android.view.InputDevice)4 SnapTarget (com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 Test (org.junit.Test)4