Initial layout of selection toolbar.
The initial selection toolbar related architecture. Render service part and the implementation will be revised in the follow up changes. Bug: 190030331 Bug: 205822301 Test: manual. Can boot to home and get manager successfully. Ignore-AOSP-First: new file for T Change-Id: Iab5d5f2e5e48e6258a63fb0c479194c958ea61e8
This commit is contained in:
@@ -227,6 +227,8 @@ import android.view.contentcapture.ContentCaptureManager;
|
||||
import android.view.contentcapture.IContentCaptureManager;
|
||||
import android.view.displayhash.DisplayHashManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.selectiontoolbar.ISelectionToolbarManager;
|
||||
import android.view.selectiontoolbar.SelectionToolbarManager;
|
||||
import android.view.textclassifier.TextClassificationManager;
|
||||
import android.view.textservice.TextServicesManager;
|
||||
import android.view.translation.ITranslationManager;
|
||||
@@ -366,6 +368,15 @@ public final class SystemServiceRegistry {
|
||||
return new TextClassificationManager(ctx);
|
||||
}});
|
||||
|
||||
registerService(Context.SELECTION_TOOLBAR_SERVICE, SelectionToolbarManager.class,
|
||||
new CachedServiceFetcher<SelectionToolbarManager>() {
|
||||
@Override
|
||||
public SelectionToolbarManager createService(ContextImpl ctx) {
|
||||
IBinder b = ServiceManager.getService(Context.SELECTION_TOOLBAR_SERVICE);
|
||||
return new SelectionToolbarManager(ctx.getOuterContext(),
|
||||
ISelectionToolbarManager.Stub.asInterface(b));
|
||||
}});
|
||||
|
||||
registerService(Context.FONT_SERVICE, FontManager.class,
|
||||
new CachedServiceFetcher<FontManager>() {
|
||||
@Override
|
||||
|
||||
@@ -4788,6 +4788,15 @@ public abstract class Context {
|
||||
*/
|
||||
public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification";
|
||||
|
||||
/**
|
||||
* Use with {@link #getSystemService(String)} to retrieve a
|
||||
* {@link android.view.selectiontoolbar.SelectionToolbarManager} for selection toolbar service.
|
||||
*
|
||||
* @see #getSystemService(String)
|
||||
* @hide
|
||||
*/
|
||||
public static final String SELECTION_TOOLBAR_SERVICE = "selection_toolbar";
|
||||
|
||||
/**
|
||||
* Use with {@link #getSystemService(String)} to retrieve a
|
||||
* {@link android.graphics.fonts.FontManager} for font services.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.view.selectiontoolbar.ToolbarMenuItem;
|
||||
import android.view.selectiontoolbar.WidgetInfo;
|
||||
|
||||
/**
|
||||
* Binder interface to notify the selection toolbar events from one process to the other.
|
||||
* @hide
|
||||
*/
|
||||
oneway interface ISelectionToolbarCallback {
|
||||
void onShown(in WidgetInfo info);
|
||||
void onHidden();
|
||||
void onDismissed();
|
||||
void onWidgetUpdated(in WidgetInfo info);
|
||||
void onMenuItemClicked(in ToolbarMenuItem item);
|
||||
void onError(int errorCode);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.view.selectiontoolbar.ISelectionToolbarCallback;
|
||||
import android.view.selectiontoolbar.ShowInfo;
|
||||
|
||||
/**
|
||||
* Mediator between apps and selection toolbar service implementation.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
oneway interface ISelectionToolbarManager {
|
||||
void showToolbar(in ShowInfo showInfo, in ISelectionToolbarCallback callback, int userId);
|
||||
void hideToolbar(long widgetToken, int userId);
|
||||
void dismissToolbar(long widgetToken, int userId);
|
||||
}
|
||||
10
core/java/android/view/selectiontoolbar/OWNERS
Normal file
10
core/java/android/view/selectiontoolbar/OWNERS
Normal file
@@ -0,0 +1,10 @@
|
||||
# Bug component: 709498
|
||||
|
||||
augale@google.com
|
||||
joannechung@google.com
|
||||
licha@google.com
|
||||
lpeter@google.com
|
||||
svetoslavganov@google.com
|
||||
toki@google.com
|
||||
tonymak@google.com
|
||||
tymtsai@google.com
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
parcelable SelectionContext;
|
||||
248
core/java/android/view/selectiontoolbar/SelectionContext.java
Normal file
248
core/java/android/view/selectiontoolbar/SelectionContext.java
Normal file
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.annotation.SystemService;
|
||||
import android.content.Context;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The {@link SelectionToolbarManager} class provides ways for apps to control the
|
||||
* selection toolbar.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemService(Context.SELECTION_TOOLBAR_SERVICE)
|
||||
public final class SelectionToolbarManager {
|
||||
|
||||
private static final String TAG = "SelectionToolbar";
|
||||
|
||||
/**
|
||||
* The tag which uses for enabling debug log dump. To enable it, we can use command "adb shell
|
||||
* setprop log.tag.UiTranslation DEBUG".
|
||||
*/
|
||||
public static final String LOG_TAG = "SelectionToolbar";
|
||||
|
||||
|
||||
@NonNull
|
||||
private final Context mContext;
|
||||
private final ISelectionToolbarManager mService;
|
||||
|
||||
public SelectionToolbarManager(@NonNull Context context,
|
||||
@NonNull ISelectionToolbarManager service) {
|
||||
mContext = Objects.requireNonNull(context);
|
||||
mService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to show selection toolbar for a given View.
|
||||
*/
|
||||
public void showToolbar(@NonNull ShowInfo showInfo,
|
||||
@NonNull ISelectionToolbarCallback callback) {
|
||||
try {
|
||||
Objects.requireNonNull(showInfo);
|
||||
Objects.requireNonNull(callback);
|
||||
mService.showToolbar(showInfo, callback, mContext.getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to hide selection toolbar.
|
||||
*/
|
||||
public void hideToolbar(long widgetToken) {
|
||||
try {
|
||||
mService.hideToolbar(widgetToken, mContext.getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss to dismiss selection toolbar.
|
||||
*/
|
||||
public void dismissToolbar(long widgetToken) {
|
||||
try {
|
||||
mService.dismissToolbar(widgetToken, mContext.getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
22
core/java/android/view/selectiontoolbar/ShowInfo.aidl
Normal file
22
core/java/android/view/selectiontoolbar/ShowInfo.aidl
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
parcelable ShowInfo;
|
||||
169
core/java/android/view/selectiontoolbar/ShowInfo.java
Normal file
169
core/java/android/view/selectiontoolbar/ShowInfo.java
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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 menu information for render service to render the selection toolbar.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@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
|
||||
|
||||
|
||||
|
||||
|
||||
// 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/ShowInfo.java
|
||||
//
|
||||
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
|
||||
// Settings > Editor > Code Style > Formatter Control
|
||||
//@formatter:off
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new ShowInfo.
|
||||
*
|
||||
* @param widgetToken
|
||||
* The token that is used to identify the selection toolbar.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public ShowInfo(
|
||||
long widgetToken) {
|
||||
this.mWidgetToken = widgetToken;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
/**
|
||||
* The token that is used to identify the selection toolbar.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public long getWidgetToken() {
|
||||
return mWidgetToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public String toString() {
|
||||
// You can override field toString logic by defining methods like:
|
||||
// String fieldNameToString() { ... }
|
||||
|
||||
return "ShowInfo { " +
|
||||
"widgetToken = " + mWidgetToken +
|
||||
" }";
|
||||
}
|
||||
|
||||
@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(ShowInfo other) { ... }
|
||||
// boolean fieldNameEquals(FieldType otherValue) { ... }
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
@SuppressWarnings("unchecked")
|
||||
ShowInfo that = (ShowInfo) o;
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& mWidgetToken == that.mWidgetToken;
|
||||
}
|
||||
|
||||
@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 + Long.hashCode(mWidgetToken);
|
||||
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.writeLong(mWidgetToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public int describeContents() { return 0; }
|
||||
|
||||
/** @hide */
|
||||
@SuppressWarnings({"unchecked", "RedundantCast"})
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ ShowInfo(@NonNull android.os.Parcel in) {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
long widgetToken = in.readLong();
|
||||
|
||||
this.mWidgetToken = widgetToken;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public static final @NonNull Parcelable.Creator<ShowInfo> CREATOR
|
||||
= new Parcelable.Creator<ShowInfo>() {
|
||||
@Override
|
||||
public ShowInfo[] newArray(int size) {
|
||||
return new ShowInfo[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShowInfo createFromParcel(@NonNull android.os.Parcel in) {
|
||||
return new ShowInfo(in);
|
||||
}
|
||||
};
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1639488262761L,
|
||||
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)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
//@formatter:on
|
||||
// End of generated code
|
||||
|
||||
}
|
||||
22
core/java/android/view/selectiontoolbar/ToolbarMenuItem.aidl
Normal file
22
core/java/android/view/selectiontoolbar/ToolbarMenuItem.aidl
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
parcelable ToolbarMenuItem;
|
||||
211
core/java/android/view/selectiontoolbar/ToolbarMenuItem.java
Normal file
211
core/java/android/view/selectiontoolbar/ToolbarMenuItem.java
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* 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.annotation.Nullable;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.util.DataClass;
|
||||
|
||||
/**
|
||||
* The menu item that is used to show the selection toolbar.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true)
|
||||
public final class ToolbarMenuItem implements Parcelable {
|
||||
|
||||
/**
|
||||
* The id of the menu item.
|
||||
*/
|
||||
private final int mItemId;
|
||||
|
||||
|
||||
|
||||
// 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/ToolbarMenuItem.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 */ ToolbarMenuItem(
|
||||
int itemId) {
|
||||
this.mItemId = itemId;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the menu item.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public int getItemId() {
|
||||
return mItemId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public String toString() {
|
||||
// You can override field toString logic by defining methods like:
|
||||
// String fieldNameToString() { ... }
|
||||
|
||||
return "ToolbarMenuItem { " +
|
||||
"itemId = " + mItemId +
|
||||
" }";
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public boolean equals(@Nullable Object o) {
|
||||
// You can override field equality logic by defining either of the methods like:
|
||||
// boolean fieldNameEquals(ToolbarMenuItem other) { ... }
|
||||
// boolean fieldNameEquals(FieldType otherValue) { ... }
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
@SuppressWarnings("unchecked")
|
||||
ToolbarMenuItem that = (ToolbarMenuItem) o;
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& mItemId == that.mItemId;
|
||||
}
|
||||
|
||||
@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 + mItemId;
|
||||
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(mItemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public int describeContents() { return 0; }
|
||||
|
||||
/** @hide */
|
||||
@SuppressWarnings({"unchecked", "RedundantCast"})
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ ToolbarMenuItem(@NonNull android.os.Parcel in) {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
int itemId = in.readInt();
|
||||
|
||||
this.mItemId = itemId;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public static final @NonNull Parcelable.Creator<ToolbarMenuItem> CREATOR
|
||||
= new Parcelable.Creator<ToolbarMenuItem>() {
|
||||
@Override
|
||||
public ToolbarMenuItem[] newArray(int size) {
|
||||
return new ToolbarMenuItem[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolbarMenuItem createFromParcel(@NonNull android.os.Parcel in) {
|
||||
return new ToolbarMenuItem(in);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A builder for {@link ToolbarMenuItem}
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@DataClass.Generated.Member
|
||||
public static final class Builder {
|
||||
|
||||
private int mItemId;
|
||||
|
||||
private long mBuilderFieldsSet = 0L;
|
||||
|
||||
/**
|
||||
* Creates a new Builder.
|
||||
*
|
||||
* @param itemId
|
||||
* The id of the menu item.
|
||||
*/
|
||||
public Builder(
|
||||
int itemId) {
|
||||
mItemId = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the menu item.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public @NonNull Builder setItemId(int value) {
|
||||
checkNotUsed();
|
||||
mBuilderFieldsSet |= 0x1;
|
||||
mItemId = 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
|
||||
|
||||
ToolbarMenuItem o = new ToolbarMenuItem(
|
||||
mItemId);
|
||||
return o;
|
||||
}
|
||||
|
||||
private void checkNotUsed() {
|
||||
if ((mBuilderFieldsSet & 0x2) != 0) {
|
||||
throw new IllegalStateException(
|
||||
"This Builder should not be reused. Use a new Builder instance instead");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1639488328542L,
|
||||
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)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
//@formatter:on
|
||||
// End of generated code
|
||||
|
||||
}
|
||||
22
core/java/android/view/selectiontoolbar/WidgetInfo.aidl
Normal file
22
core/java/android/view/selectiontoolbar/WidgetInfo.aidl
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
parcelable WidgetInfo;
|
||||
168
core/java/android/view/selectiontoolbar/WidgetInfo.java
Normal file
168
core/java/android/view/selectiontoolbar/WidgetInfo.java
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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 the rendered content and the related information from the render service to
|
||||
* be used to show on the selection toolbar.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@DataClass(genToString = true, genEqualsHashCode = true)
|
||||
public final class WidgetInfo implements Parcelable {
|
||||
|
||||
/**
|
||||
* The token that is used to identify the selection toolbar.
|
||||
*/
|
||||
private final long mWidgetToken;
|
||||
|
||||
// TODO: add members when the code really uses it
|
||||
|
||||
|
||||
|
||||
// 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/WidgetInfo.java
|
||||
//
|
||||
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
|
||||
// Settings > Editor > Code Style > Formatter Control
|
||||
//@formatter:off
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new WidgetInfo.
|
||||
*
|
||||
* @param widgetToken
|
||||
* The token that is used to identify the selection toolbar.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public WidgetInfo(
|
||||
long widgetToken) {
|
||||
this.mWidgetToken = widgetToken;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
/**
|
||||
* The token that is used to identify the selection toolbar.
|
||||
*/
|
||||
@DataClass.Generated.Member
|
||||
public long getWidgetToken() {
|
||||
return mWidgetToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public String toString() {
|
||||
// You can override field toString logic by defining methods like:
|
||||
// String fieldNameToString() { ... }
|
||||
|
||||
return "WidgetInfo { " +
|
||||
"widgetToken = " + mWidgetToken +
|
||||
" }";
|
||||
}
|
||||
|
||||
@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(WidgetInfo other) { ... }
|
||||
// boolean fieldNameEquals(FieldType otherValue) { ... }
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
@SuppressWarnings("unchecked")
|
||||
WidgetInfo that = (WidgetInfo) o;
|
||||
//noinspection PointlessBooleanExpression
|
||||
return true
|
||||
&& mWidgetToken == that.mWidgetToken;
|
||||
}
|
||||
|
||||
@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 + Long.hashCode(mWidgetToken);
|
||||
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.writeLong(mWidgetToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataClass.Generated.Member
|
||||
public int describeContents() { return 0; }
|
||||
|
||||
/** @hide */
|
||||
@SuppressWarnings({"unchecked", "RedundantCast"})
|
||||
@DataClass.Generated.Member
|
||||
/* package-private */ WidgetInfo(@NonNull android.os.Parcel in) {
|
||||
// You can override field unparcelling by defining methods like:
|
||||
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||
|
||||
long widgetToken = in.readLong();
|
||||
|
||||
this.mWidgetToken = widgetToken;
|
||||
|
||||
// onConstructed(); // You can define this method to get a callback
|
||||
}
|
||||
|
||||
@DataClass.Generated.Member
|
||||
public static final @NonNull Parcelable.Creator<WidgetInfo> CREATOR
|
||||
= new Parcelable.Creator<WidgetInfo>() {
|
||||
@Override
|
||||
public WidgetInfo[] newArray(int size) {
|
||||
return new WidgetInfo[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public WidgetInfo createFromParcel(@NonNull android.os.Parcel in) {
|
||||
return new WidgetInfo(in);
|
||||
}
|
||||
};
|
||||
|
||||
@DataClass.Generated(
|
||||
time = 1639488254020L,
|
||||
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)")
|
||||
@Deprecated
|
||||
private void __metadata() {}
|
||||
|
||||
|
||||
//@formatter:on
|
||||
// End of generated code
|
||||
|
||||
}
|
||||
@@ -3997,6 +3997,14 @@
|
||||
<permission android:name="android.permission.BIND_TEXTCLASSIFIER_SERVICE"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- Must be required by a android.service.selectiontoolbar.SelectionToolbarRenderService,
|
||||
to ensure that only the system can bind to it.
|
||||
@hide This is not a third-party API (intended for OEMs and system apps).
|
||||
<p>Protection level: signature
|
||||
-->
|
||||
<permission android:name="android.permission.BIND_SELECTION_TOOLBAR_RENDER_SERVICE"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- Must be required by a android.service.contentcapture.ContentCaptureService,
|
||||
to ensure that only the system can bind to it.
|
||||
@SystemApi @hide This is not a third-party API (intended for OEMs and system apps).
|
||||
|
||||
@@ -90,6 +90,7 @@ filegroup {
|
||||
":services.profcollect-sources",
|
||||
":services.restrictions-sources",
|
||||
":services.searchui-sources",
|
||||
":services.selectiontoolbar-sources",
|
||||
":services.smartspace-sources",
|
||||
":services.speech-sources",
|
||||
":services.startop.iorap-sources",
|
||||
@@ -144,6 +145,7 @@ java_library {
|
||||
"services.profcollect",
|
||||
"services.restrictions",
|
||||
"services.searchui",
|
||||
"services.selectiontoolbar",
|
||||
"services.smartspace",
|
||||
"services.speech",
|
||||
"services.startop",
|
||||
|
||||
@@ -332,6 +332,8 @@ public final class SystemServer implements Dumpable {
|
||||
"com.android.server.contentcapture.ContentCaptureManagerService";
|
||||
private static final String TRANSLATION_MANAGER_SERVICE_CLASS =
|
||||
"com.android.server.translation.TranslationManagerService";
|
||||
private static final String SELECTION_TOOLBAR_MANAGER_SERVICE_CLASS =
|
||||
"com.android.server.selectiontoolbar.SelectionToolbarManagerService";
|
||||
private static final String MUSIC_RECOGNITION_MANAGER_SERVICE_CLASS =
|
||||
"com.android.server.musicrecognition.MusicRecognitionManagerService";
|
||||
private static final String SYSTEM_CAPTIONS_MANAGER_SERVICE_CLASS =
|
||||
@@ -2592,6 +2594,11 @@ public final class SystemServer implements Dumpable {
|
||||
Slog.d(TAG, "TranslationService not defined by OEM");
|
||||
}
|
||||
|
||||
// Selection toolbar service
|
||||
t.traceBegin("StartSelectionToolbarManagerService");
|
||||
mSystemServiceManager.startService(SELECTION_TOOLBAR_MANAGER_SERVICE_CLASS);
|
||||
t.traceEnd();
|
||||
|
||||
// NOTE: ClipboardService depends on ContentCapture and Autofill
|
||||
t.traceBegin("StartClipboardService");
|
||||
mSystemServiceManager.startService(ClipboardService.class);
|
||||
|
||||
22
services/selectiontoolbar/Android.bp
Normal file
22
services/selectiontoolbar/Android.bp
Normal file
@@ -0,0 +1,22 @@
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "frameworks_base_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["frameworks_base_license"],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "services.selectiontoolbar-sources",
|
||||
srcs: ["java/**/*.java"],
|
||||
path: "java",
|
||||
visibility: ["//frameworks/base/services"],
|
||||
}
|
||||
|
||||
java_library_static {
|
||||
name: "services.selectiontoolbar",
|
||||
defaults: ["platform_service_defaults"],
|
||||
srcs: [":services.selectiontoolbar-sources"],
|
||||
libs: ["services.core"],
|
||||
}
|
||||
1
services/selectiontoolbar/OWNERS
Normal file
1
services/selectiontoolbar/OWNERS
Normal file
@@ -0,0 +1 @@
|
||||
include /core/java/android/view/selectiontoolbar/OWNERS
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 com.android.server.selectiontoolbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Slog;
|
||||
import android.view.selectiontoolbar.ISelectionToolbarCallback;
|
||||
import android.view.selectiontoolbar.ISelectionToolbarManager;
|
||||
import android.view.selectiontoolbar.ShowInfo;
|
||||
|
||||
import com.android.internal.util.DumpUtils;
|
||||
import com.android.server.infra.AbstractMasterSystemService;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Entry point service for selection toolbar management.
|
||||
*/
|
||||
public final class SelectionToolbarManagerService extends
|
||||
AbstractMasterSystemService<SelectionToolbarManagerService,
|
||||
SelectionToolbarManagerServiceImpl> {
|
||||
|
||||
private static final String TAG = "SelectionToolbarManagerService";
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
publishBinderService(Context.SELECTION_TOOLBAR_SERVICE,
|
||||
new SelectionToolbarManagerService.SelectionToolbarManagerServiceStub());
|
||||
}
|
||||
|
||||
public SelectionToolbarManagerService(Context context) {
|
||||
super(context, new SelectionToolbarServiceNameResolver(), /* disallowProperty= */
|
||||
null, PACKAGE_UPDATE_POLICY_REFRESH_EAGER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SelectionToolbarManagerServiceImpl newServiceLocked(int resolvedUserId,
|
||||
boolean disabled) {
|
||||
return new SelectionToolbarManagerServiceImpl(this, mLock, resolvedUserId);
|
||||
}
|
||||
|
||||
final class SelectionToolbarManagerServiceStub extends ISelectionToolbarManager.Stub {
|
||||
|
||||
@Override
|
||||
public void showToolbar(ShowInfo showInfo, ISelectionToolbarCallback callback, int userId) {
|
||||
synchronized (mLock) {
|
||||
SelectionToolbarManagerServiceImpl service = getServiceForUserLocked(userId);
|
||||
if (service != null) {
|
||||
service.showToolbar(showInfo, callback);
|
||||
} else {
|
||||
Slog.v(TAG, "showToolbar(): no service for " + userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideToolbar(long widgetToken, int userId) {
|
||||
synchronized (mLock) {
|
||||
SelectionToolbarManagerServiceImpl service = getServiceForUserLocked(userId);
|
||||
if (service != null) {
|
||||
service.hideToolbar(widgetToken);
|
||||
} else {
|
||||
Slog.v(TAG, "hideToolbar(): no service for " + userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissToolbar(long widgetToken, int userId) {
|
||||
synchronized (mLock) {
|
||||
SelectionToolbarManagerServiceImpl service = getServiceForUserLocked(userId);
|
||||
if (service != null) {
|
||||
service.dismissToolbar(widgetToken);
|
||||
} else {
|
||||
Slog.v(TAG, "dismissToolbar(): no service for " + userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) return;
|
||||
|
||||
synchronized (mLock) {
|
||||
dumpLocked("", pw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 com.android.server.selectiontoolbar;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.view.selectiontoolbar.ISelectionToolbarCallback;
|
||||
import android.view.selectiontoolbar.ShowInfo;
|
||||
|
||||
import com.android.server.infra.AbstractPerUserSystemService;
|
||||
|
||||
final class SelectionToolbarManagerServiceImpl extends
|
||||
AbstractPerUserSystemService<SelectionToolbarManagerServiceImpl,
|
||||
SelectionToolbarManagerService> {
|
||||
|
||||
private static final String TAG = "SelectionToolbarManagerServiceImpl";
|
||||
|
||||
protected SelectionToolbarManagerServiceImpl(@NonNull SelectionToolbarManagerService master,
|
||||
@NonNull Object lock, int userId) {
|
||||
super(master, lock, userId);
|
||||
}
|
||||
|
||||
void showToolbar(ShowInfo showInfo, ISelectionToolbarCallback callback) {
|
||||
// TODO: add implementation to bind service
|
||||
}
|
||||
|
||||
void hideToolbar(long widgetToken) {
|
||||
// TODO: add implementation to bind service
|
||||
}
|
||||
|
||||
void dismissToolbar(long widgetToken) {
|
||||
// TODO: add implementation to bind service
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 com.android.server.selectiontoolbar;
|
||||
|
||||
import com.android.server.infra.ServiceNameResolver;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
final class SelectionToolbarServiceNameResolver implements ServiceNameResolver {
|
||||
|
||||
// TODO: move to SysUi or ExtServices
|
||||
private static final String SELECTION_TOOLBAR_SERVICE_NAME =
|
||||
"android/com.android.server.selectiontoolbar.DefaultSelectionToolbarRenderService";
|
||||
|
||||
@Override
|
||||
public String getDefaultServiceName(int userId) {
|
||||
return SELECTION_TOOLBAR_SERVICE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpShort(PrintWriter pw) {
|
||||
pw.print("service="); pw.print(SELECTION_TOOLBAR_SERVICE_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpShort(PrintWriter pw, int userId) {
|
||||
pw.print("defaultService="); pw.print(getDefaultServiceName(userId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user