diff options
15 files changed, 126 insertions, 86 deletions
diff --git a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java index 1efa3dd0c865..b47b2b41bdd9 100644 --- a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java +++ b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java @@ -31,6 +31,7 @@ import android.content.ComponentName; import android.content.Intent; import android.graphics.Rect; import android.os.Build; +import android.os.Bundle; import android.os.CancellationSignal; import android.os.Handler; import android.os.IBinder; @@ -558,9 +559,10 @@ public abstract class AugmentedAutofillService extends Service { } } - void reportResult(@Nullable List<Dataset> inlineSuggestionsData) { + void reportResult(@Nullable List<Dataset> inlineSuggestionsData, + @Nullable Bundle clientState) { try { - mCallback.onSuccess(inlineSuggestionsData); + mCallback.onSuccess(inlineSuggestionsData, clientState); } catch (RemoteException e) { Log.e(TAG, "Error calling back with the inline suggestions data: " + e); } diff --git a/core/java/android/service/autofill/augmented/FillCallback.java b/core/java/android/service/autofill/augmented/FillCallback.java index 526a749c95a1..21738d80f2d3 100644 --- a/core/java/android/service/autofill/augmented/FillCallback.java +++ b/core/java/android/service/autofill/augmented/FillCallback.java @@ -21,6 +21,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; +import android.os.Bundle; import android.service.autofill.Dataset; import android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy; import android.util.Log; @@ -55,14 +56,15 @@ public final class FillCallback { if (response == null) { mProxy.logEvent(AutofillProxy.REPORT_EVENT_NO_RESPONSE); - mProxy.reportResult(/* inlineSuggestionsData */ null); + mProxy.reportResult(/* inlineSuggestionsData */ null, /* clientState */ null); return; } List<Dataset> inlineSuggestions = response.getInlineSuggestions(); + Bundle clientState = response.getClientState(); if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) { mProxy.logEvent(AutofillProxy.REPORT_EVENT_INLINE_RESPONSE); - mProxy.reportResult(inlineSuggestions); + mProxy.reportResult(inlineSuggestions, clientState); return; } diff --git a/core/java/android/service/autofill/augmented/IFillCallback.aidl b/core/java/android/service/autofill/augmented/IFillCallback.aidl index 24af1e51dd56..609e382e2b96 100644 --- a/core/java/android/service/autofill/augmented/IFillCallback.aidl +++ b/core/java/android/service/autofill/augmented/IFillCallback.aidl @@ -30,7 +30,7 @@ import java.util.List; */ interface IFillCallback { void onCancellable(in ICancellationSignal cancellation); - void onSuccess(in @nullable List<Dataset> inlineSuggestionsData); + void onSuccess(in @nullable List<Dataset> inlineSuggestionsData, in @nullable Bundle clientState); boolean isCompleted(); void cancel(); } diff --git a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java b/core/java/com/android/internal/accessibility/dialog/AccessibilityShortcutChooserActivity.java index 4f98a6354ea3..9338c3c87217 100644 --- a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java +++ b/core/java/com/android/internal/accessibility/dialog/AccessibilityShortcutChooserActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.internal.app; +package com.android.internal.accessibility.dialog; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY; @@ -79,9 +79,10 @@ import java.util.List; import java.util.Locale; /** - * Activity used to display and persist a service or feature target for the Accessibility button. + * Activity used to display various targets related to accessibility service, accessibility + * activity or white listing feature for volume key shortcut. */ -public class AccessibilityButtonChooserActivity extends Activity { +public class AccessibilityShortcutChooserActivity extends Activity { @ShortcutType private static int sShortcutType; @UserShortcutType @@ -355,17 +356,18 @@ public class AccessibilityButtonChooserActivity extends Activity { ViewHolder holder; if (convertView == null) { convertView = LayoutInflater.from(context).inflate( - R.layout.accessibility_button_chooser_item, parent, /* attachToRoot= */ + R.layout.accessibility_shortcut_chooser_item, parent, /* attachToRoot= */ false); holder = new ViewHolder(); holder.mItemView = convertView; holder.mCheckBox = convertView.findViewById( - R.id.accessibility_button_target_checkbox); - holder.mIconView = convertView.findViewById(R.id.accessibility_button_target_icon); + R.id.accessibility_shortcut_target_checkbox); + holder.mIconView = convertView.findViewById( + R.id.accessibility_shortcut_target_icon); holder.mLabelView = convertView.findViewById( - R.id.accessibility_button_target_label); + R.id.accessibility_shortcut_target_label); holder.mSwitchItem = convertView.findViewById( - R.id.accessibility_button_target_switch_item); + R.id.accessibility_shortcut_target_switch_item); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); diff --git a/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java b/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java index bcbd6abc252c..a92a50d4d832 100644 --- a/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java +++ b/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java @@ -19,6 +19,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.Access import static com.android.internal.accessibility.common.ShortcutConstants.SERVICES_SEPARATOR; import android.accessibilityservice.AccessibilityServiceInfo; +import android.annotation.NonNull; import android.content.ComponentName; import android.content.Context; import android.os.Build; @@ -115,7 +116,7 @@ public final class AccessibilityUtils { * @return int from {@link AccessibilityFragmentType}. */ public static @AccessibilityFragmentType int getAccessibilityServiceFragmentType( - AccessibilityServiceInfo accessibilityServiceInfo) { + @NonNull AccessibilityServiceInfo accessibilityServiceInfo) { final int targetSdk = accessibilityServiceInfo.getResolveInfo() .serviceInfo.applicationInfo.targetSdkVersion; final boolean requestA11yButton = (accessibilityServiceInfo.flags diff --git a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java index 717e78078b1c..7ec80ecdb2a9 100644 --- a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java +++ b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java @@ -39,21 +39,21 @@ public final class ShortcutUtils { new TextUtils.SimpleStringSplitter(SERVICES_SEPARATOR); /** - * Opts in component name into colon-separated {@link UserShortcutType} - * key's string in Settings. + * Opts in component id into colon-separated {@link UserShortcutType} + * key's string from Settings. * * @param context The current context. * @param shortcutType The preferred shortcut type user selected. - * @param componentId The component id that need to be opted out from Settings. + * @param componentId The component id that need to be opted in Settings. */ public static void optInValueToSettings(Context context, @UserShortcutType int shortcutType, - String componentId) { + @NonNull String componentId) { final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR)); final String targetKey = convertToKey(shortcutType); final String targetString = Settings.Secure.getString(context.getContentResolver(), targetKey); - if (hasValueInSettings(context, shortcutType, componentId)) { + if (isComponentIdExistingInSettings(context, shortcutType, componentId)) { return; } @@ -66,14 +66,15 @@ public final class ShortcutUtils { } /** - * Opts out component name into colon-separated {@code shortcutType} key's string in Settings. + * Opts out of component id into colon-separated {@link UserShortcutType} key's string from + * Settings. * * @param context The current context. * @param shortcutType The preferred shortcut type user selected. - * @param componentId The component id that need to be opted out from Settings. + * @param componentId The component id that need to be opted out of Settings. */ public static void optOutValueFromSettings( - Context context, @UserShortcutType int shortcutType, String componentId) { + Context context, @UserShortcutType int shortcutType, @NonNull String componentId) { final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR)); final String targetsKey = convertToKey(shortcutType); final String targetsValue = Settings.Secure.getString(context.getContentResolver(), @@ -96,36 +97,38 @@ public final class ShortcutUtils { } /** - * Returns if component name existed in one of {@code shortcutTypes} string in Settings. + * Returns if component id existed in one of {@link UserShortcutType} string from Settings. * * @param context The current context. * @param shortcutTypes A combination of {@link UserShortcutType}. - * @param componentId The component name that need to be checked existed in Settings. - * @return {@code true} if componentName existed in Settings. + * @param componentId The component id that need to be checked existed in Settings. + * @return {@code true} if component id existed in Settings. */ - public static boolean hasValuesInSettings(Context context, int shortcutTypes, + public static boolean hasValuesInSettings(Context context, @UserShortcutType int shortcutTypes, @NonNull String componentId) { boolean exist = false; if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) { - exist = hasValueInSettings(context, UserShortcutType.SOFTWARE, componentId); + exist = isComponentIdExistingInSettings(context, UserShortcutType.SOFTWARE, + componentId); } if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) { - exist |= hasValueInSettings(context, UserShortcutType.HARDWARE, componentId); + exist |= isComponentIdExistingInSettings(context, UserShortcutType.HARDWARE, + componentId); } return exist; } /** - * Returns if component name existed in Settings. + * Returns if component id existed in Settings. * * @param context The current context. * @param shortcutType The preferred shortcut type user selected. * @param componentId The component id that need to be checked existed in Settings. - * @return {@code true} if componentName existed in Settings. + * @return {@code true} if component id existed in Settings. */ - public static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType, - @NonNull String componentId) { + public static boolean isComponentIdExistingInSettings(Context context, + @UserShortcutType int shortcutType, @NonNull String componentId) { final String targetKey = convertToKey(shortcutType); final String targetString = Settings.Secure.getString(context.getContentResolver(), targetKey); @@ -146,7 +149,7 @@ public final class ShortcutUtils { } /** - * Converts {@link UserShortcutType} to key in Settings. + * Converts {@link UserShortcutType} to {@link Settings.Secure} key. * * @param type The shortcut type. * @return Mapping key in Settings. @@ -169,7 +172,7 @@ public final class ShortcutUtils { * Converts {@link ShortcutType} to {@link UserShortcutType}. * * @param type The shortcut type. - * @return {@link UserShortcutType}. + * @return Mapping type from {@link UserShortcutType}. */ public static @UserShortcutType int convertToUserType(@ShortcutType int type) { switch (type) { diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 32a79f3ab8ae..5d6fc766676b 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -5060,7 +5060,7 @@ <category android:name="android.intent.category.VOICE" /> </intent-filter> </activity> - <activity android:name="com.android.internal.app.AccessibilityButtonChooserActivity" + <activity android:name="com.android.internal.accessibility.dialog.AccessibilityShortcutChooserActivity" android:exported="false" android:theme="@style/Theme.DeviceDefault.Dialog.Alert.DayNight" android:finishOnCloseSystemDialogs="true" diff --git a/core/res/res/layout/accessibility_button_chooser_item.xml b/core/res/res/layout/accessibility_shortcut_chooser_item.xml index b7dd892fd161..fff22d916b15 100644 --- a/core/res/res/layout/accessibility_button_chooser_item.xml +++ b/core/res/res/layout/accessibility_shortcut_chooser_item.xml @@ -24,7 +24,7 @@ android:padding="16dp"> <CheckBox - android:id="@+id/accessibility_button_target_checkbox" + android:id="@+id/accessibility_shortcut_target_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingStart="16dp" @@ -34,13 +34,13 @@ android:visibility="gone"/> <ImageView - android:id="@+id/accessibility_button_target_icon" + android:id="@+id/accessibility_shortcut_target_icon" android:layout_width="48dp" android:layout_height="48dp" android:scaleType="fitCenter"/> <TextView - android:id="@+id/accessibility_button_target_label" + android:id="@+id/accessibility_shortcut_target_label" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="16dp" @@ -50,7 +50,7 @@ android:fontFamily="sans-serif-medium"/> <Switch - android:id="@+id/accessibility_button_target_switch_item" + android:id="@+id/accessibility_shortcut_target_switch_item" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@null" diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ef1e8b74b05f..fdef5dd69aa0 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3232,12 +3232,13 @@ <java-symbol type="string" name="accessibility_enable_service_title" /> <java-symbol type="string" name="accessibility_enable_service_encryption_warning" /> + <java-symbol type="layout" name="accessibility_shortcut_chooser_item" /> + <java-symbol type="id" name="accessibility_shortcut_target_checkbox" /> + <java-symbol type="id" name="accessibility_shortcut_target_icon" /> + <java-symbol type="id" name="accessibility_shortcut_target_label" /> + <java-symbol type="id" name="accessibility_shortcut_target_switch_item" /> + <!-- Accessibility Button --> - <java-symbol type="layout" name="accessibility_button_chooser_item" /> - <java-symbol type="id" name="accessibility_button_target_checkbox" /> - <java-symbol type="id" name="accessibility_button_target_icon" /> - <java-symbol type="id" name="accessibility_button_target_label" /> - <java-symbol type="id" name="accessibility_button_target_switch_item" /> <java-symbol type="string" name="accessibility_magnification_chooser_text" /> <java-symbol type="string" name="edit_accessibility_shortcut_menu_button" /> <java-symbol type="string" name="done_accessibility_shortcut_menu_button" /> diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java index f89a01e0c73b..0125153542c1 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java +++ b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java @@ -322,13 +322,19 @@ public class PipTaskOrganizer extends TaskOrganizer { * @param destinationBoundsOut the current destination bounds will be populated to this param */ @SuppressWarnings("unchecked") - public void onMovementBoundsChanged(Rect destinationBoundsOut, + public void onMovementBoundsChanged(Rect destinationBoundsOut, boolean fromRotation, boolean fromImeAdjustment, boolean fromShelfAdjustment) { final PipAnimationController.PipTransitionAnimator animator = mPipAnimationController.getCurrentAnimator(); - destinationBoundsOut.set(mLastReportedBounds); if (animator == null || !animator.isRunning() || animator.getTransitionDirection() != TRANSITION_DIRECTION_TO_PIP) { + if (mInPip && fromRotation) { + // this could happen if rotation finishes before the animation + mLastReportedBounds.set(destinationBoundsOut); + scheduleFinishResizePip(mLastReportedBounds); + } else if (!mLastReportedBounds.isEmpty()) { + destinationBoundsOut.set(mLastReportedBounds); + } return; } diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java index a2667d9a4c74..c3779efcf4b2 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java @@ -97,8 +97,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio final boolean changed = mPipBoundsHandler.onDisplayRotationChanged(mTmpNormalBounds, displayId, fromRotation, toRotation, t); if (changed) { - updateMovementBounds(mTmpNormalBounds, false /* fromImeAdjustment */, - false /* fromShelfAdjustment */); + updateMovementBounds(mTmpNormalBounds, true /* fromRotation */, + false /* fromImeAdjustment */, false /* fromShelfAdjustment */); } }; @@ -163,7 +163,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio @Override public void onMovementBoundsChanged(boolean fromImeAdjustment) { mHandler.post(() -> updateMovementBounds(null /* toBounds */, - fromImeAdjustment, false /* fromShelfAdjustment */)); + false /* fromRotation */, fromImeAdjustment, false /* fromShelfAdjustment */)); } @Override @@ -294,7 +294,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio if (changed) { mTouchHandler.onShelfVisibilityChanged(visible, height); updateMovementBounds(mPipBoundsHandler.getLastDestinationBounds(), - false /* fromImeAdjustment */, true /* fromShelfAdjustment */); + false /* fromRotation */, false /* fromImeAdjustment */, + true /* fromShelfAdjustment */); } }); } @@ -353,7 +354,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio mMenuController.onPinnedStackAnimationEnded(); } - private void updateMovementBounds(@Nullable Rect toBounds, + private void updateMovementBounds(@Nullable Rect toBounds, boolean fromRotation, boolean fromImeAdjustment, boolean fromShelfAdjustment) { // Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler before // passing to mTouchHandler/mPipTaskOrganizer @@ -361,7 +362,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds, outBounds, mTmpDisplayInfo); // mTouchHandler would rely on the bounds populated from mPipTaskOrganizer - mPipTaskOrganizer.onMovementBoundsChanged(outBounds, + mPipTaskOrganizer.onMovementBoundsChanged(outBounds, fromRotation, fromImeAdjustment, fromShelfAdjustment); mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds, outBounds, fromImeAdjustment, fromShelfAdjustment, diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java index d1805d96cad8..1bc026cd3b19 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java @@ -815,26 +815,27 @@ final class AutofillManagerServiceImpl } } - void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId) { + void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId, + @Nullable Bundle clientState) { synchronized (mLock) { if (mAugmentedAutofillEventHistory == null || mAugmentedAutofillEventHistory.getSessionId() != sessionId) { return; } mAugmentedAutofillEventHistory.addEvent( - new Event(Event.TYPE_DATASET_SELECTED, suggestionId, null, null, null, + new Event(Event.TYPE_DATASET_SELECTED, suggestionId, clientState, null, null, null, null, null, null, null, null)); } } - void logAugmentedAutofillShown(int sessionId) { + void logAugmentedAutofillShown(int sessionId, @Nullable Bundle clientState) { synchronized (mLock) { if (mAugmentedAutofillEventHistory == null || mAugmentedAutofillEventHistory.getSessionId() != sessionId) { return; } mAugmentedAutofillEventHistory.addEvent( - new Event(Event.TYPE_DATASETS_SHOWN, null, null, null, null, null, + new Event(Event.TYPE_DATASETS_SHOWN, null, clientState, null, null, null, null, null, null, null, null)); } @@ -1185,15 +1186,16 @@ final class AutofillManagerServiceImpl } @Override - public void logAugmentedAutofillShown(int sessionId) { - AutofillManagerServiceImpl.this.logAugmentedAutofillShown(sessionId); + public void logAugmentedAutofillShown(int sessionId, Bundle clientState) { + AutofillManagerServiceImpl.this.logAugmentedAutofillShown(sessionId, + clientState); } @Override public void logAugmentedAutofillSelected(int sessionId, - String suggestionId) { + String suggestionId, Bundle clientState) { AutofillManagerServiceImpl.this.logAugmentedAutofillSelected(sessionId, - suggestionId); + suggestionId, clientState); } @Override diff --git a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java index b6bc7c5646a5..6cec8d82f9d4 100644 --- a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java +++ b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java @@ -168,12 +168,12 @@ final class RemoteAugmentedAutofillService focusedId, focusedValue, requestTime, inlineSuggestionsRequest, new IFillCallback.Stub() { @Override - public void onSuccess( - @Nullable List<Dataset> inlineSuggestionsData) { + public void onSuccess(@Nullable List<Dataset> inlineSuggestionsData, + @Nullable Bundle clientState) { mCallbacks.resetLastResponse(); maybeRequestShowInlineSuggestions(sessionId, inlineSuggestionsRequest, inlineSuggestionsData, - focusedId, inlineSuggestionsCallback, + clientState, focusedId, inlineSuggestionsCallback, client, onErrorCallback, remoteRenderService); requestAutofill.complete(null); } @@ -238,7 +238,8 @@ final class RemoteAugmentedAutofillService private void maybeRequestShowInlineSuggestions(int sessionId, @Nullable InlineSuggestionsRequest request, - @Nullable List<Dataset> inlineSuggestionsData, @NonNull AutofillId focusedId, + @Nullable List<Dataset> inlineSuggestionsData, @Nullable Bundle clientState, + @NonNull AutofillId focusedId, @Nullable Function<InlineSuggestionsResponse, Boolean> inlineSuggestionsCallback, @NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService) { @@ -256,7 +257,7 @@ final class RemoteAugmentedAutofillService @Override public void autofill(Dataset dataset) { mCallbacks.logAugmentedAutofillSelected(sessionId, - dataset.getId()); + dataset.getId(), clientState); try { final ArrayList<AutofillId> fieldIds = dataset.getFieldIds(); final int size = fieldIds.size(); @@ -287,7 +288,7 @@ final class RemoteAugmentedAutofillService return; } if (inlineSuggestionsCallback.apply(inlineSuggestionsResponse)) { - mCallbacks.logAugmentedAutofillShown(sessionId); + mCallbacks.logAugmentedAutofillShown(sessionId, clientState); } } @@ -310,8 +311,9 @@ final class RemoteAugmentedAutofillService void setLastResponse(int sessionId); - void logAugmentedAutofillShown(int sessionId); + void logAugmentedAutofillShown(int sessionId, @Nullable Bundle clientState); - void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId); + void logAugmentedAutofillSelected(int sessionId, @Nullable String suggestionId, + @Nullable Bundle clientState); } } diff --git a/services/core/java/com/android/server/hdmi/HdmiCecMessage.java b/services/core/java/com/android/server/hdmi/HdmiCecMessage.java index f8b39627f236..ff7da11340eb 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecMessage.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecMessage.java @@ -115,8 +115,12 @@ public final class HdmiCecMessage { s.append(String.format("<%s> %X%X:%02X", opcodeToString(mOpcode), mSource, mDestination, mOpcode)); if (mParams.length > 0) { - for (byte data : mParams) { - s.append(String.format(":%02X", data)); + if (filterMessageParameters(mOpcode)) { + s.append(String.format(" <Redacted len=%d>", mParams.length)); + } else { + for (byte data : mParams) { + s.append(String.format(":%02X", data)); + } } } return s.toString(); @@ -270,5 +274,21 @@ public final class HdmiCecMessage { return String.format("Opcode: %02X", opcode); } } + + private static boolean filterMessageParameters(int opcode) { + switch (opcode) { + case Constants.MESSAGE_USER_CONTROL_PRESSED: + case Constants.MESSAGE_USER_CONTROL_RELEASED: + case Constants.MESSAGE_SET_OSD_NAME: + case Constants.MESSAGE_SET_OSD_STRING: + case Constants.MESSAGE_VENDOR_COMMAND: + case Constants.MESSAGE_VENDOR_REMOTE_BUTTON_DOWN: + case Constants.MESSAGE_VENDOR_REMOTE_BUTTON_UP: + case Constants.MESSAGE_VENDOR_COMMAND_WITH_ID: + return true; + default: + return false; + } + } } diff --git a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java index c3413e8d2934..0d899974cf93 100644 --- a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +++ b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java @@ -622,6 +622,16 @@ class MediaRouter2ServiceImpl { return; } + if (route.isSystemRoute() && !routerRecord.mHasModifyAudioRoutingPermission + && !TextUtils.equals(route.getId(), + routerRecord.mUserRecord.mHandler.mSystemProvider.getDefaultRoute().getId())) { + Slog.w(TAG, "MODIFY_AUDIO_ROUTING permission is required to transfer to" + + route); + routerRecord.mUserRecord.mHandler.notifySessionCreationFailedToRouter( + routerRecord, requestId); + return; + } + long uniqueRequestId = toUniqueRequestId(routerRecord.mRouterId, requestId); routerRecord.mUserRecord.mHandler.sendMessage( obtainMessage(UserHandler::requestCreateSessionOnHandler, @@ -915,9 +925,6 @@ class MediaRouter2ServiceImpl { RouterRecord routerRecord = managerRecord.mUserRecord.mHandler .findRouterforSessionLocked(uniqueSessionId); - if (routerRecord == null) { - return; - } long uniqueRequestId = toUniqueRequestId(managerRecord.mManagerId, requestId); managerRecord.mUserRecord.mHandler.sendMessage( @@ -1272,15 +1279,6 @@ class MediaRouter2ServiceImpl { toOriginalRequestId(uniqueRequestId)); return; } - if (route.isSystemRoute() && !routerRecord.mHasModifyAudioRoutingPermission - && !TextUtils.equals(route.getId(), - mSystemProvider.getDefaultRoute().getId())) { - Slog.w(TAG, "MODIFY_AUDIO_ROUTING permission is required to transfer to" - + route); - notifySessionCreationFailedToRouter(routerRecord, - toOriginalRequestId(uniqueRequestId)); - return; - } SessionCreationRequest request = new SessionCreationRequest(routerRecord, uniqueRequestId, route, managerRecord); @@ -1404,11 +1402,11 @@ class MediaRouter2ServiceImpl { } private void releaseSessionOnHandler(long uniqueRequestId, - @NonNull RouterRecord routerRecord, @NonNull String uniqueSessionId) { + @Nullable RouterRecord routerRecord, @NonNull String uniqueSessionId) { final RouterRecord matchingRecord = mSessionToRouterMap.get(uniqueSessionId); if (matchingRecord != routerRecord) { - Slog.w(TAG, "Ignoring releasing session from non-matching router." - + " packageName=" + routerRecord.mPackageName + Slog.w(TAG, "Ignoring releasing session from non-matching router. packageName=" + + (routerRecord == null ? null : routerRecord.mPackageName) + " uniqueSessionId=" + uniqueSessionId); return; } |