Remove more thin wrappers from the shared lib

- These were only used for the unbundled launcher build, and Launcher
  can reference system code directly now

Bug: 219861883
Test: Builds/Presubmit
Change-Id: I1532f1b853765fb69c5bf46ad5a08230bde00c5f
Merged-In: I1532f1b853765fb69c5bf46ad5a08230bde00c5f
This commit is contained in:
Winson Chung
2022-09-09 22:20:59 +00:00
parent de5f0ae846
commit 7d4a22c86c
14 changed files with 56 additions and 596 deletions

View File

@@ -17,11 +17,10 @@
package com.android.systemui.shared.recents.model;
import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
import static android.graphics.Bitmap.Config.ARGB_8888;
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_UNDEFINED;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2018 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.systemui.shared.system;
import android.app.Activity;
import android.view.View;
import android.view.ViewHierarchyEncoder;
import java.io.ByteArrayOutputStream;
public class ActivityCompat {
private final Activity mWrapped;
public ActivityCompat(Activity activity) {
mWrapped = activity;
}
/**
* @see Activity#registerRemoteAnimations
*/
public void registerRemoteAnimations(RemoteAnimationDefinitionCompat definition) {
mWrapped.registerRemoteAnimations(definition.getWrapped());
}
/**
* @see Activity#unregisterRemoteAnimations
*/
public void unregisterRemoteAnimations() {
mWrapped.unregisterRemoteAnimations();
}
}

View File

@@ -1,85 +0,0 @@
/*
* Copyright (C) 2017 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.systemui.shared.system;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import android.app.ActivityOptions;
import android.content.Context;
import android.os.Handler;
/**
* Wrapper around internal ActivityOptions creation.
*/
public abstract class ActivityOptionsCompat {
/**
* @return ActivityOptions for starting a task in freeform.
*/
public static ActivityOptions makeFreeformOptions() {
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
return options;
}
public static ActivityOptions makeRemoteAnimation(
RemoteAnimationAdapterCompat remoteAnimationAdapter) {
return ActivityOptions.makeRemoteAnimation(remoteAnimationAdapter.getWrapped(),
remoteAnimationAdapter.getRemoteTransition().getTransition());
}
/**
* Constructs an ActivityOptions object that will delegate its transition handling to a
* `remoteTransition`.
*/
public static ActivityOptions makeRemoteTransition(RemoteTransitionCompat remoteTransition) {
return ActivityOptions.makeRemoteTransition(remoteTransition.getTransition());
}
/**
* Returns ActivityOptions for overriding task transition animation.
*/
public static ActivityOptions makeCustomAnimation(Context context, int enterResId,
int exitResId, final Runnable callback, final Handler callbackHandler) {
return ActivityOptions.makeCustomTaskAnimation(context, enterResId, exitResId,
callbackHandler,
new ActivityOptions.OnAnimationStartedListener() {
@Override
public void onAnimationStarted(long elapsedRealTime) {
if (callback != null) {
callbackHandler.post(callback);
}
}
}, null /* finishedListener */);
}
/**
* Sets the flag to freeze the recents task list reordering as a part of launching the activity.
*/
public static ActivityOptions setFreezeRecentTasksList(ActivityOptions opts) {
opts.setFreezeRecentTasksReordering();
return opts;
}
/**
* Sets the launch event time from launcher.
*/
public static ActivityOptions setLauncherSourceInfo(ActivityOptions opts, long uptimeMillis) {
opts.setSourceInfo(ActivityOptions.SourceInfo.TYPE_LAUNCHER, uptimeMillis);
return opts;
}
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright (C) 2020 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.systemui.shared.system;
import android.annotation.UserIdInt;
import android.content.Context;
public class ContextUtils {
/** Get the user associated with this context */
public static @UserIdInt int getUserId(Context context) {
return context.getUserId();
}
}

View File

@@ -1,32 +0,0 @@
/*
* Copyright (C) 2018 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.systemui.shared.system;
import android.app.KeyguardManager;
import android.content.Context;
public class KeyguardManagerCompat {
private final KeyguardManager mKeyguardManager;
public KeyguardManagerCompat(Context context) {
mKeyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
}
public boolean isDeviceLocked(int userId) {
return mKeyguardManager.isDeviceLocked(userId);
}
}

View File

@@ -1,33 +0,0 @@
/*
* Copyright (C) 2018 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.systemui.shared.system;
import android.content.Context;
import com.android.internal.util.LatencyTracker;
/**
* @see LatencyTracker
*/
public class LatencyTrackerCompat {
/** @see LatencyTracker */
public static void logToggleRecents(Context context, int duration) {
LatencyTracker.getInstance(context).logAction(LatencyTracker.ACTION_TOGGLE_RECENTS,
duration);
}
}

View File

@@ -58,7 +58,7 @@ public class RemoteAnimationAdapterCompat {
mRemoteTransition = buildRemoteTransition(runner, appThread);
}
RemoteAnimationAdapter getWrapped() {
public RemoteAnimationAdapter getWrapped() {
return mWrapped;
}

View File

@@ -34,7 +34,7 @@ public class RemoteAnimationDefinitionCompat {
mWrapped.addRemoteAnimation(transition, activityTypeFilter, adapter.getWrapped());
}
RemoteAnimationDefinition getWrapped() {
public RemoteAnimationDefinition getWrapped() {
return mWrapped;
}
}

View File

@@ -1,179 +0,0 @@
/*
* Copyright (C) 2020 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.systemui.shared.system;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.graphics.Rect;
import android.graphics.Region;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
import java.util.HashMap;
public class ViewTreeObserverWrapper {
private static final HashMap<OnComputeInsetsListener, ViewTreeObserver>
sListenerObserverMap = new HashMap<>();
private static final HashMap<OnComputeInsetsListener, OnComputeInternalInsetsListener>
sListenerInternalListenerMap = new HashMap<>();
/**
* Register a callback to be invoked when the invoked when it is time to compute the window's
* insets.
*
* @param observer The observer to be added
* @param listener The callback to add
* @throws IllegalStateException If {@link ViewTreeObserver#isAlive()} returns false
*/
public static void addOnComputeInsetsListener(
@NonNull ViewTreeObserver observer, @NonNull OnComputeInsetsListener listener) {
final OnComputeInternalInsetsListener internalListener = internalInOutInfo -> {
final InsetsInfo inOutInfo = new InsetsInfo();
inOutInfo.contentInsets.set(internalInOutInfo.contentInsets);
inOutInfo.visibleInsets.set(internalInOutInfo.visibleInsets);
inOutInfo.touchableRegion.set(internalInOutInfo.touchableRegion);
listener.onComputeInsets(inOutInfo);
internalInOutInfo.contentInsets.set(inOutInfo.contentInsets);
internalInOutInfo.visibleInsets.set(inOutInfo.visibleInsets);
internalInOutInfo.touchableRegion.set(inOutInfo.touchableRegion);
internalInOutInfo.setTouchableInsets(inOutInfo.mTouchableInsets);
};
sListenerObserverMap.put(listener, observer);
sListenerInternalListenerMap.put(listener, internalListener);
observer.addOnComputeInternalInsetsListener(internalListener);
}
/**
* Remove a previously installed insets computation callback.
*
* @param victim The callback to remove
* @throws IllegalStateException If {@link ViewTreeObserver#isAlive()} returns false
* @see #addOnComputeInsetsListener(ViewTreeObserver, OnComputeInsetsListener)
*/
public static void removeOnComputeInsetsListener(@NonNull OnComputeInsetsListener victim) {
final ViewTreeObserver observer = sListenerObserverMap.get(victim);
final OnComputeInternalInsetsListener listener = sListenerInternalListenerMap.get(victim);
if (observer != null && listener != null) {
observer.removeOnComputeInternalInsetsListener(listener);
}
sListenerObserverMap.remove(victim);
sListenerInternalListenerMap.remove(victim);
}
/**
* Interface definition for a callback to be invoked when layout has
* completed and the client can compute its interior insets.
*/
public interface OnComputeInsetsListener {
/**
* Callback method to be invoked when layout has completed and the
* client can compute its interior insets.
*
* @param inoutInfo Should be filled in by the implementation with
* the information about the insets of the window. This is called
* with whatever values the previous OnComputeInsetsListener
* returned, if there are multiple such listeners in the window.
*/
void onComputeInsets(InsetsInfo inoutInfo);
}
/**
* Parameters used with OnComputeInsetsListener.
*/
public final static class InsetsInfo {
/**
* Offsets from the frame of the window at which the content of
* windows behind it should be placed.
*/
public final Rect contentInsets = new Rect();
/**
* Offsets from the frame of the window at which windows behind it
* are visible.
*/
public final Rect visibleInsets = new Rect();
/**
* Touchable region defined relative to the origin of the frame of the window.
* Only used when {@link #setTouchableInsets(int)} is called with
* the option {@link #TOUCHABLE_INSETS_REGION}.
*/
public final Region touchableRegion = new Region();
/**
* Option for {@link #setTouchableInsets(int)}: the entire window frame
* can be touched.
*/
public static final int TOUCHABLE_INSETS_FRAME =
ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
/**
* Option for {@link #setTouchableInsets(int)}: the area inside of
* the content insets can be touched.
*/
public static final int TOUCHABLE_INSETS_CONTENT =
ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT;
/**
* Option for {@link #setTouchableInsets(int)}: the area inside of
* the visible insets can be touched.
*/
public static final int TOUCHABLE_INSETS_VISIBLE =
ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE;
/**
* Option for {@link #setTouchableInsets(int)}: the area inside of
* the provided touchable region in {@link #touchableRegion} can be touched.
*/
public static final int TOUCHABLE_INSETS_REGION =
ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
/**
* Set which parts of the window can be touched: either
* {@link #TOUCHABLE_INSETS_FRAME}, {@link #TOUCHABLE_INSETS_CONTENT},
* {@link #TOUCHABLE_INSETS_VISIBLE}, or {@link #TOUCHABLE_INSETS_REGION}.
*/
public void setTouchableInsets(int val) {
mTouchableInsets = val;
}
int mTouchableInsets;
@Override
public int hashCode() {
int result = contentInsets.hashCode();
result = 31 * result + visibleInsets.hashCode();
result = 31 * result + touchableRegion.hashCode();
result = 31 * result + mTouchableInsets;
return result;
}
@Override
public boolean equals(@Nullable Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final InsetsInfo other = (InsetsInfo) o;
return mTouchableInsets == other.mTouchableInsets &&
contentInsets.equals(other.contentInsets) &&
visibleInsets.equals(other.visibleInsets) &&
touchableRegion.equals(other.touchableRegion);
}
}
}

View File

@@ -1,175 +0,0 @@
/*
* Copyright (C) 2017 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.systemui.shared.system;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_BOTTOM;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_RIGHT;
import android.app.WindowConfiguration;
import android.graphics.Rect;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
import android.view.InsetsController;
import android.view.InsetsFrameProvider;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.animation.Interpolator;
import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecsFuture;
import com.android.systemui.shared.recents.view.RecentsTransition;
public class WindowManagerWrapper {
private static final String TAG = "WindowManagerWrapper";
public static final int TRANSIT_UNSET = WindowManager.TRANSIT_OLD_UNSET;
public static final int TRANSIT_NONE = WindowManager.TRANSIT_OLD_NONE;
public static final int TRANSIT_ACTIVITY_OPEN = WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
public static final int TRANSIT_ACTIVITY_CLOSE = WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
public static final int TRANSIT_TASK_OPEN = WindowManager.TRANSIT_OLD_TASK_OPEN;
public static final int TRANSIT_TASK_CLOSE = WindowManager.TRANSIT_OLD_TASK_CLOSE;
public static final int TRANSIT_TASK_TO_FRONT = WindowManager.TRANSIT_OLD_TASK_TO_FRONT;
public static final int TRANSIT_TASK_TO_BACK = WindowManager.TRANSIT_OLD_TASK_TO_BACK;
public static final int TRANSIT_WALLPAPER_CLOSE = WindowManager.TRANSIT_OLD_WALLPAPER_CLOSE;
public static final int TRANSIT_WALLPAPER_OPEN = WindowManager.TRANSIT_OLD_WALLPAPER_OPEN;
public static final int TRANSIT_WALLPAPER_INTRA_OPEN =
WindowManager.TRANSIT_OLD_WALLPAPER_INTRA_OPEN;
public static final int TRANSIT_WALLPAPER_INTRA_CLOSE =
WindowManager.TRANSIT_OLD_WALLPAPER_INTRA_CLOSE;
public static final int TRANSIT_TASK_OPEN_BEHIND = WindowManager.TRANSIT_OLD_TASK_OPEN_BEHIND;
public static final int TRANSIT_ACTIVITY_RELAUNCH = WindowManager.TRANSIT_OLD_ACTIVITY_RELAUNCH;
public static final int TRANSIT_KEYGUARD_GOING_AWAY =
WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY;
public static final int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER =
WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
public static final int TRANSIT_KEYGUARD_OCCLUDE = WindowManager.TRANSIT_OLD_KEYGUARD_OCCLUDE;
public static final int TRANSIT_KEYGUARD_UNOCCLUDE =
WindowManager.TRANSIT_OLD_KEYGUARD_UNOCCLUDE;
public static final int NAV_BAR_POS_INVALID = NAV_BAR_INVALID;
public static final int NAV_BAR_POS_LEFT = NAV_BAR_LEFT;
public static final int NAV_BAR_POS_RIGHT = NAV_BAR_RIGHT;
public static final int NAV_BAR_POS_BOTTOM = NAV_BAR_BOTTOM;
public static final int ACTIVITY_TYPE_STANDARD = WindowConfiguration.ACTIVITY_TYPE_STANDARD;
public static final int WINDOWING_MODE_UNDEFINED = WindowConfiguration.WINDOWING_MODE_UNDEFINED;
public static final int WINDOWING_MODE_FULLSCREEN =
WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
public static final int WINDOWING_MODE_MULTI_WINDOW =
WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
public static final int WINDOWING_MODE_FREEFORM = WindowConfiguration.WINDOWING_MODE_FREEFORM;
public static final int ITYPE_EXTRA_NAVIGATION_BAR = InsetsState.ITYPE_EXTRA_NAVIGATION_BAR;
public static final int ITYPE_LEFT_TAPPABLE_ELEMENT = InsetsState.ITYPE_LEFT_TAPPABLE_ELEMENT;
public static final int ITYPE_TOP_TAPPABLE_ELEMENT = InsetsState.ITYPE_TOP_TAPPABLE_ELEMENT;
public static final int ITYPE_RIGHT_TAPPABLE_ELEMENT = InsetsState.ITYPE_RIGHT_TAPPABLE_ELEMENT;
public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT =
InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
public static final int ITYPE_SIZE = InsetsState.SIZE;
public static final int ANIMATION_DURATION_RESIZE = InsetsController.ANIMATION_DURATION_RESIZE;
public static final Interpolator RESIZE_INTERPOLATOR = InsetsController.RESIZE_INTERPOLATOR;
private static final WindowManagerWrapper sInstance = new WindowManagerWrapper();
public static WindowManagerWrapper getInstance() {
return sInstance;
}
/**
* Sets {@param providesInsetsTypes} as the inset types provided by {@param params}.
* @param params The window layout params.
* @param providesInsetsTypes The inset types we would like this layout params to provide.
*/
public void setProvidesInsetsTypes(WindowManager.LayoutParams params,
int[] providesInsetsTypes) {
final int length = providesInsetsTypes.length;
params.providedInsets = new InsetsFrameProvider[length];
for (int i = 0; i < length; i++) {
params.providedInsets[i] = new InsetsFrameProvider(providesInsetsTypes[i]);
}
}
/**
* Overrides a pending app transition.
*/
public void overridePendingAppTransitionMultiThumbFuture(
AppTransitionAnimationSpecsFuture animationSpecFuture, Runnable animStartedCallback,
Handler animStartedCallbackHandler, boolean scaleUp, int displayId) {
try {
WindowManagerGlobal.getWindowManagerService()
.overridePendingAppTransitionMultiThumbFuture(animationSpecFuture.getFuture(),
RecentsTransition.wrapStartedListener(animStartedCallbackHandler,
animStartedCallback), scaleUp, displayId);
} catch (RemoteException e) {
Log.w(TAG, "Failed to override pending app transition (multi-thumbnail future): ", e);
}
}
/**
* Enable or disable haptic feedback on the navigation bar buttons.
*/
public void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled) {
try {
WindowManagerGlobal.getWindowManagerService()
.setNavBarVirtualKeyHapticFeedbackEnabled(enabled);
} catch (RemoteException e) {
Log.w(TAG, "Failed to enable or disable navigation bar button haptics: ", e);
}
}
/**
* @param displayId the id of display to check if there is a software navigation bar.
*
* @return whether there is a soft nav bar on specific display.
*/
public boolean hasSoftNavigationBar(int displayId) {
try {
return WindowManagerGlobal.getWindowManagerService().hasNavigationBar(displayId);
} catch (RemoteException e) {
return false;
}
}
/**
* Mirrors a specified display. The SurfaceControl returned is the root of the mirrored
* hierarchy.
*
* @param displayId The id of the display to mirror
* @return The SurfaceControl for the root of the mirrored hierarchy.
*/
public SurfaceControl mirrorDisplay(final int displayId) {
try {
SurfaceControl outSurfaceControl = new SurfaceControl();
WindowManagerGlobal.getWindowManagerService().mirrorDisplay(displayId,
outSurfaceControl);
return outSurfaceControl;
} catch (RemoteException e) {
Log.e(TAG, "Unable to reach window manager", e);
}
return null;
}
}

View File

@@ -69,7 +69,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
import com.android.systemui.R;
import com.android.systemui.model.SysUiState;
import com.android.systemui.shared.system.WindowManagerWrapper;
import java.io.PrintWriter;
import java.text.NumberFormat;
@@ -634,7 +633,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
* child of the surfaceView.
*/
private void createMirror() {
mMirrorSurface = WindowManagerWrapper.getInstance().mirrorDisplay(mDisplayId);
mMirrorSurface = mirrorDisplay(mDisplayId);
if (!mMirrorSurface.isValid()) {
return;
}
@@ -643,6 +642,25 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
modifyWindowMagnification(false);
}
/**
* Mirrors a specified display. The SurfaceControl returned is the root of the mirrored
* hierarchy.
*
* @param displayId The id of the display to mirror
* @return The SurfaceControl for the root of the mirrored hierarchy.
*/
private SurfaceControl mirrorDisplay(final int displayId) {
try {
SurfaceControl outSurfaceControl = new SurfaceControl();
WindowManagerGlobal.getWindowManagerService().mirrorDisplay(displayId,
outSurfaceControl);
return outSurfaceControl;
} catch (RemoteException e) {
Log.e(TAG, "Unable to reach window manager", e);
}
return null;
}
private void addDragTouchListeners() {
mDragView = mMirrorView.findViewById(R.id.drag_handle);
mLeftDrag = mMirrorView.findViewById(R.id.left_handle);

View File

@@ -19,7 +19,6 @@ package com.android.systemui.dagger;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.shared.system.WindowManagerWrapper;
import dagger.Module;
import dagger.Provides;
@@ -49,10 +48,4 @@ public class SharedLibraryModule {
return TaskStackChangeListeners.getInstance();
}
/** */
@Provides
public WindowManagerWrapper providesWindowManagerWrapper() {
return WindowManagerWrapper.getInstance();
}
}

View File

@@ -39,6 +39,7 @@ import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
@@ -51,6 +52,7 @@ import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowInsetsController.Behavior;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.FrameLayout;
@@ -78,7 +80,6 @@ import com.android.systemui.shared.rotation.RotationButton.RotationButtonUpdates
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.LightBarTransitionsController;
@@ -775,12 +776,23 @@ public class NavigationBarView extends FrameLayout {
updateSlippery();
reloadNavIcons();
updateNavButtonIcons();
mBgExecutor.execute(() -> WindowManagerWrapper.getInstance()
.setNavBarVirtualKeyHapticFeedbackEnabled(!mShowSwipeUpUi));
mBgExecutor.execute(() -> setNavBarVirtualKeyHapticFeedbackEnabled(!mShowSwipeUpUi));
getHomeButton().setAccessibilityDelegate(
mShowSwipeUpUi ? mQuickStepAccessibilityDelegate : null);
}
/**
* Enable or disable haptic feedback on the navigation bar buttons.
*/
private void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled) {
try {
WindowManagerGlobal.getWindowManagerService()
.setNavBarVirtualKeyHapticFeedbackEnabled(enabled);
} catch (RemoteException e) {
Log.w(TAG, "Failed to enable or disable navigation bar button haptics: ", e);
}
}
/**
* Updates the {@link WindowManager.LayoutParams.FLAG_SLIPPERY} state dependent on if swipe up
* is enabled, or the notifications is fully opened without being in an animated state. If

View File

@@ -37,10 +37,12 @@ import android.os.RemoteException;
import android.text.SpannableStringBuilder;
import android.text.style.BulletSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
@@ -54,7 +56,6 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.util.leak.RotationUtils;
@@ -67,6 +68,7 @@ import dagger.Lazy;
public class ScreenPinningRequest implements View.OnClickListener,
NavigationModeController.ModeChangedListener {
private static final String TAG = "ScreenPinningRequest";
private final Context mContext;
private final Lazy<Optional<CentralSurfaces>> mCentralSurfacesOptionalLazy;
@@ -248,9 +250,8 @@ public class ScreenPinningRequest implements View.OnClickListener,
mLayout.findViewById(R.id.screen_pinning_text_area)
.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
View buttons = mLayout.findViewById(R.id.screen_pinning_buttons);
WindowManagerWrapper wm = WindowManagerWrapper.getInstance();
if (!QuickStepContract.isGesturalMode(mNavBarMode)
&& wm.hasSoftNavigationBar(mContext.getDisplayId()) && !isTablet(mContext)) {
&& hasSoftNavigationBar(mContext.getDisplayId()) && !isTablet(mContext)) {
buttons.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
swapChildrenIfRtlAndVertical(buttons);
} else {
@@ -321,6 +322,20 @@ public class ScreenPinningRequest implements View.OnClickListener,
addView(mLayout, getRequestLayoutParams(rotation));
}
/**
* @param displayId the id of display to check if there is a software navigation bar.
*
* @return whether there is a soft nav bar on specific display.
*/
private boolean hasSoftNavigationBar(int displayId) {
try {
return WindowManagerGlobal.getWindowManagerService().hasNavigationBar(displayId);
} catch (RemoteException e) {
Log.e(TAG, "Failed to check soft navigation bar", e);
return false;
}
}
private void swapChildrenIfRtlAndVertical(View group) {
if (mContext.getResources().getConfiguration().getLayoutDirection()
!= View.LAYOUT_DIRECTION_RTL) {