Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ce896ca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Added foundation for supporting unit tests in WindowManager"

parents 0506f45b b699ce0d
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.app.ActivityManager.StackId;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region.Op;
import android.hardware.display.DisplayManagerInternal;
import android.util.DisplayMetrics;
import android.util.Slog;
import android.view.Display;
@@ -197,12 +198,15 @@ class DisplayContent {
    }

    void initializeDisplayBaseInfo() {
        final DisplayManagerInternal displayManagerInternal = mService.mDisplayManagerInternal;
        if (displayManagerInternal != null) {
            // Bootstrap the default logical display from the display manager.
        final DisplayInfo newDisplayInfo =
                mService.mDisplayManagerInternal.getDisplayInfo(mDisplayId);
            final DisplayInfo newDisplayInfo = displayManagerInternal.getDisplayInfo(mDisplayId);
            if (newDisplayInfo != null) {
                mDisplayInfo.copyFrom(newDisplayInfo);
            }
        }

        mBaseDisplayWidth = mInitialDisplayWidth = mDisplayInfo.logicalWidth;
        mBaseDisplayHeight = mInitialDisplayHeight = mDisplayInfo.logicalHeight;
        mBaseDisplayDensity = mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi;
+27 −26
Original line number Diff line number Diff line
@@ -389,7 +389,7 @@ public class WindowManagerService extends IWindowManager.Stub

    final boolean mLimitedAlphaCompositing;

    final WindowManagerPolicy mPolicy = new PhoneWindowManager();
    final WindowManagerPolicy mPolicy;

    final IActivityManager mActivityManager;
    final ActivityManagerInternal mAmInternal;
@@ -925,14 +925,11 @@ public class WindowManagerService extends IWindowManager.Stub
    public static WindowManagerService main(final Context context,
            final InputManagerService im,
            final boolean haveInputMethods, final boolean showBootMsgs,
            final boolean onlyCore) {
            final boolean onlyCore, WindowManagerPolicy policy) {
        final WindowManagerService[] holder = new WindowManagerService[1];
        DisplayThread.getHandler().runWithScissors(new Runnable() {
            @Override
            public void run() {
                holder[0] = new WindowManagerService(context, im,
                        haveInputMethods, showBootMsgs, onlyCore);
            }
        DisplayThread.getHandler().runWithScissors(() -> {
            holder[0] = new WindowManagerService(context, im, haveInputMethods, showBootMsgs,
                    onlyCore, policy);
        }, 0);
        return holder[0];
    }
@@ -949,7 +946,8 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    private WindowManagerService(Context context, InputManagerService inputManager,
            boolean haveInputMethods, boolean showBootMsgs, boolean onlyCore) {
            boolean haveInputMethods, boolean showBootMsgs, boolean onlyCore,
            WindowManagerPolicy policy) {
        mContext = context;
        mHaveInputMethods = haveInputMethods;
        mAllowBootMessages = showBootMsgs;
@@ -972,10 +970,12 @@ public class WindowManagerService extends IWindowManager.Stub
        mWallpaperControllerLocked = new WallpaperController(this);
        mWindowPlacerLocked = new WindowSurfacePlacer(this);
        mLayersController = new WindowLayersController(this);
        mPolicy = policy;

        LocalServices.addService(WindowManagerPolicy.class, mPolicy);

        mPointerEventDispatcher = new PointerEventDispatcher(mInputManager.monitorInput(TAG_WM));
        mPointerEventDispatcher = mInputManager != null
                ? new PointerEventDispatcher(mInputManager.monitorInput(TAG_WM)) : null;

        mFxSession = new SurfaceSession();
        mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
@@ -988,19 +988,18 @@ public class WindowManagerService extends IWindowManager.Stub

        mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
        mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);
        mPowerManagerInternal.registerLowPowerModeObserver(
                new PowerManagerInternal.LowPowerModeListener() {
            @Override
            public void onLowPowerModeChanged(boolean enabled) {

        if (mPowerManagerInternal != null) {
            mPowerManagerInternal.registerLowPowerModeObserver((enabled) -> {
                synchronized (mWindowMap) {
                    if (mAnimationsDisabled != enabled && !mAllowAnimationsInLowPowerMode) {
                        mAnimationsDisabled = enabled;
                        dispatchNewAnimatorScaleLocked(null);
                    }
                }
            }
            });
            mAnimationsDisabled = mPowerManagerInternal.getLowPowerModeEnabled();
        }
        mScreenFrozenLock = mPowerManager.newWakeLock(
                PowerManager.PARTIAL_WAKE_LOCK, "SCREEN_FROZEN");
        mScreenFrozenLock.setReferenceCounted(false);
@@ -2032,8 +2031,8 @@ public class WindowManagerService extends IWindowManager.Stub
                addToken = true;
            }

            WindowState win = new WindowState(this, session, client, token,
                    attachedWindow, appOp[0], seq, attrs, viewVisibility, displayContent);
            WindowState win = new WindowState(this, session, client, token, attachedWindow,
                    appOp[0], seq, attrs, viewVisibility, displayContent, session.mUid);
            if (win.mDeathRecipient == null) {
                // Client has apparently died, so there is no reason to
                // continue.
@@ -10808,6 +10807,7 @@ public class WindowManagerService extends IWindowManager.Stub
        displayInfo.overscanTop = rect.top;
        displayInfo.overscanRight = rect.right;
        displayInfo.overscanBottom = rect.bottom;
        if (mDisplayManagerInternal != null) {
            mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(displayId, displayInfo);
            configureDisplayPolicyLocked(displayContent);

@@ -10817,6 +10817,7 @@ public class WindowManagerService extends IWindowManager.Stub
                registerPointerEventListener(displayContent.mTapDetector);
                registerPointerEventListener(mMousePositionTracker);
            }
        }

        return displayContent;
    }
+2 −2
Original line number Diff line number Diff line
@@ -505,13 +505,13 @@ final class WindowState implements WindowManagerPolicy.WindowState {

    WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
           WindowState parentWindow, int appOp, int seq, WindowManager.LayoutParams a,
           int viewVisibility, final DisplayContent displayContent) {
           int viewVisibility, final DisplayContent displayContent, int ownerId) {
        mService = service;
        mSession = s;
        mClient = c;
        mAppOp = appOp;
        mToken = token;
        mOwnerUid = s.mUid;
        mOwnerUid = ownerId;
        mWindowId = new IWindowId.Stub() {
            @Override
            public void registerFocusObserver(IWindowFocusObserver observer) {
+2 −1
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import com.android.server.pm.OtaDexoptService;
import com.android.server.pm.PackageManagerService;
import com.android.server.pm.ShortcutService;
import com.android.server.pm.UserManagerService;
import com.android.server.policy.PhoneWindowManager;
import com.android.server.power.PowerManagerService;
import com.android.server.power.ShutdownThread;
import com.android.server.restrictions.RestrictionsManagerService;
@@ -616,7 +617,7 @@ public final class SystemServer {
            traceBeginAndSlog("StartWindowManagerService");
            wm = WindowManagerService.main(context, inputManager,
                    mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL,
                    !mFirstBoot, mOnlyCore);
                    !mFirstBoot, mOnlyCore, new PhoneWindowManager());
            ServiceManager.addService(Context.WINDOW_SERVICE, wm);
            ServiceManager.addService(Context.INPUT_SERVICE, inputManager);
            Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
+110 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.server.wm;

import com.android.internal.os.IResultReceiver;

import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.view.DragEvent;
import android.view.IWindow;

public class TestIWindow extends IWindow.Stub {
    @Override
    public void executeCommand(String command, String parameters,
            ParcelFileDescriptor descriptor)
            throws RemoteException {

    }

    @Override
    public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets,
            Rect stableInsets, Rect outsets, boolean reportDraw, Configuration newConfig,
            Rect backDropFrame, boolean forceLayout, boolean alwaysConsumeNavBar)
            throws RemoteException {

    }

    @Override
    public void moved(int newX, int newY) throws RemoteException {

    }

    @Override
    public void dispatchAppVisibility(boolean visible) throws RemoteException {

    }

    @Override
    public void dispatchGetNewSurface() throws RemoteException {

    }

    @Override
    public void windowFocusChanged(boolean hasFocus, boolean inTouchMode)
            throws RemoteException {

    }

    @Override
    public void closeSystemDialogs(String reason) throws RemoteException {

    }

    @Override
    public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep,
            boolean sync)
            throws RemoteException {

    }

    @Override
    public void dispatchWallpaperCommand(String action, int x, int y, int z, Bundle extras,
            boolean sync) throws RemoteException {

    }

    @Override
    public void dispatchDragEvent(DragEvent event) throws RemoteException {

    }

    @Override
    public void updatePointerIcon(float x, float y) throws RemoteException {

    }

    @Override
    public void dispatchSystemUiVisibilityChanged(int seq, int globalVisibility, int localValue,
            int localChanges) throws RemoteException {

    }

    @Override
    public void dispatchWindowShown() throws RemoteException {

    }

    @Override
    public void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId)
            throws RemoteException {

    }
}
Loading