The service implementatoin of selection toolbar
We clone most the render logic from LocalFloatingToolbarPopup to the DefaultSelectionToolbarRenderService to render the menu items in the system process. When the rendering is done, the system will notify the application process events to let the application to position the rendered content. The changes also removes unused file SelctionContext. We punt the TC part to the next release, the file is unnecessary now. This change is only for the service implementation, the client side implementation will be done on the next change. Bug: 190030331 Bug: 205823018 Test: manual. Merged-In: I3915e8165b4d371700cb5fb9e7eb23d46f39bd5c Change-Id: I2e704432b1e149ce8dd6853fcad6850cf02b60bb
This commit is contained in:
@@ -16,12 +16,21 @@
|
||||
|
||||
package android.service.selectiontoolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import static android.view.selectiontoolbar.SelectionToolbarManager.ERROR_DO_NOT_ALLOW_MULTIPLE_TOOL_BAR;
|
||||
import static android.view.selectiontoolbar.SelectionToolbarManager.NO_TOOLBAR_ID;
|
||||
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.view.selectiontoolbar.ShowInfo;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The default implementation of {@link SelectionToolbarRenderService}.
|
||||
*
|
||||
* <p><b>NOTE:<b/> The requests are handled on the service main thread.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
// TODO(b/214122495): fix class not found then move to system service folder
|
||||
@@ -29,22 +38,97 @@ public final class DefaultSelectionToolbarRenderService extends SelectionToolbar
|
||||
|
||||
private static final String TAG = "DefaultSelectionToolbarRenderService";
|
||||
|
||||
// TODO(b/215497659): handle remove if the client process dies.
|
||||
// Only show one toolbar, dismiss the old ones and remove from cache
|
||||
private final SparseArray<Pair<Long, RemoteSelectionToolbar>> mToolbarCache =
|
||||
new SparseArray<>();
|
||||
|
||||
/**
|
||||
* Only allow one package to create one toolbar.
|
||||
*/
|
||||
private boolean canShowToolbar(int uid, ShowInfo showInfo) {
|
||||
if (showInfo.getWidgetToken() != NO_TOOLBAR_ID) {
|
||||
return true;
|
||||
}
|
||||
return mToolbarCache.indexOfKey(uid) < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(ShowInfo showInfo,
|
||||
public void onShow(int callingUid, ShowInfo showInfo,
|
||||
SelectionToolbarRenderService.RemoteCallbackWrapper callbackWrapper) {
|
||||
// TODO: Add implementation
|
||||
Log.w(TAG, "onShow()");
|
||||
if (!canShowToolbar(callingUid, showInfo)) {
|
||||
Slog.e(TAG, "Do not allow multiple toolbar for the app.");
|
||||
callbackWrapper.onError(ERROR_DO_NOT_ALLOW_MULTIPLE_TOOL_BAR);
|
||||
return;
|
||||
}
|
||||
long widgetToken = showInfo.getWidgetToken() == NO_TOOLBAR_ID
|
||||
? UUID.randomUUID().getMostSignificantBits()
|
||||
: showInfo.getWidgetToken();
|
||||
|
||||
if (mToolbarCache.indexOfKey(callingUid) < 0) {
|
||||
RemoteSelectionToolbar toolbar = new RemoteSelectionToolbar(this,
|
||||
widgetToken, showInfo.getHostInputToken(),
|
||||
callbackWrapper, this::transferTouch);
|
||||
mToolbarCache.put(callingUid, new Pair<>(widgetToken, toolbar));
|
||||
}
|
||||
Slog.v(TAG, "onShow() for " + widgetToken);
|
||||
Pair<Long, RemoteSelectionToolbar> toolbarPair = mToolbarCache.get(callingUid);
|
||||
if (toolbarPair.first == widgetToken) {
|
||||
toolbarPair.second.show(showInfo);
|
||||
} else {
|
||||
Slog.w(TAG, "onShow() for unknown " + widgetToken);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHide(long widgetToken) {
|
||||
// TODO: Add implementation
|
||||
Log.w(TAG, "onHide()");
|
||||
RemoteSelectionToolbar toolbar = getRemoteSelectionToolbarByTokenLocked(widgetToken);
|
||||
if (toolbar != null) {
|
||||
Slog.v(TAG, "onHide() for " + widgetToken);
|
||||
toolbar.hide(widgetToken);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(long widgetToken) {
|
||||
// TODO: Add implementation
|
||||
Log.w(TAG, "onDismiss()");
|
||||
RemoteSelectionToolbar toolbar = getRemoteSelectionToolbarByTokenLocked(widgetToken);
|
||||
if (toolbar != null) {
|
||||
Slog.v(TAG, "onDismiss() for " + widgetToken);
|
||||
toolbar.dismiss(widgetToken);
|
||||
removeRemoteSelectionToolbarByTokenLocked(widgetToken);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onToolbarShowTimeout(int callingUid) {
|
||||
Slog.w(TAG, "onToolbarShowTimeout for callingUid = " + callingUid);
|
||||
Pair<Long, RemoteSelectionToolbar> toolbarPair = mToolbarCache.get(callingUid);
|
||||
if (toolbarPair != null) {
|
||||
RemoteSelectionToolbar remoteToolbar = toolbarPair.second;
|
||||
remoteToolbar.dismiss(toolbarPair.first);
|
||||
remoteToolbar.onToolbarShowTimeout();
|
||||
mToolbarCache.remove(callingUid);
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteSelectionToolbar getRemoteSelectionToolbarByTokenLocked(long widgetToken) {
|
||||
for (int i = 0; i < mToolbarCache.size(); i++) {
|
||||
Pair<Long, RemoteSelectionToolbar> toolbarPair = mToolbarCache.valueAt(i);
|
||||
if (toolbarPair.first == widgetToken) {
|
||||
return toolbarPair.second;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void removeRemoteSelectionToolbarByTokenLocked(long widgetToken) {
|
||||
for (int i = 0; i < mToolbarCache.size(); i++) {
|
||||
Pair<Long, RemoteSelectionToolbar> toolbarPair = mToolbarCache.valueAt(i);
|
||||
if (toolbarPair.first == widgetToken) {
|
||||
mToolbarCache.remove(mToolbarCache.keyAt(i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 android.service.selectiontoolbar;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.IBinder;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* This class is the root view for the selection toolbar. It is responsible for
|
||||
* detecting the click on the item and to also transfer input focus to the application.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SuppressLint("ViewConstructor")
|
||||
public class FloatingToolbarRoot extends LinearLayout {
|
||||
|
||||
private final IBinder mTargetInputToken;
|
||||
private final SelectionToolbarRenderService.TransferTouchListener mTransferTouchListener;
|
||||
private float mDownX;
|
||||
private float mDownY;
|
||||
|
||||
public FloatingToolbarRoot(Context context, IBinder targetInputToken,
|
||||
SelectionToolbarRenderService.TransferTouchListener transferTouchListener) {
|
||||
super(context);
|
||||
mTargetInputToken = targetInputToken;
|
||||
mTransferTouchListener = transferTouchListener;
|
||||
setFocusable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN: {
|
||||
mDownX = event.getX();
|
||||
mDownY = event.getY();
|
||||
// TODO: Check x, y if we need to transfer touch focus to application
|
||||
//mTransferTouchListener.onTransferTouch(getViewRootImpl().getInputToken(),
|
||||
// mTargetInputToken);
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ import android.view.selectiontoolbar.ShowInfo;
|
||||
* @hide
|
||||
*/
|
||||
oneway interface ISelectionToolbarRenderService {
|
||||
void onShow(in ShowInfo showInfo, in ISelectionToolbarCallback callback);
|
||||
void onConnected(in IBinder callback);
|
||||
void onShow(int callingUid, in ShowInfo showInfo, in ISelectionToolbarCallback callback);
|
||||
void onHide(long widgetToken);
|
||||
void onDismiss(long widgetToken);
|
||||
void onDismiss(int callingUid, long widgetToken);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2022 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.
|
||||
@@ -14,9 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.selectiontoolbar;
|
||||
package android.service.selectiontoolbar;
|
||||
|
||||
import android.os.IBinder;
|
||||
|
||||
/**
|
||||
* The interface from the SelectionToolbarRenderService to the system.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
parcelable SelectionContext;
|
||||
oneway interface ISelectionToolbarRenderServiceCallback {
|
||||
void transferTouch(in IBinder source, in IBinder target);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,14 +30,6 @@ public interface SelectionToolbarRenderCallback {
|
||||
* The selection toolbar is shown.
|
||||
*/
|
||||
void onShown(WidgetInfo widgetInfo);
|
||||
/**
|
||||
* The selection toolbar is hidden.
|
||||
*/
|
||||
void onHidden(long widgetToken);
|
||||
/**
|
||||
* The selection toolbar is dismissed.
|
||||
*/
|
||||
void onDismissed(long widgetToken);
|
||||
/**
|
||||
* The selection toolbar has changed.
|
||||
*/
|
||||
@@ -46,6 +38,10 @@ public interface SelectionToolbarRenderCallback {
|
||||
* The menu item on the selection toolbar has been clicked.
|
||||
*/
|
||||
void onMenuItemClicked(ToolbarMenuItem item);
|
||||
/**
|
||||
* The toolbar doesn't be dismissed after showing on a given timeout.
|
||||
*/
|
||||
void onToolbarShowTimeout();
|
||||
/**
|
||||
* The error occurred when operating on the selection toolbar.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,8 @@ import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.view.selectiontoolbar.ISelectionToolbarCallback;
|
||||
import android.view.selectiontoolbar.ShowInfo;
|
||||
import android.view.selectiontoolbar.ToolbarMenuItem;
|
||||
@@ -42,6 +44,10 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
|
||||
private static final String TAG = "SelectionToolbarRenderService";
|
||||
|
||||
// TODO(b/215497659): read from DeviceConfig
|
||||
// The timeout to clean the cache if the client forgot to call dismiss()
|
||||
private static final int CACHE_CLEAN_AFTER_SHOW_TIMEOUT_IN_MS = 10 * 60 * 1000; // 10 minutes
|
||||
|
||||
/**
|
||||
* The {@link Intent} that must be declared as handled by the service.
|
||||
*
|
||||
@@ -53,6 +59,10 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
"android.service.selectiontoolbar.SelectionToolbarRenderService";
|
||||
|
||||
private Handler mHandler;
|
||||
private ISelectionToolbarRenderServiceCallback mServiceCallback;
|
||||
|
||||
private final SparseArray<Pair<RemoteCallbackWrapper, CleanCacheRunnable>> mCache =
|
||||
new SparseArray<>();
|
||||
|
||||
/**
|
||||
* Binder to receive calls from system server.
|
||||
@@ -61,10 +71,18 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
new ISelectionToolbarRenderService.Stub() {
|
||||
|
||||
@Override
|
||||
public void onShow(ShowInfo showInfo, ISelectionToolbarCallback callback) {
|
||||
public void onShow(int callingUid, ShowInfo showInfo, ISelectionToolbarCallback callback) {
|
||||
if (mCache.indexOfKey(callingUid) < 0) {
|
||||
mCache.put(callingUid, new Pair<>(new RemoteCallbackWrapper(callback),
|
||||
new CleanCacheRunnable(callingUid)));
|
||||
}
|
||||
Pair<RemoteCallbackWrapper, CleanCacheRunnable> toolbarPair = mCache.get(callingUid);
|
||||
CleanCacheRunnable cleanRunnable = toolbarPair.second;
|
||||
mHandler.removeCallbacks(cleanRunnable);
|
||||
mHandler.sendMessage(obtainMessage(SelectionToolbarRenderService::onShow,
|
||||
SelectionToolbarRenderService.this, showInfo,
|
||||
new RemoteCallbackWrapper(callback)));
|
||||
SelectionToolbarRenderService.this, callingUid, showInfo,
|
||||
toolbarPair.first));
|
||||
mHandler.postDelayed(cleanRunnable, CACHE_CLEAN_AFTER_SHOW_TIMEOUT_IN_MS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,9 +92,20 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(long widgetToken) {
|
||||
public void onDismiss(int callingUid, long widgetToken) {
|
||||
mHandler.sendMessage(obtainMessage(SelectionToolbarRenderService::onDismiss,
|
||||
SelectionToolbarRenderService.this, widgetToken));
|
||||
Pair<RemoteCallbackWrapper, CleanCacheRunnable> toolbarPair = mCache.get(callingUid);
|
||||
if (toolbarPair != null) {
|
||||
mHandler.removeCallbacks(toolbarPair.second);
|
||||
mCache.remove(callingUid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(IBinder callback) {
|
||||
mHandler.sendMessage(obtainMessage(SelectionToolbarRenderService::handleOnConnected,
|
||||
SelectionToolbarRenderService.this, callback));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,11 +126,28 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleOnConnected(@NonNull IBinder callback) {
|
||||
mServiceCallback = ISelectionToolbarRenderServiceCallback.Stub.asInterface(callback);
|
||||
}
|
||||
|
||||
protected void transferTouch(@NonNull IBinder source, @NonNull IBinder target) {
|
||||
final ISelectionToolbarRenderServiceCallback callback = mServiceCallback;
|
||||
if (callback == null) {
|
||||
Log.e(TAG, "transferTouch(): no server callback");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
callback.transferTouch(source, target);
|
||||
} catch (RemoteException e) {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when showing the selection toolbar.
|
||||
*/
|
||||
public abstract void onShow(ShowInfo showInfo, RemoteCallbackWrapper callbackWrapper);
|
||||
public abstract void onShow(int callingUid, ShowInfo showInfo,
|
||||
RemoteCallbackWrapper callbackWrapper);
|
||||
|
||||
/**
|
||||
* Called when hiding the selection toolbar.
|
||||
@@ -115,13 +161,22 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
public abstract void onDismiss(long widgetToken);
|
||||
|
||||
/**
|
||||
* Add avadoc.
|
||||
* Called when showing the selection toolbar for a specific timeout. This avoids the client
|
||||
* forgot to call dismiss to clean the state.
|
||||
*/
|
||||
public void onToolbarShowTimeout(int callingUid) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to notify the client toolbar events.
|
||||
*/
|
||||
public static final class RemoteCallbackWrapper implements SelectionToolbarRenderCallback {
|
||||
|
||||
private final ISelectionToolbarCallback mRemoteCallback;
|
||||
|
||||
RemoteCallbackWrapper(ISelectionToolbarCallback remoteCallback) {
|
||||
// TODO(b/215497659): handle if the binder dies.
|
||||
mRemoteCallback = remoteCallback;
|
||||
}
|
||||
|
||||
@@ -130,25 +185,16 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
try {
|
||||
mRemoteCallback.onShown(widgetInfo);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowAsRuntimeException();
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidden(long widgetToken) {
|
||||
public void onToolbarShowTimeout() {
|
||||
try {
|
||||
mRemoteCallback.onHidden(widgetToken);
|
||||
mRemoteCallback.onToolbarShowTimeout();
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowAsRuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissed(long widgetToken) {
|
||||
try {
|
||||
mRemoteCallback.onDismissed(widgetToken);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowAsRuntimeException();
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +203,7 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
try {
|
||||
mRemoteCallback.onWidgetUpdated(widgetInfo);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowAsRuntimeException();
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +212,7 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
try {
|
||||
mRemoteCallback.onMenuItemClicked(item);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowAsRuntimeException();
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +221,37 @@ public abstract class SelectionToolbarRenderService extends Service {
|
||||
try {
|
||||
mRemoteCallback.onError(errorCode);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowAsRuntimeException();
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CleanCacheRunnable implements Runnable {
|
||||
|
||||
int mCleanUid;
|
||||
|
||||
CleanCacheRunnable(int cleanUid) {
|
||||
mCleanUid = cleanUid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Pair<RemoteCallbackWrapper, CleanCacheRunnable> toolbarPair = mCache.get(mCleanUid);
|
||||
if (toolbarPair != null) {
|
||||
Log.w(TAG, "CleanCacheRunnable: remove " + mCleanUid + " from cache.");
|
||||
mCache.remove(mCleanUid);
|
||||
onToolbarShowTimeout(mCleanUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A listener to notify the service to the transfer touch focus.
|
||||
*/
|
||||
public interface TransferTouchListener {
|
||||
/**
|
||||
* Notify the service to transfer the touch focus.
|
||||
*/
|
||||
void onTransferTouch(IBinder source, IBinder target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,8 @@ import android.view.selectiontoolbar.WidgetInfo;
|
||||
*/
|
||||
oneway interface ISelectionToolbarCallback {
|
||||
void onShown(in WidgetInfo info);
|
||||
void onHidden(long widgetToken);
|
||||
void onDismissed(long widgetToken);
|
||||
void onWidgetUpdated(in WidgetInfo info);
|
||||
void onToolbarShowTimeout();
|
||||
void onMenuItemClicked(in ToolbarMenuItem item);
|
||||
void onError(int errorCode);
|
||||
}
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 android.view.selectiontoolbar;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.util.DataClass;
|
||||
|
||||
/**
|
||||
* The class holds information for a selection.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true)
|
||||
public final class SelectionContext implements Parcelable {
|
||||
|
||||
/**
|
||||
* The start index of a selection.
|
||||
*/
|
||||
private final int mStartIndex;
|
||||
|
||||
/**
|
||||
* The end index of a selection.
|
||||
*/
|
||||
private final int mEndIndex;
|
||||
|
||||
|
||||
|
||||
// Code below generated by codegen v1.0.23.
|
||||
//
|
||||
// DO NOT MODIFY!
|
||||
// CHECKSTYLE:OFF Generated code
|
||||
//
|
||||
// To regenerate run:
|
||||
// $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/selectiontoolbar/SelectionContext.java
|
||||
//
|
||||
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
|
||||
// Settings > Editor > Code Style > Formatter Control
|
||||
//@formatter:off
|
||||
|
||||
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ SelectionContext(
|
||||
int startIndex,
|
||||
int endIndex) {
|
||||
this.mStartIndex = startIndex;
|
||||
this.mEndIndex = endIndex;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
/**
|
||||
* The start index of a selection.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getStartIndex() {
|
||||
return mStartIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* The end index of a selection.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getEndIndex() {
|
||||
return mEndIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public String toString() {
|
||||
// You can override field toString logic by defining methods like:
|
||||
// String fieldNameToString() { ... }
|
||||
|
||||
return "SelectionContext { " +
|
||||
"startIndex = " + mStartIndex + ", " +
|
||||
"endIndex = " + mEndIndex +
|
||||
" }";
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public boolean equals(@android.annotation.Nullable Object o) {
|
||||
// You can override field equality logic by defining either of the methods like:
|
||||
// boolean fieldNameEquals(SelectionContext other) { ... }
|
||||
// boolean fieldNameEquals(FieldType otherValue) { ... }
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
@SuppressWarnings("unchecked")
|
||||
SelectionContext that = (SelectionContext) o;
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& mStartIndex == that.mStartIndex
|
||||
&& mEndIndex == that.mEndIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public int hashCode() {
|
||||
// You can override field hashCode logic by defining methods like:
|
||||
// int fieldNameHashCode() { ... }
|
||||
|
||||
int _hash = 1;
|
||||
_hash = 31 * _hash + mStartIndex;
|
||||
_hash = 31 * _hash + mEndIndex;
|
||||
return _hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
|
||||
// You can override field parcelling by defining methods like:
|
||||
// void parcelFieldName(Parcel dest, int flags) { ... }
|
||||
|
||||
dest.writeInt(mStartIndex);
|
||||
dest.writeInt(mEndIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public int describeContents() { return 0; }
|
||||
|
||||
/** @hide */
|
||||
@SuppressWarnings({"unchecked", "RedundantCast"})
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ SelectionContext(@NonNull android.os.Parcel in) {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
int startIndex = in.readInt();
|
||||
int endIndex = in.readInt();
|
||||
|
||||
this.mStartIndex = startIndex;
|
||||
this.mEndIndex = endIndex;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public static final @NonNull Parcelable.Creator<SelectionContext> CREATOR
|
||||
= new Parcelable.Creator<SelectionContext>() {
|
||||
@Override
|
||||
public SelectionContext[] newArray(int size) {
|
||||
return new SelectionContext[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectionContext createFromParcel(@NonNull android.os.Parcel in) {
|
||||
return new SelectionContext(in);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A builder for {@link SelectionContext}
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@DataClass.Generated.Member
|
||||
public static final class Builder {
|
||||
|
||||
private int mStartIndex;
|
||||
private int mEndIndex;
|
||||
|
||||
private long mBuilderFieldsSet = 0L;
|
||||
|
||||
/**
|
||||
* Creates a new Builder.
|
||||
*
|
||||
* @param startIndex
|
||||
* The start index of a selection.
|
||||
* @param endIndex
|
||||
* The end index of a selection.
|
||||
*/
|
||||
public Builder(
|
||||
int startIndex,
|
||||
int endIndex) {
|
||||
mStartIndex = startIndex;
|
||||
mEndIndex = endIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* The start index of a selection.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setStartIndex(int value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x1;
|
||||
mStartIndex = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The end index of a selection.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setEndIndex(int value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x2;
|
||||
mEndIndex = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds the instance. This builder should not be touched after calling this! */
|
||||
public @NonNull SelectionContext build() {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x4; // Mark builder used
|
||||
|
||||
SelectionContext o = new SelectionContext(
|
||||
mStartIndex,
|
||||
mEndIndex);
|
||||
return o;
|
||||
}
|
||||
|
||||
private void checkNotUsed() {
|
||||
if ((mBuilderFieldsSet & 0x4) != 0) {
|
||||
throw new IllegalStateException(
|
||||
"This Builder should not be reused. Use a new Builder instance instead");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1639488292248L,
|
||||
codegenVersion = "1.0.23",
|
||||
sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/SelectionContext.java",
|
||||
inputSignatures = "private final int mStartIndex\nprivate final int mEndIndex\nclass SelectionContext extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
//@formatter:on
|
||||
// End of generated code
|
||||
|
||||
}
|
||||
@@ -47,6 +47,16 @@ public final class SelectionToolbarManager {
|
||||
private static final String REMOTE_SELECTION_TOOLBAR_ENABLED =
|
||||
"remote_selection_toolbar_enabled";
|
||||
|
||||
/**
|
||||
* Used to mark a toolbar that has no toolbar token id.
|
||||
*/
|
||||
public static final long NO_TOOLBAR_ID = 0;
|
||||
|
||||
/**
|
||||
* The error code that do not allow to create multiple toolbar.
|
||||
*/
|
||||
public static final int ERROR_DO_NOT_ALLOW_MULTIPLE_TOOL_BAR = 1;
|
||||
|
||||
@NonNull
|
||||
private final Context mContext;
|
||||
private final ISelectionToolbarManager mService;
|
||||
|
||||
@@ -17,10 +17,14 @@
|
||||
package android.view.selectiontoolbar;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.graphics.Rect;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.util.DataClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* The class holds menu information for render service to render the selection toolbar.
|
||||
@@ -29,14 +33,47 @@ import com.android.internal.util.DataClass;
|
||||
*/
|
||||
@DataClass(genToString = true, genEqualsHashCode = true)
|
||||
public final class ShowInfo implements Parcelable {
|
||||
|
||||
/**
|
||||
* The token that is used to identify the selection toolbar. This is initially set to 0
|
||||
* until a selection toolbar has been created for the showToolbar request.
|
||||
*/
|
||||
private final long mWidgetToken;
|
||||
|
||||
// TODO: add members when the code really uses it
|
||||
/**
|
||||
* If the toolbar menu items need to be re-layout.
|
||||
*/
|
||||
private final boolean mLayoutRequired;
|
||||
|
||||
/**
|
||||
* The menu items to be rendered in the selection toolbar.
|
||||
*/
|
||||
@NonNull
|
||||
private final List<ToolbarMenuItem> mMenuItems;
|
||||
|
||||
/**
|
||||
* A rect specifying where the selection toolbar on the screen.
|
||||
*/
|
||||
@NonNull
|
||||
private final Rect mContentRect;
|
||||
|
||||
/**
|
||||
* A recommended maximum suggested width of the selection toolbar.
|
||||
*/
|
||||
private final int mSuggestedWidth;
|
||||
|
||||
/**
|
||||
* The portion of the screen that is available to the selection toolbar.
|
||||
*/
|
||||
@NonNull
|
||||
private final Rect mViewPortOnScreen;
|
||||
|
||||
/**
|
||||
* The host application's input token, this allows the remote render service to transfer
|
||||
* the touch focus to the host application.
|
||||
*/
|
||||
@NonNull
|
||||
private final IBinder mHostInputToken;
|
||||
|
||||
|
||||
|
||||
@@ -57,24 +94,108 @@ public final class ShowInfo implements Parcelable {
|
||||
* Creates a new ShowInfo.
|
||||
*
|
||||
* @param widgetToken
|
||||
* The token that is used to identify the selection toolbar.
|
||||
* The token that is used to identify the selection toolbar. This is initially set to 0
|
||||
* until a selection toolbar has been created for the showToolbar request.
|
||||
* @param layoutRequired
|
||||
* If the toolbar menu items need to be re-layout.
|
||||
* @param menuItems
|
||||
* The menu items to be rendered in the selection toolbar.
|
||||
* @param contentRect
|
||||
* A rect specifying where the selection toolbar on the screen.
|
||||
* @param suggestedWidth
|
||||
* A recommended maximum suggested width of the selection toolbar.
|
||||
* @param viewPortOnScreen
|
||||
* The portion of the screen that is available to the selection toolbar.
|
||||
* @param hostInputToken
|
||||
* The host application's input token, this allows the remote render service to transfer
|
||||
* the touch focus to the host application.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public ShowInfo(
|
||||
long widgetToken) {
|
||||
long widgetToken,
|
||||
boolean layoutRequired,
|
||||
@NonNull List<ToolbarMenuItem> menuItems,
|
||||
@NonNull Rect contentRect,
|
||||
int suggestedWidth,
|
||||
@NonNull Rect viewPortOnScreen,
|
||||
@NonNull IBinder hostInputToken) {
|
||||
this.mWidgetToken = widgetToken;
|
||||
this.mLayoutRequired = layoutRequired;
|
||||
this.mMenuItems = menuItems;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mMenuItems);
|
||||
this.mContentRect = contentRect;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mContentRect);
|
||||
this.mSuggestedWidth = suggestedWidth;
|
||||
this.mViewPortOnScreen = viewPortOnScreen;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mViewPortOnScreen);
|
||||
this.mHostInputToken = hostInputToken;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mHostInputToken);
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
/**
|
||||
* The token that is used to identify the selection toolbar.
|
||||
* The token that is used to identify the selection toolbar. This is initially set to 0
|
||||
* until a selection toolbar has been created for the showToolbar request.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public long getWidgetToken() {
|
||||
return mWidgetToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the toolbar menu items need to be re-layout.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public boolean isLayoutRequired() {
|
||||
return mLayoutRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* The menu items to be rendered in the selection toolbar.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull List<ToolbarMenuItem> getMenuItems() {
|
||||
return mMenuItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* A rect specifying where the selection toolbar on the screen.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Rect getContentRect() {
|
||||
return mContentRect;
|
||||
}
|
||||
|
||||
/**
|
||||
* A recommended maximum suggested width of the selection toolbar.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getSuggestedWidth() {
|
||||
return mSuggestedWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* The portion of the screen that is available to the selection toolbar.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Rect getViewPortOnScreen() {
|
||||
return mViewPortOnScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* The host application's input token, this allows the remote render service to transfer
|
||||
* the touch focus to the host application.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull IBinder getHostInputToken() {
|
||||
return mHostInputToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public String toString() {
|
||||
@@ -82,7 +203,13 @@ public final class ShowInfo implements Parcelable {
|
||||
// String fieldNameToString() { ... }
|
||||
|
||||
return "ShowInfo { " +
|
||||
"widgetToken = " + mWidgetToken +
|
||||
"widgetToken = " + mWidgetToken + ", " +
|
||||
"layoutRequired = " + mLayoutRequired + ", " +
|
||||
"menuItems = " + mMenuItems + ", " +
|
||||
"contentRect = " + mContentRect + ", " +
|
||||
"suggestedWidth = " + mSuggestedWidth + ", " +
|
||||
"viewPortOnScreen = " + mViewPortOnScreen + ", " +
|
||||
"hostInputToken = " + mHostInputToken +
|
||||
" }";
|
||||
}
|
||||
|
||||
@@ -99,7 +226,13 @@ public final class ShowInfo implements Parcelable {
|
||||
ShowInfo that = (ShowInfo) o;
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& mWidgetToken == that.mWidgetToken;
|
||||
&& mWidgetToken == that.mWidgetToken
|
||||
&& mLayoutRequired == that.mLayoutRequired
|
||||
&& java.util.Objects.equals(mMenuItems, that.mMenuItems)
|
||||
&& java.util.Objects.equals(mContentRect, that.mContentRect)
|
||||
&& mSuggestedWidth == that.mSuggestedWidth
|
||||
&& java.util.Objects.equals(mViewPortOnScreen, that.mViewPortOnScreen)
|
||||
&& java.util.Objects.equals(mHostInputToken, that.mHostInputToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,6 +243,12 @@ public final class ShowInfo implements Parcelable {
|
||||
|
||||
int _hash = 1;
|
||||
_hash = 31 * _hash + Long.hashCode(mWidgetToken);
|
||||
_hash = 31 * _hash + Boolean.hashCode(mLayoutRequired);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mMenuItems);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mContentRect);
|
||||
_hash = 31 * _hash + mSuggestedWidth;
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mViewPortOnScreen);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mHostInputToken);
|
||||
return _hash;
|
||||
}
|
||||
|
||||
@@ -119,7 +258,15 @@ public final class ShowInfo implements Parcelable {
|
||||
// You can override field parcelling by defining methods like:
|
||||
// void parcelFieldName(Parcel dest, int flags) { ... }
|
||||
|
||||
byte flg = 0;
|
||||
if (mLayoutRequired) flg |= 0x2;
|
||||
dest.writeByte(flg);
|
||||
dest.writeLong(mWidgetToken);
|
||||
dest.writeParcelableList(mMenuItems, flags);
|
||||
dest.writeTypedObject(mContentRect, flags);
|
||||
dest.writeInt(mSuggestedWidth);
|
||||
dest.writeTypedObject(mViewPortOnScreen, flags);
|
||||
dest.writeStrongBinder(mHostInputToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,9 +280,31 @@ public final class ShowInfo implements Parcelable {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
byte flg = in.readByte();
|
||||
boolean layoutRequired = (flg & 0x2) != 0;
|
||||
long widgetToken = in.readLong();
|
||||
List<ToolbarMenuItem> menuItems = new java.util.ArrayList<>();
|
||||
in.readParcelableList(menuItems, ToolbarMenuItem.class.getClassLoader());
|
||||
Rect contentRect = (Rect) in.readTypedObject(Rect.CREATOR);
|
||||
int suggestedWidth = in.readInt();
|
||||
Rect viewPortOnScreen = (Rect) in.readTypedObject(Rect.CREATOR);
|
||||
IBinder hostInputToken = (IBinder) in.readStrongBinder();
|
||||
|
||||
this.mWidgetToken = widgetToken;
|
||||
this.mLayoutRequired = layoutRequired;
|
||||
this.mMenuItems = menuItems;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mMenuItems);
|
||||
this.mContentRect = contentRect;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mContentRect);
|
||||
this.mSuggestedWidth = suggestedWidth;
|
||||
this.mViewPortOnScreen = viewPortOnScreen;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mViewPortOnScreen);
|
||||
this.mHostInputToken = hostInputToken;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mHostInputToken);
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
@@ -155,10 +324,10 @@ public final class ShowInfo implements Parcelable {
|
||||
};
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1639488262761L,
|
||||
time = 1643186262604L,
|
||||
codegenVersion = "1.0.23",
|
||||
sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/ShowInfo.java",
|
||||
inputSignatures = "private final long mWidgetToken\nclass ShowInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)")
|
||||
inputSignatures = "private final long mWidgetToken\nprivate final boolean mLayoutRequired\nprivate final @android.annotation.NonNull java.util.List<android.view.selectiontoolbar.ToolbarMenuItem> mMenuItems\nprivate final @android.annotation.NonNull android.graphics.Rect mContentRect\nprivate final int mSuggestedWidth\nprivate final @android.annotation.NonNull android.graphics.Rect mViewPortOnScreen\nprivate final @android.annotation.NonNull android.os.IBinder mHostInputToken\nclass ShowInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ package android.view.selectiontoolbar;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Parcelable;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.android.internal.util.DataClass;
|
||||
|
||||
@@ -30,11 +32,85 @@ import com.android.internal.util.DataClass;
|
||||
@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true)
|
||||
public final class ToolbarMenuItem implements Parcelable {
|
||||
|
||||
/**
|
||||
* The priority of menu item is unknown.
|
||||
*/
|
||||
public static final int PRIORITY_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* The priority of menu item is shown in primary selection toolbar.
|
||||
*/
|
||||
public static final int PRIORITY_PRIMARY = 1;
|
||||
|
||||
/**
|
||||
* The priority of menu item is shown in overflow selection toolbar.
|
||||
*/
|
||||
public static final int PRIORITY_OVERFLOW = 2;
|
||||
|
||||
/**
|
||||
* The id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getItemId()
|
||||
*/
|
||||
private final int mItemId;
|
||||
|
||||
/**
|
||||
* The title of the menu item.
|
||||
*
|
||||
* @see MenuItem#getTitle()
|
||||
*/
|
||||
@NonNull
|
||||
private final CharSequence mTitle;
|
||||
|
||||
/**
|
||||
* The content description of the menu item.
|
||||
*
|
||||
* @see MenuItem#getContentDescription()
|
||||
*/
|
||||
@Nullable
|
||||
private final CharSequence mContentDescription;
|
||||
|
||||
/**
|
||||
* The group id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getGroupId()
|
||||
*/
|
||||
private final int mGroupId;
|
||||
|
||||
/**
|
||||
* The icon id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getIcon()
|
||||
*/
|
||||
@Nullable
|
||||
private final Icon mIcon;
|
||||
|
||||
/**
|
||||
* The tooltip text of the menu item.
|
||||
*
|
||||
* @see MenuItem#getTooltipText()
|
||||
*/
|
||||
@Nullable
|
||||
private final CharSequence mTooltipText;
|
||||
|
||||
/**
|
||||
* The priority of the menu item used to display the order of the menu item.
|
||||
*/
|
||||
private final int mPriority;
|
||||
|
||||
/**
|
||||
* Returns the priority from a given {@link MenuItem}.
|
||||
*/
|
||||
public static int getPriorityFromMenuItem(MenuItem menuItem) {
|
||||
if (menuItem.requiresActionButton()) {
|
||||
return PRIORITY_PRIMARY;
|
||||
} else if (menuItem.requiresOverflow()) {
|
||||
return PRIORITY_OVERFLOW;
|
||||
}
|
||||
return PRIORITY_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Code below generated by codegen v1.0.23.
|
||||
@@ -50,22 +126,118 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
//@formatter:off
|
||||
|
||||
|
||||
@android.annotation.IntDef(prefix = "PRIORITY_", value = {
|
||||
PRIORITY_UNKNOWN,
|
||||
PRIORITY_PRIMARY,
|
||||
PRIORITY_OVERFLOW
|
||||
})
|
||||
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE)
|
||||
@DataClass.Generated.Member
|
||||
public @interface Priority {}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public static String priorityToString(@Priority int value) {
|
||||
switch (value) {
|
||||
case PRIORITY_UNKNOWN:
|
||||
return "PRIORITY_UNKNOWN";
|
||||
case PRIORITY_PRIMARY:
|
||||
return "PRIORITY_PRIMARY";
|
||||
case PRIORITY_OVERFLOW:
|
||||
return "PRIORITY_OVERFLOW";
|
||||
default: return Integer.toHexString(value);
|
||||
}
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ ToolbarMenuItem(
|
||||
int itemId) {
|
||||
int itemId,
|
||||
@NonNull CharSequence title,
|
||||
@Nullable CharSequence contentDescription,
|
||||
int groupId,
|
||||
@Nullable Icon icon,
|
||||
@Nullable CharSequence tooltipText,
|
||||
int priority) {
|
||||
this.mItemId = itemId;
|
||||
this.mTitle = title;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mTitle);
|
||||
this.mContentDescription = contentDescription;
|
||||
this.mGroupId = groupId;
|
||||
this.mIcon = icon;
|
||||
this.mTooltipText = tooltipText;
|
||||
this.mPriority = priority;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getItemId()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getItemId() {
|
||||
return mItemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of the menu item.
|
||||
*
|
||||
* @see MenuItem#getTitle()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull CharSequence getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* The content description of the menu item.
|
||||
*
|
||||
* @see MenuItem#getContentDescription()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @Nullable CharSequence getContentDescription() {
|
||||
return mContentDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* The group id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getGroupId()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getGroupId() {
|
||||
return mGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The icon id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getIcon()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @Nullable Icon getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* The tooltip text of the menu item.
|
||||
*
|
||||
* @see MenuItem#getTooltipText()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @Nullable CharSequence getTooltipText() {
|
||||
return mTooltipText;
|
||||
}
|
||||
|
||||
/**
|
||||
* The priority of the menu item used to display the order of the menu item.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getPriority() {
|
||||
return mPriority;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public String toString() {
|
||||
@@ -73,7 +245,13 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
// String fieldNameToString() { ... }
|
||||
|
||||
return "ToolbarMenuItem { " +
|
||||
"itemId = " + mItemId +
|
||||
"itemId = " + mItemId + ", " +
|
||||
"title = " + mTitle + ", " +
|
||||
"contentDescription = " + mContentDescription + ", " +
|
||||
"groupId = " + mGroupId + ", " +
|
||||
"icon = " + mIcon + ", " +
|
||||
"tooltipText = " + mTooltipText + ", " +
|
||||
"priority = " + mPriority +
|
||||
" }";
|
||||
}
|
||||
|
||||
@@ -90,7 +268,13 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
ToolbarMenuItem that = (ToolbarMenuItem) o;
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& mItemId == that.mItemId;
|
||||
&& mItemId == that.mItemId
|
||||
&& java.util.Objects.equals(mTitle, that.mTitle)
|
||||
&& java.util.Objects.equals(mContentDescription, that.mContentDescription)
|
||||
&& mGroupId == that.mGroupId
|
||||
&& java.util.Objects.equals(mIcon, that.mIcon)
|
||||
&& java.util.Objects.equals(mTooltipText, that.mTooltipText)
|
||||
&& mPriority == that.mPriority;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,6 +285,12 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
|
||||
int _hash = 1;
|
||||
_hash = 31 * _hash + mItemId;
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mTitle);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mContentDescription);
|
||||
_hash = 31 * _hash + mGroupId;
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mIcon);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mTooltipText);
|
||||
_hash = 31 * _hash + mPriority;
|
||||
return _hash;
|
||||
}
|
||||
|
||||
@@ -110,7 +300,18 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
// You can override field parcelling by defining methods like:
|
||||
// void parcelFieldName(Parcel dest, int flags) { ... }
|
||||
|
||||
byte flg = 0;
|
||||
if (mContentDescription != null) flg |= 0x4;
|
||||
if (mIcon != null) flg |= 0x10;
|
||||
if (mTooltipText != null) flg |= 0x20;
|
||||
dest.writeByte(flg);
|
||||
dest.writeInt(mItemId);
|
||||
dest.writeCharSequence(mTitle);
|
||||
if (mContentDescription != null) dest.writeCharSequence(mContentDescription);
|
||||
dest.writeInt(mGroupId);
|
||||
if (mIcon != null) dest.writeTypedObject(mIcon, flags);
|
||||
if (mTooltipText != null) dest.writeCharSequence(mTooltipText);
|
||||
dest.writeInt(mPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,9 +325,24 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
byte flg = in.readByte();
|
||||
int itemId = in.readInt();
|
||||
CharSequence title = (CharSequence) in.readCharSequence();
|
||||
CharSequence contentDescription = (flg & 0x4) == 0 ? null : (CharSequence) in.readCharSequence();
|
||||
int groupId = in.readInt();
|
||||
Icon icon = (flg & 0x10) == 0 ? null : (Icon) in.readTypedObject(Icon.CREATOR);
|
||||
CharSequence tooltipText = (flg & 0x20) == 0 ? null : (CharSequence) in.readCharSequence();
|
||||
int priority = in.readInt();
|
||||
|
||||
this.mItemId = itemId;
|
||||
this.mTitle = title;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mTitle);
|
||||
this.mContentDescription = contentDescription;
|
||||
this.mGroupId = groupId;
|
||||
this.mIcon = icon;
|
||||
this.mTooltipText = tooltipText;
|
||||
this.mPriority = priority;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
@@ -153,6 +369,12 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
public static final class Builder {
|
||||
|
||||
private int mItemId;
|
||||
private @NonNull CharSequence mTitle;
|
||||
private @Nullable CharSequence mContentDescription;
|
||||
private int mGroupId;
|
||||
private @Nullable Icon mIcon;
|
||||
private @Nullable CharSequence mTooltipText;
|
||||
private int mPriority;
|
||||
|
||||
private long mBuilderFieldsSet = 0L;
|
||||
|
||||
@@ -161,14 +383,42 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
*
|
||||
* @param itemId
|
||||
* The id of the menu item.
|
||||
* @param title
|
||||
* The title of the menu item.
|
||||
* @param contentDescription
|
||||
* The content description of the menu item.
|
||||
* @param groupId
|
||||
* The group id of the menu item.
|
||||
* @param icon
|
||||
* The icon id of the menu item.
|
||||
* @param tooltipText
|
||||
* The tooltip text of the menu item.
|
||||
* @param priority
|
||||
* The priority of the menu item used to display the order of the menu item.
|
||||
*/
|
||||
public Builder(
|
||||
int itemId) {
|
||||
int itemId,
|
||||
@NonNull CharSequence title,
|
||||
@Nullable CharSequence contentDescription,
|
||||
int groupId,
|
||||
@Nullable Icon icon,
|
||||
@Nullable CharSequence tooltipText,
|
||||
int priority) {
|
||||
mItemId = itemId;
|
||||
mTitle = title;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mTitle);
|
||||
mContentDescription = contentDescription;
|
||||
mGroupId = groupId;
|
||||
mIcon = icon;
|
||||
mTooltipText = tooltipText;
|
||||
mPriority = priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getItemId()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setItemId(int value) {
|
||||
@@ -178,18 +428,100 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of the menu item.
|
||||
*
|
||||
* @see MenuItem#getTitle()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setTitle(@NonNull CharSequence value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x2;
|
||||
mTitle = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The content description of the menu item.
|
||||
*
|
||||
* @see MenuItem#getContentDescription()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setContentDescription(@NonNull CharSequence value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x4;
|
||||
mContentDescription = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The group id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getGroupId()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setGroupId(int value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x8;
|
||||
mGroupId = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The icon id of the menu item.
|
||||
*
|
||||
* @see MenuItem#getIcon()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setIcon(@NonNull Icon value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x10;
|
||||
mIcon = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The tooltip text of the menu item.
|
||||
*
|
||||
* @see MenuItem#getTooltipText()
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setTooltipText(@NonNull CharSequence value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x20;
|
||||
mTooltipText = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The priority of the menu item used to display the order of the menu item.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setPriority(int value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x40;
|
||||
mPriority = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds the instance. This builder should not be touched after calling this! */
|
||||
public @NonNull ToolbarMenuItem build() {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x2; // Mark builder used
|
||||
mBuilderFieldsSet |= 0x80; // Mark builder used
|
||||
|
||||
ToolbarMenuItem o = new ToolbarMenuItem(
|
||||
mItemId);
|
||||
mItemId,
|
||||
mTitle,
|
||||
mContentDescription,
|
||||
mGroupId,
|
||||
mIcon,
|
||||
mTooltipText,
|
||||
mPriority);
|
||||
return o;
|
||||
}
|
||||
|
||||
private void checkNotUsed() {
|
||||
if ((mBuilderFieldsSet & 0x2) != 0) {
|
||||
if ((mBuilderFieldsSet & 0x80) != 0) {
|
||||
throw new IllegalStateException(
|
||||
"This Builder should not be reused. Use a new Builder instance instead");
|
||||
}
|
||||
@@ -197,10 +529,10 @@ public final class ToolbarMenuItem implements Parcelable {
|
||||
}
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1639488328542L,
|
||||
time = 1643200806234L,
|
||||
codegenVersion = "1.0.23",
|
||||
sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/ToolbarMenuItem.java",
|
||||
inputSignatures = "private final int mItemId\nclass ToolbarMenuItem extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true)")
|
||||
inputSignatures = "public static final int PRIORITY_UNKNOWN\npublic static final int PRIORITY_PRIMARY\npublic static final int PRIORITY_OVERFLOW\nprivate final int mItemId\nprivate final @android.annotation.NonNull java.lang.CharSequence mTitle\nprivate final @android.annotation.Nullable java.lang.CharSequence mContentDescription\nprivate final int mGroupId\nprivate final @android.annotation.Nullable android.graphics.drawable.Icon mIcon\nprivate final @android.annotation.Nullable java.lang.CharSequence mTooltipText\nprivate final int mPriority\npublic static int getPriorityFromMenuItem(android.view.MenuItem)\nclass ToolbarMenuItem extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
package android.view.selectiontoolbar;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.view.SurfaceControlViewHost;
|
||||
|
||||
import com.android.internal.util.DataClass;
|
||||
|
||||
@@ -35,7 +38,18 @@ public final class WidgetInfo implements Parcelable {
|
||||
*/
|
||||
private final long mWidgetToken;
|
||||
|
||||
// TODO: add members when the code really uses it
|
||||
/**
|
||||
* A Rect that defines the size and positioning of the remote view with respect to
|
||||
* its host window.
|
||||
*/
|
||||
@NonNull
|
||||
private final Rect mContentRect;
|
||||
|
||||
/**
|
||||
* The SurfacePackage pointing to the remote view.
|
||||
*/
|
||||
@NonNull
|
||||
private final SurfaceControlViewHost.SurfacePackage mSurfacePackage;
|
||||
|
||||
|
||||
|
||||
@@ -57,11 +71,24 @@ public final class WidgetInfo implements Parcelable {
|
||||
*
|
||||
* @param widgetToken
|
||||
* The token that is used to identify the selection toolbar.
|
||||
* @param contentRect
|
||||
* A Rect that defines the size and positioning of the remote view with respect to
|
||||
* its host window.
|
||||
* @param surfacePackage
|
||||
* The SurfacePackage pointing to the remote view.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public WidgetInfo(
|
||||
long widgetToken) {
|
||||
long widgetToken,
|
||||
@NonNull Rect contentRect,
|
||||
@NonNull SurfaceControlViewHost.SurfacePackage surfacePackage) {
|
||||
this.mWidgetToken = widgetToken;
|
||||
this.mContentRect = contentRect;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mContentRect);
|
||||
this.mSurfacePackage = surfacePackage;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mSurfacePackage);
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
@@ -74,6 +101,23 @@ public final class WidgetInfo implements Parcelable {
|
||||
return mWidgetToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Rect that defines the size and positioning of the remote view with respect to
|
||||
* its host window.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Rect getContentRect() {
|
||||
return mContentRect;
|
||||
}
|
||||
|
||||
/**
|
||||
* The SurfacePackage pointing to the remote view.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull SurfaceControlViewHost.SurfacePackage getSurfacePackage() {
|
||||
return mSurfacePackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public String toString() {
|
||||
@@ -81,7 +125,9 @@ public final class WidgetInfo implements Parcelable {
|
||||
// String fieldNameToString() { ... }
|
||||
|
||||
return "WidgetInfo { " +
|
||||
"widgetToken = " + mWidgetToken +
|
||||
"widgetToken = " + mWidgetToken + ", " +
|
||||
"contentRect = " + mContentRect + ", " +
|
||||
"surfacePackage = " + mSurfacePackage +
|
||||
" }";
|
||||
}
|
||||
|
||||
@@ -98,7 +144,9 @@ public final class WidgetInfo implements Parcelable {
|
||||
WidgetInfo that = (WidgetInfo) o;
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& mWidgetToken == that.mWidgetToken;
|
||||
&& mWidgetToken == that.mWidgetToken
|
||||
&& java.util.Objects.equals(mContentRect, that.mContentRect)
|
||||
&& java.util.Objects.equals(mSurfacePackage, that.mSurfacePackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,16 +157,20 @@ public final class WidgetInfo implements Parcelable {
|
||||
|
||||
int _hash = 1;
|
||||
_hash = 31 * _hash + Long.hashCode(mWidgetToken);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mContentRect);
|
||||
_hash = 31 * _hash + java.util.Objects.hashCode(mSurfacePackage);
|
||||
return _hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
// You can override field parcelling by defining methods like:
|
||||
// void parcelFieldName(Parcel dest, int flags) { ... }
|
||||
|
||||
dest.writeLong(mWidgetToken);
|
||||
dest.writeTypedObject(mContentRect, flags);
|
||||
dest.writeTypedObject(mSurfacePackage, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,13 +180,21 @@ public final class WidgetInfo implements Parcelable {
|
||||
/** @hide */
|
||||
@SuppressWarnings({"unchecked", "RedundantCast"})
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ WidgetInfo(@NonNull android.os.Parcel in) {
|
||||
/* package-private */ WidgetInfo(@NonNull Parcel in) {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
long widgetToken = in.readLong();
|
||||
Rect contentRect = (Rect) in.readTypedObject(Rect.CREATOR);
|
||||
SurfaceControlViewHost.SurfacePackage surfacePackage = (SurfaceControlViewHost.SurfacePackage) in.readTypedObject(SurfaceControlViewHost.SurfacePackage.CREATOR);
|
||||
|
||||
this.mWidgetToken = widgetToken;
|
||||
this.mContentRect = contentRect;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mContentRect);
|
||||
this.mSurfacePackage = surfacePackage;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mSurfacePackage);
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
@@ -148,16 +208,16 @@ public final class WidgetInfo implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WidgetInfo createFromParcel(@NonNull android.os.Parcel in) {
|
||||
public WidgetInfo createFromParcel(@NonNull Parcel in) {
|
||||
return new WidgetInfo(in);
|
||||
}
|
||||
};
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1639488254020L,
|
||||
time = 1643281495056L,
|
||||
codegenVersion = "1.0.23",
|
||||
sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/WidgetInfo.java",
|
||||
inputSignatures = "private final long mWidgetToken\nclass WidgetInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)")
|
||||
inputSignatures = "private final long mWidgetToken\nprivate final @android.annotation.NonNull android.graphics.Rect mContentRect\nprivate final @android.annotation.NonNull android.view.SurfaceControlViewHost.SurfacePackage mSurfacePackage\nclass WidgetInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
@@ -19,8 +19,10 @@ package com.android.server.selectiontoolbar;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.service.selectiontoolbar.ISelectionToolbarRenderService;
|
||||
import android.service.selectiontoolbar.SelectionToolbarRenderService;
|
||||
import android.util.Slog;
|
||||
import android.view.selectiontoolbar.ISelectionToolbarCallback;
|
||||
import android.view.selectiontoolbar.ShowInfo;
|
||||
|
||||
@@ -35,12 +37,14 @@ final class RemoteSelectionToolbarRenderService extends
|
||||
AbstractRemoteService.PERMANENT_BOUND_TIMEOUT_MS;
|
||||
|
||||
private final ComponentName mComponentName;
|
||||
private final IBinder mRemoteCallback;
|
||||
|
||||
|
||||
RemoteSelectionToolbarRenderService(Context context, ComponentName serviceName, int userId) {
|
||||
RemoteSelectionToolbarRenderService(Context context, ComponentName serviceName, int userId,
|
||||
IBinder callback) {
|
||||
super(context, new Intent(SelectionToolbarRenderService.SERVICE_INTERFACE).setComponent(
|
||||
serviceName), 0, userId, ISelectionToolbarRenderService.Stub::asInterface);
|
||||
mComponentName = serviceName;
|
||||
mRemoteCallback = callback;
|
||||
// Bind right away.
|
||||
connect();
|
||||
}
|
||||
@@ -50,19 +54,31 @@ final class RemoteSelectionToolbarRenderService extends
|
||||
return TIMEOUT_IDLE_UNBIND_MS;
|
||||
}
|
||||
|
||||
@Override // from ServiceConnector.Impl
|
||||
protected void onServiceConnectionStatusChanged(ISelectionToolbarRenderService service,
|
||||
boolean connected) {
|
||||
try {
|
||||
if (connected) {
|
||||
service.onConnected(mRemoteCallback);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Slog.w(TAG, "Exception calling onConnected().", e);
|
||||
}
|
||||
}
|
||||
|
||||
public ComponentName getComponentName() {
|
||||
return mComponentName;
|
||||
}
|
||||
|
||||
public void onShow(ShowInfo showInfo, ISelectionToolbarCallback callback) {
|
||||
run((s) -> s.onShow(showInfo, callback));
|
||||
public void onShow(int callingUid, ShowInfo showInfo, ISelectionToolbarCallback callback) {
|
||||
run((s) -> s.onShow(callingUid, showInfo, callback));
|
||||
}
|
||||
|
||||
public void onHide(long widgetToken) {
|
||||
run((s) -> s.onHide(widgetToken));
|
||||
}
|
||||
|
||||
public void onDismiss(long widgetToken) {
|
||||
run((s) -> s.onDismiss(widgetToken));
|
||||
public void onDismiss(int callingUid, long widgetToken) {
|
||||
run((s) -> s.onDismiss(callingUid, widgetToken));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,17 @@ import android.app.AppGlobals;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.hardware.input.InputManagerInternal;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.service.selectiontoolbar.ISelectionToolbarRenderServiceCallback;
|
||||
import android.util.Slog;
|
||||
import android.view.selectiontoolbar.ISelectionToolbarCallback;
|
||||
import android.view.selectiontoolbar.ShowInfo;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.infra.AbstractPerUserSystemService;
|
||||
|
||||
final class SelectionToolbarManagerServiceImpl extends
|
||||
@@ -41,9 +46,14 @@ final class SelectionToolbarManagerServiceImpl extends
|
||||
@Nullable
|
||||
private RemoteSelectionToolbarRenderService mRemoteService;
|
||||
|
||||
InputManagerInternal mInputManagerInternal;
|
||||
private final SelectionToolbarRenderServiceRemoteCallback mRemoteServiceCallback =
|
||||
new SelectionToolbarRenderServiceRemoteCallback();
|
||||
|
||||
protected SelectionToolbarManagerServiceImpl(@NonNull SelectionToolbarManagerService master,
|
||||
@NonNull Object lock, int userId) {
|
||||
super(master, lock, userId);
|
||||
mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
|
||||
updateRemoteServiceLocked();
|
||||
}
|
||||
|
||||
@@ -78,7 +88,7 @@ final class SelectionToolbarManagerServiceImpl extends
|
||||
void showToolbar(ShowInfo showInfo, ISelectionToolbarCallback callback) {
|
||||
final RemoteSelectionToolbarRenderService remoteService = ensureRemoteServiceLocked();
|
||||
if (remoteService != null) {
|
||||
remoteService.onShow(showInfo, callback);
|
||||
remoteService.onShow(Binder.getCallingUid(), showInfo, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +104,7 @@ final class SelectionToolbarManagerServiceImpl extends
|
||||
void dismissToolbar(long widgetToken) {
|
||||
final RemoteSelectionToolbarRenderService remoteService = ensureRemoteServiceLocked();
|
||||
if (remoteService != null) {
|
||||
remoteService.onDismiss(widgetToken);
|
||||
remoteService.onDismiss(Binder.getCallingUid(), widgetToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +115,7 @@ final class SelectionToolbarManagerServiceImpl extends
|
||||
final String serviceName = getComponentNameLocked();
|
||||
final ComponentName serviceComponent = ComponentName.unflattenFromString(serviceName);
|
||||
mRemoteService = new RemoteSelectionToolbarRenderService(getContext(), serviceComponent,
|
||||
mUserId);
|
||||
mUserId, mRemoteServiceCallback);
|
||||
}
|
||||
return mRemoteService;
|
||||
}
|
||||
@@ -125,4 +135,17 @@ final class SelectionToolbarManagerServiceImpl extends
|
||||
}
|
||||
return si;
|
||||
}
|
||||
|
||||
private void transferTouchFocus(IBinder source, IBinder target) {
|
||||
mInputManagerInternal.transferTouchFocus(source, target);
|
||||
}
|
||||
|
||||
private final class SelectionToolbarRenderServiceRemoteCallback extends
|
||||
ISelectionToolbarRenderServiceCallback.Stub {
|
||||
|
||||
@Override
|
||||
public void transferTouch(IBinder source, IBinder target) {
|
||||
transferTouchFocus(source, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user