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

Commit 9ceaf99a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7692139 from 849f43ac to sc-qpr1-release

Change-Id: Ie4b51b5839b363221c9feb201463e51a7301755b
parents 3d2cf73d 849f43ac
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -464,11 +464,7 @@ public final class ActivityThread extends ClientTransactionHandler

        @Override
        public int hashCode() {
            return hashCode(authority, userId);
        }

        public static int hashCode(final String auth, final int userIdent) {
            return ((auth != null) ? auth.hashCode() : 0) ^ userIdent;
            return ((authority != null) ? authority.hashCode() : 0) ^ userId;
        }
    }

@@ -490,7 +486,7 @@ public final class ActivityThread extends ClientTransactionHandler
    // Note we never removes items from this map but that's okay because there are only so many
    // users and so many authorities.
    @GuardedBy("mGetProviderKeys")
    final SparseArray<ProviderKey> mGetProviderKeys = new SparseArray<>();
    final ArrayMap<ProviderKey, ProviderKey> mGetProviderKeys = new ArrayMap<>();

    final ArrayMap<Activity, ArrayList<OnActivityPausedListener>> mOnPauseListeners
        = new ArrayMap<Activity, ArrayList<OnActivityPausedListener>>();
@@ -7016,11 +7012,11 @@ public final class ActivityThread extends ClientTransactionHandler
    }

    private ProviderKey getGetProviderKey(String auth, int userId) {
        final int key = ProviderKey.hashCode(auth, userId);
        final ProviderKey key = new ProviderKey(auth, userId);
        synchronized (mGetProviderKeys) {
            ProviderKey lock = mGetProviderKeys.get(key);
            if (lock == null) {
                lock = new ProviderKey(auth, userId);
                lock = key;
                mGetProviderKeys.put(key, lock);
            }
            return lock;
+22 −7
Original line number Diff line number Diff line
@@ -361,6 +361,11 @@ public final class DisplayManagerGlobal {
        for (int i = 0; i < numListeners; i++) {
            mask |= mDisplayListeners.get(i).mEventsMask;
        }
        if (mDispatchNativeCallbacks) {
            mask |= DisplayManager.EVENT_FLAG_DISPLAY_ADDED
                    | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
                    | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
        }
        return mask;
    }

@@ -1047,12 +1052,17 @@ public final class DisplayManagerGlobal {

    private static native void nSignalNativeCallbacks(float refreshRate);

    // Called from AChoreographer via JNI.
    // Registers AChoreographer so that refresh rate callbacks can be dispatched from DMS.
    private void registerNativeChoreographerForRefreshRateCallbacks() {
    /**
     * Called from AChoreographer via JNI.
     * Registers AChoreographer so that refresh rate callbacks can be dispatched from DMS.
     * Public for unit testing to be able to call this method.
     */
    @VisibleForTesting
    public void registerNativeChoreographerForRefreshRateCallbacks() {
        synchronized (mLock) {
            registerCallbackIfNeededLocked();
            mDispatchNativeCallbacks = true;
            registerCallbackIfNeededLocked();
            updateCallbackIfNeededLocked();
            DisplayInfo display = getDisplayInfoLocked(Display.DEFAULT_DISPLAY);
            if (display != null) {
                // We need to tell AChoreographer instances the current refresh rate so that apps
@@ -1063,11 +1073,16 @@ public final class DisplayManagerGlobal {
        }
    }

    // Called from AChoreographer via JNI.
    // Unregisters AChoreographer from receiving refresh rate callbacks.
    private void unregisterNativeChoreographerForRefreshRateCallbacks() {
    /**
     * Called from AChoreographer via JNI.
     * Unregisters AChoreographer from receiving refresh rate callbacks.
     * Public for unit testing to be able to call this method.
     */
    @VisibleForTesting
    public void unregisterNativeChoreographerForRefreshRateCallbacks() {
        synchronized (mLock) {
            mDispatchNativeCallbacks = false;
            updateCallbackIfNeededLocked();
        }
    }
}
+41 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -121,6 +122,46 @@ public class DisplayManagerGlobalTest {
        Mockito.verifyZeroInteractions(mListener);
    }

    @Test
    public void testDisplayManagerGlobalRegistersWithDisplayManager_WhenThereAreNoOtherListeners()
            throws RemoteException {
        mDisplayManagerGlobal.registerNativeChoreographerForRefreshRateCallbacks();
        Mockito.verify(mDisplayManager)
                .registerCallbackWithEventMask(mCallbackCaptor.capture(), eq(ALL_DISPLAY_EVENTS));

        mDisplayManagerGlobal.unregisterNativeChoreographerForRefreshRateCallbacks();
        Mockito.verify(mDisplayManager)
                .registerCallbackWithEventMask(mCallbackCaptor.capture(), eq(0L));

    }

    @Test
    public void testDisplayManagerGlobalRegistersWithDisplayManager_WhenThereAreListeners()
            throws RemoteException {
        mDisplayManagerGlobal.registerDisplayListener(mListener, mHandler,
                DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS);
        InOrder inOrder = Mockito.inOrder(mDisplayManager);

        inOrder.verify(mDisplayManager)
                .registerCallbackWithEventMask(mCallbackCaptor.capture(),
                        eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));

        mDisplayManagerGlobal.registerNativeChoreographerForRefreshRateCallbacks();
        inOrder.verify(mDisplayManager)
                .registerCallbackWithEventMask(mCallbackCaptor.capture(),
                        eq(ALL_DISPLAY_EVENTS | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));

        mDisplayManagerGlobal.unregisterNativeChoreographerForRefreshRateCallbacks();
        inOrder.verify(mDisplayManager)
                .registerCallbackWithEventMask(mCallbackCaptor.capture(),
                        eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));

        mDisplayManagerGlobal.unregisterDisplayListener(mListener);
        inOrder.verify(mDisplayManager)
                .registerCallbackWithEventMask(mCallbackCaptor.capture(), eq(0L));

    }

    private void waitForHandler() {
        mHandler.runWithScissors(() -> { }, 0);
    }
+1 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.view.ContextThemeWrapper;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
import android.view.animation.LinearInterpolator;
@@ -33,7 +34,6 @@ import android.window.DisplayAreaOrganizer;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.view.ContextThemeWrapper;

import com.android.wm.shell.R;
import com.android.wm.shell.common.DisplayLayout;
+379 −260

File changed.

Preview size limit exceeded, changes collapsed.

Loading