Search in sources :

Example 26 with DisplayInfo

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

the class WindowManagerService method relayoutWindow.

public int relayoutWindow(Session session, IWindow client, int seq, WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, int flags, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets, Rect outVisibleInsets, Rect outStableInsets, Rect outOutsets, Rect outBackdropFrame, Configuration outConfig, Surface outSurface) {
    int result = 0;
    boolean configChanged;
    boolean hasStatusBarPermission = mContext.checkCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR) == PackageManager.PERMISSION_GRANTED;
    long origId = Binder.clearCallingIdentity();
    synchronized (mWindowMap) {
        WindowState win = windowForClientLocked(session, client, false);
        if (win == null) {
            return 0;
        }
        WindowStateAnimator winAnimator = win.mWinAnimator;
        if (viewVisibility != View.GONE) {
            win.setRequestedSize(requestedWidth, requestedHeight);
        }
        int attrChanges = 0;
        int flagChanges = 0;
        if (attrs != null) {
            mPolicy.adjustWindowParamsLw(attrs);
            // if they don't have the permission, mask out the status bar bits
            if (seq == win.mSeq) {
                int systemUiVisibility = attrs.systemUiVisibility | attrs.subtreeSystemUiVisibility;
                if ((systemUiVisibility & DISABLE_MASK) != 0) {
                    if (!hasStatusBarPermission) {
                        systemUiVisibility &= ~DISABLE_MASK;
                    }
                }
                win.mSystemUiVisibility = systemUiVisibility;
            }
            if (win.mAttrs.type != attrs.type) {
                throw new IllegalArgumentException("Window type can not be changed after the window is added.");
            }
            // Odd choice but less odd than embedding in copyFrom()
            if ((attrs.privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_PRESERVE_GEOMETRY) != 0) {
                attrs.x = win.mAttrs.x;
                attrs.y = win.mAttrs.y;
                attrs.width = win.mAttrs.width;
                attrs.height = win.mAttrs.height;
            }
            flagChanges = win.mAttrs.flags ^= attrs.flags;
            attrChanges = win.mAttrs.copyFrom(attrs);
            if ((attrChanges & (WindowManager.LayoutParams.LAYOUT_CHANGED | WindowManager.LayoutParams.SYSTEM_UI_VISIBILITY_CHANGED)) != 0) {
                win.mLayoutNeeded = true;
            }
        }
        if (DEBUG_LAYOUT)
            Slog.v(TAG_WM, "Relayout " + win + ": viewVisibility=" + viewVisibility + " req=" + requestedWidth + "x" + requestedHeight + " " + win.mAttrs);
        winAnimator.mSurfaceDestroyDeferred = (flags & RELAYOUT_DEFER_SURFACE_DESTROY) != 0;
        win.mEnforceSizeCompat = (win.mAttrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0;
        if ((attrChanges & WindowManager.LayoutParams.ALPHA_CHANGED) != 0) {
            winAnimator.mAlpha = attrs.alpha;
        }
        win.setWindowScale(win.mRequestedWidth, win.mRequestedHeight);
        if (win.mAttrs.surfaceInsets.left != 0 || win.mAttrs.surfaceInsets.top != 0 || win.mAttrs.surfaceInsets.right != 0 || win.mAttrs.surfaceInsets.bottom != 0) {
            winAnimator.setOpaqueLocked(false);
        }
        boolean imMayMove = (flagChanges & (FLAG_ALT_FOCUSABLE_IM | FLAG_NOT_FOCUSABLE)) != 0;
        final boolean isDefaultDisplay = win.isDefaultDisplay();
        boolean focusMayChange = isDefaultDisplay && (win.mViewVisibility != viewVisibility || ((flagChanges & FLAG_NOT_FOCUSABLE) != 0) || (!win.mRelayoutCalled));
        boolean wallpaperMayMove = win.mViewVisibility != viewVisibility && (win.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0;
        wallpaperMayMove |= (flagChanges & FLAG_SHOW_WALLPAPER) != 0;
        if ((flagChanges & FLAG_SECURE) != 0 && winAnimator.mSurfaceController != null) {
            winAnimator.mSurfaceController.setSecure(isSecureLocked(win));
        }
        win.mRelayoutCalled = true;
        win.mInRelayout = true;
        final int oldVisibility = win.mViewVisibility;
        win.mViewVisibility = viewVisibility;
        if (DEBUG_SCREEN_ON) {
            RuntimeException stack = new RuntimeException();
            stack.fillInStackTrace();
            Slog.i(TAG_WM, "Relayout " + win + ": oldVis=" + oldVisibility + " newVis=" + viewVisibility, stack);
        }
        if (viewVisibility == View.VISIBLE && (win.mAppToken == null || !win.mAppToken.clientHidden)) {
            result = relayoutVisibleWindow(outConfig, result, win, winAnimator, attrChanges, oldVisibility);
            try {
                result = createSurfaceControl(outSurface, result, win, winAnimator);
            } catch (Exception e) {
                mInputMonitor.updateInputWindowsLw(true);
                Slog.w(TAG_WM, "Exception thrown when creating surface for client " + client + " (" + win.mAttrs.getTitle() + ")", e);
                Binder.restoreCallingIdentity(origId);
                return 0;
            }
            if ((result & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
                focusMayChange = isDefaultDisplay;
            }
            if (win.mAttrs.type == TYPE_INPUT_METHOD && mInputMethodWindow == null) {
                mInputMethodWindow = win;
                imMayMove = true;
            }
            win.adjustStartingWindowFlags();
        } else {
            winAnimator.mEnterAnimationPending = false;
            winAnimator.mEnteringAnimation = false;
            final boolean usingSavedSurfaceBeforeVisible = oldVisibility != View.VISIBLE && win.isAnimatingWithSavedSurface();
            if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
                if (winAnimator.hasSurface() && !win.mAnimatingExit && usingSavedSurfaceBeforeVisible) {
                    Slog.d(TAG, "Ignoring layout to invisible when using saved surface " + win);
                }
            }
            if (winAnimator.hasSurface() && !win.mAnimatingExit && !usingSavedSurfaceBeforeVisible) {
                if (DEBUG_VISIBILITY)
                    Slog.i(TAG_WM, "Relayout invis " + win + ": mAnimatingExit=" + win.mAnimatingExit);
                // So we just do nothing on our side.
                if (!win.mWillReplaceWindow) {
                    focusMayChange = tryStartExitingAnimation(win, winAnimator, isDefaultDisplay, focusMayChange);
                }
                result |= RELAYOUT_RES_SURFACE_CHANGED;
            }
            if (viewVisibility == View.VISIBLE && winAnimator.hasSurface()) {
                // We already told the client to go invisible, but the message may not be
                // handled yet, or it might want to draw a last frame. If we already have a
                // surface, let the client use that, but don't create new surface at this point.
                winAnimator.mSurfaceController.getSurface(outSurface);
            } else {
                if (DEBUG_VISIBILITY)
                    Slog.i(TAG_WM, "Releasing surface in: " + win);
                try {
                    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmReleaseOutSurface_" + win.mAttrs.getTitle());
                    outSurface.release();
                } finally {
                    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
                }
            }
        }
        if (focusMayChange) {
            //System.out.println("Focus may change: " + win.mAttrs.getTitle());
            if (updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, false)) {
                imMayMove = false;
            }
        //System.out.println("Relayout " + win + ": focus=" + mCurrentFocus);
        }
        // updateFocusedWindowLocked() already assigned layers so we only need to
        // reassign them at this point if the IM window state gets shuffled
        boolean toBeDisplayed = (result & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0;
        if (imMayMove && (moveInputMethodWindowsIfNeededLocked(false) || toBeDisplayed)) {
            // Little hack here -- we -should- be able to rely on the
            // function to return true if the IME has moved and needs
            // its layer recomputed.  However, if the IME was hidden
            // and isn't actually moved in the list, its layer may be
            // out of data so we make sure to recompute it.
            mLayersController.assignLayersLocked(win.getWindowList());
        }
        if (wallpaperMayMove) {
            getDefaultDisplayContentLocked().pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
        }
        win.setDisplayLayoutNeeded();
        win.mGivenInsetsPending = (flags & WindowManagerGlobal.RELAYOUT_INSETS_PENDING) != 0;
        configChanged = updateOrientationFromAppTokensLocked(false);
        mWindowPlacerLocked.performSurfacePlacement();
        if (toBeDisplayed && win.mIsWallpaper) {
            DisplayInfo displayInfo = getDefaultDisplayInfoLocked();
            mWallpaperControllerLocked.updateWallpaperOffset(win, displayInfo.logicalWidth, displayInfo.logicalHeight, false);
        }
        if (win.mAppToken != null) {
            win.mAppToken.updateReportedVisibilityLocked();
        }
        if (winAnimator.mReportSurfaceResized) {
            winAnimator.mReportSurfaceResized = false;
            result |= WindowManagerGlobal.RELAYOUT_RES_SURFACE_RESIZED;
        }
        if (mPolicy.isNavBarForcedShownLw(win)) {
            result |= WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_NAV_BAR;
        }
        if (!win.isGoneForLayoutLw()) {
            win.mResizedWhileGone = false;
        }
        outFrame.set(win.mCompatFrame);
        outOverscanInsets.set(win.mOverscanInsets);
        outContentInsets.set(win.mContentInsets);
        outVisibleInsets.set(win.mVisibleInsets);
        outStableInsets.set(win.mStableInsets);
        outOutsets.set(win.mOutsets);
        outBackdropFrame.set(win.getBackdropFrame(win.mFrame));
        if (localLOGV)
            Slog.v(TAG_WM, "Relayout given client " + client.asBinder() + ", requestedWidth=" + requestedWidth + ", requestedHeight=" + requestedHeight + ", viewVisibility=" + viewVisibility + "\nRelayout returning frame=" + outFrame + ", surface=" + outSurface);
        if (localLOGV || DEBUG_FOCUS)
            Slog.v(TAG_WM, "Relayout of " + win + ": focusMayChange=" + focusMayChange);
        result |= mInTouchMode ? WindowManagerGlobal.RELAYOUT_RES_IN_TOUCH_MODE : 0;
        mInputMonitor.updateInputWindowsLw(true);
        if (DEBUG_LAYOUT) {
            Slog.v(TAG_WM, "Relayout complete " + win + ": outFrame=" + outFrame.toShortString());
        }
        win.mInRelayout = false;
    }
    if (configChanged) {
        sendNewConfiguration();
    }
    Binder.restoreCallingIdentity(origId);
    return result;
}
Also used : DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point) RemoteException(android.os.RemoteException) IOException(java.io.IOException) OutOfResourcesException(android.view.Surface.OutOfResourcesException) FileNotFoundException(java.io.FileNotFoundException)

Example 27 with DisplayInfo

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

the class WindowStateAnimator method stepAnimationLocked.

// This must be called while inside a transaction.  Returns true if
// there is more animation to run.
boolean stepAnimationLocked(long currentTime) {
    // Save the animation state as it was before this step so WindowManagerService can tell if
    // we just started or just stopped animating by comparing mWasAnimating with isAnimationSet().
    mWasAnimating = mAnimating;
    final DisplayContent displayContent = mWin.getDisplayContent();
    if (displayContent != null && mService.okToDisplay()) {
        if (mWin.isDrawnLw() && mAnimation != null) {
            mHasTransformation = true;
            mHasLocalTransformation = true;
            if (!mLocalAnimating) {
                if (DEBUG_ANIM)
                    Slog.v(TAG, "Starting animation in " + this + " @ " + currentTime + ": ww=" + mWin.mFrame.width() + " wh=" + mWin.mFrame.height() + " dx=" + mAnimDx + " dy=" + mAnimDy + " scale=" + mService.getWindowAnimationScaleLocked());
                final DisplayInfo displayInfo = displayContent.getDisplayInfo();
                if (mAnimateMove) {
                    mAnimateMove = false;
                    mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), mAnimDx, mAnimDy);
                } else {
                    mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), displayInfo.appWidth, displayInfo.appHeight);
                }
                mAnimDx = displayInfo.appWidth;
                mAnimDy = displayInfo.appHeight;
                mAnimation.setStartTime(mAnimationStartTime != -1 ? mAnimationStartTime : currentTime);
                mLocalAnimating = true;
                mAnimating = true;
            }
            if ((mAnimation != null) && mLocalAnimating) {
                mLastAnimationTime = currentTime;
                if (stepAnimation(currentTime)) {
                    return true;
                }
            }
            if (DEBUG_ANIM)
                Slog.v(TAG, "Finished animation in " + this + " @ " + currentTime);
        //WindowManagerService.this.dump();
        }
        mHasLocalTransformation = false;
        if ((!mLocalAnimating || mAnimationIsEntrance) && mAppAnimator != null && mAppAnimator.animation != null) {
            // When our app token is animating, we kind-of pretend like
            // we are as well.  Note the mLocalAnimating mAnimationIsEntrance
            // part of this check means that we will only do this if
            // our window is not currently exiting, or it is not
            // locally animating itself.  The idea being that one that
            // is exiting and doing a local animation should be removed
            // once that animation is done.
            mAnimating = true;
            mHasTransformation = true;
            mTransformation.clear();
            return false;
        } else if (mHasTransformation) {
            // Little trick to get through the path below to act like
            // we have finished an animation.
            mAnimating = true;
        } else if (isAnimationSet()) {
            mAnimating = true;
        }
    } else if (mAnimation != null) {
        // If the display is frozen, and there is a pending animation,
        // clear it and make sure we run the cleanup code.
        mAnimating = true;
    }
    if (!mAnimating && !mLocalAnimating) {
        return false;
    }
    // Done animating, clean up.
    if (DEBUG_ANIM)
        Slog.v(TAG, "Animation done in " + this + ": exiting=" + mWin.mAnimatingExit + ", reportedVisible=" + (mWin.mAppToken != null ? mWin.mAppToken.reportedVisible : false));
    mAnimating = false;
    mKeyguardGoingAwayAnimation = false;
    mKeyguardGoingAwayWithWallpaper = false;
    mLocalAnimating = false;
    if (mAnimation != null) {
        mAnimation.cancel();
        mAnimation = null;
    }
    if (mAnimator.mWindowDetachedWallpaper == mWin) {
        mAnimator.mWindowDetachedWallpaper = null;
    }
    mAnimLayer = mWin.mLayer + mService.mLayersController.getSpecialWindowAnimLayerAdjustment(mWin);
    if (DEBUG_LAYERS)
        Slog.v(TAG, "Stepping win " + this + " anim layer: " + mAnimLayer);
    mHasTransformation = false;
    mHasLocalTransformation = false;
    mStackClip = STACK_CLIP_BEFORE_ANIM;
    mWin.checkPolicyVisibilityChange();
    mTransformation.clear();
    if (mDrawState == HAS_DRAWN && mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING && mWin.mAppToken != null && mWin.mAppToken.firstWindowDrawn && mWin.mAppToken.startingData != null) {
        if (DEBUG_STARTING_WINDOW)
            Slog.v(TAG, "Finish starting " + mWin.mToken + ": first real window done animating");
        mService.mFinishedStarting.add(mWin.mAppToken);
        mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
    } else if (mAttrType == LayoutParams.TYPE_STATUS_BAR && mWin.mPolicyVisibility) {
        // required.
        if (displayContent != null) {
            displayContent.layoutNeeded = true;
        }
    }
    finishExit();
    final int displayId = mWin.getDisplayId();
    mAnimator.setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
    if (DEBUG_LAYOUT_REPEATS)
        mService.mWindowPlacerLocked.debugLayoutRepeats("WindowStateAnimator", mAnimator.getPendingLayoutChanges(displayId));
    if (mWin.mAppToken != null) {
        mWin.mAppToken.updateReportedVisibilityLocked();
    }
    return false;
}
Also used : DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Example 28 with DisplayInfo

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

the class WindowManagerService method applyAnimationLocked.

private boolean applyAnimationLocked(AppWindowToken atoken, WindowManager.LayoutParams lp, int transit, boolean enter, boolean isVoiceInteraction) {
    // Only apply an animation if the display isn't frozen.  If it is
    // frozen, there is no reason to animate and it can cause strange
    // artifacts when we unfreeze the display if some different animation
    // is running.
    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "WM#applyAnimationLocked");
    if (okToDisplay()) {
        DisplayInfo displayInfo = getDefaultDisplayInfoLocked();
        final int width = displayInfo.appWidth;
        final int height = displayInfo.appHeight;
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG_WM, "applyAnimation: atoken=" + atoken);
        // Determine the visible rect to calculate the thumbnail clip
        final WindowState win = atoken.findMainWindow();
        final Rect frame = new Rect(0, 0, width, height);
        final Rect displayFrame = new Rect(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
        final Rect insets = new Rect();
        Rect surfaceInsets = null;
        final boolean freeform = win != null && win.inFreeformWorkspace();
        if (win != null) {
            // the status bar). In that case we need to use the final frame.
            if (freeform) {
                frame.set(win.mFrame);
            } else {
                frame.set(win.mContainingFrame);
            }
            surfaceInsets = win.getAttrs().surfaceInsets;
            insets.set(win.mContentInsets);
        }
        if (atoken.mLaunchTaskBehind) {
            // Differentiate the two animations. This one which is briefly on the screen
            // gets the !enter animation, and the other activity which remains on the
            // screen gets the enter animation. Both appear in the mOpeningApps set.
            enter = false;
        }
        if (DEBUG_APP_TRANSITIONS)
            Slog.d(TAG_WM, "Loading animation for app transition." + " transit=" + AppTransition.appTransitionToString(transit) + " enter=" + enter + " frame=" + frame + " insets=" + insets + " surfaceInsets=" + surfaceInsets);
        Animation a = mAppTransition.loadAnimation(lp, transit, enter, mCurConfiguration.uiMode, mCurConfiguration.orientation, frame, displayFrame, insets, surfaceInsets, isVoiceInteraction, freeform, atoken.mTask.mTaskId);
        if (a != null) {
            if (DEBUG_ANIM)
                logWithStack(TAG, "Loaded animation " + a + " for " + atoken);
            final int containingWidth = frame.width();
            final int containingHeight = frame.height();
            atoken.mAppAnimator.setAnimation(a, containingWidth, containingHeight, mAppTransition.canSkipFirstFrame(), mAppTransition.getAppStackClipMode());
        }
    } else {
        atoken.mAppAnimator.clearAnimation();
    }
    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
    return atoken.mAppAnimator.animation != null;
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo) Animation(android.view.animation.Animation) Point(android.graphics.Point)

Example 29 with DisplayInfo

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

the class WindowManagerService method newDisplayContentLocked.

private DisplayContent newDisplayContentLocked(final Display display) {
    DisplayContent displayContent = new DisplayContent(display, this);
    final int displayId = display.getDisplayId();
    if (DEBUG_DISPLAY)
        Slog.v(TAG_WM, "Adding display=" + display);
    mDisplayContents.put(displayId, displayContent);
    DisplayInfo displayInfo = displayContent.getDisplayInfo();
    final Rect rect = new Rect();
    mDisplaySettings.getOverscanLocked(displayInfo.name, displayInfo.uniqueId, rect);
    displayInfo.overscanLeft = rect.left;
    displayInfo.overscanTop = rect.top;
    displayInfo.overscanRight = rect.right;
    displayInfo.overscanBottom = rect.bottom;
    mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(displayId, displayInfo);
    configureDisplayPolicyLocked(displayContent);
    // TODO: Create an input channel for each display with touch capability.
    if (displayId == Display.DEFAULT_DISPLAY) {
        displayContent.mTapDetector = new TaskTapPointerEventListener(this, displayContent);
        registerPointerEventListener(displayContent.mTapDetector);
        registerPointerEventListener(mMousePositionTracker);
    }
    return displayContent;
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Example 30 with DisplayInfo

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

the class WindowManagerService method computeScreenConfigurationLocked.

/** Do not call if mDisplayReady == false */
void computeScreenConfigurationLocked(Configuration config) {
    final DisplayInfo displayInfo = updateDisplayAndOrientationLocked(config.uiMode);
    final int dw = displayInfo.logicalWidth;
    final int dh = displayInfo.logicalHeight;
    config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
    config.screenWidthDp = (int) (mPolicy.getConfigDisplayWidth(dw, dh, mRotation, config.uiMode) / mDisplayMetrics.density);
    config.screenHeightDp = (int) (mPolicy.getConfigDisplayHeight(dw, dh, mRotation, config.uiMode) / mDisplayMetrics.density);
    final boolean rotated = (mRotation == Surface.ROTATION_90 || mRotation == Surface.ROTATION_270);
    computeSizeRangesAndScreenLayout(displayInfo, rotated, config.uiMode, dw, dh, mDisplayMetrics.density, config);
    config.screenLayout = (config.screenLayout & ~Configuration.SCREENLAYOUT_ROUND_MASK) | ((displayInfo.flags & Display.FLAG_ROUND) != 0 ? Configuration.SCREENLAYOUT_ROUND_YES : Configuration.SCREENLAYOUT_ROUND_NO);
    config.compatScreenWidthDp = (int) (config.screenWidthDp / mCompatibleScreenScale);
    config.compatScreenHeightDp = (int) (config.screenHeightDp / mCompatibleScreenScale);
    config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, config.uiMode, mDisplayMetrics, dw, dh);
    config.densityDpi = displayInfo.logicalDensityDpi;
    // 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;
            }
        }
    }
    if (config.navigation == Configuration.NAVIGATION_NONAV && mHasPermanentDpad) {
        config.navigation = Configuration.NAVIGATION_DPAD;
        navigationPresence |= WindowManagerPolicy.PRESENCE_INTERNAL;
    }
    // Determine whether a hard keyboard is available and enabled.
    boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
    if (hardKeyboardAvailable != mHardKeyboardAvailable) {
        mHardKeyboardAvailable = hardKeyboardAvailable;
        mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
        mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
    }
    // 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);
}
Also used : InputDevice(android.view.InputDevice) DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Aggregations

DisplayInfo (android.view.DisplayInfo)186 Point (android.graphics.Point)53 Rect (android.graphics.Rect)29 RemoteException (android.os.RemoteException)19 Display (android.view.Display)11 Animation (android.view.animation.Animation)10 Bitmap (android.graphics.Bitmap)9 WindowManager (android.view.WindowManager)8 DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)8 Canvas (android.graphics.Canvas)6 SurfaceControl (android.view.SurfaceControl)6 LayoutParams (android.view.WindowManager.LayoutParams)6 DisplayManager (android.hardware.display.DisplayManager)5 DisplayMetrics (android.util.DisplayMetrics)5 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 OutOfResourcesException (android.view.Surface.OutOfResourcesException)3