diff options
11 files changed, 147 insertions, 22 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index b06374615730..815ccfe0b1c6 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -52022,6 +52022,7 @@ package android.view.accessibility { field public static final int CONTENT_CHANGE_TYPE_DRAG_CANCELLED = 512; // 0x200 field public static final int CONTENT_CHANGE_TYPE_DRAG_DROPPED = 256; // 0x100 field public static final int CONTENT_CHANGE_TYPE_DRAG_STARTED = 128; // 0x80 + field public static final int CONTENT_CHANGE_TYPE_ENABLED = 4096; // 0x1000 field public static final int CONTENT_CHANGE_TYPE_ERROR = 2048; // 0x800 field public static final int CONTENT_CHANGE_TYPE_PANE_APPEARED = 16; // 0x10 field public static final int CONTENT_CHANGE_TYPE_PANE_DISAPPEARED = 32; // 0x20 diff --git a/core/java/android/app/smartspace/SmartspaceTarget.java b/core/java/android/app/smartspace/SmartspaceTarget.java index 79d7b216628f..3c66a15399d3 100644 --- a/core/java/android/app/smartspace/SmartspaceTarget.java +++ b/core/java/android/app/smartspace/SmartspaceTarget.java @@ -245,6 +245,10 @@ public final class SmartspaceTarget implements Parcelable { public static final int UI_TEMPLATE_COMBINED_CARDS = 6; // Sub-card template whose data is represented by {@link SubCardTemplateData} public static final int UI_TEMPLATE_SUB_CARD = 7; + // Reserved: 8 + // Template type used by non-UI template features for sending logging information in the + // base template data. This should not be used for UI template features. + // public static final int UI_TEMPLATE_LOGGING_ONLY = 8; /** * The types of the Smartspace ui templates. diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index bc665cf09652..5c899e489347 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -12538,6 +12538,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!enabled) { cancelPendingInputEvents(); } + notifyViewAccessibilityStateChangedIfNeeded( + AccessibilityEvent.CONTENT_CHANGE_TYPE_ENABLED); } /** diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java index f86f51fc0022..b0cf504ec568 100644 --- a/core/java/android/view/accessibility/AccessibilityEvent.java +++ b/core/java/android/view/accessibility/AccessibilityEvent.java @@ -709,6 +709,18 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par */ public static final int CONTENT_CHANGE_TYPE_ERROR = 0x0000800; + /** + * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: + * The source node changed its ability to interact returned by + * {@link AccessibilityNodeInfo#isEnabled}. + * The view changing content's ability to interact should call + * {@link AccessibilityNodeInfo#setEnabled} and then send this event. + * + * @see AccessibilityNodeInfo#isEnabled + * @see AccessibilityNodeInfo#setEnabled + */ + public static final int CONTENT_CHANGE_TYPE_ENABLED = 1 << 12; + /** Change type for {@link #TYPE_SPEECH_STATE_CHANGE} event: another service is speaking. */ public static final int SPEECH_STATE_SPEAKING_START = 0x00000001; @@ -836,6 +848,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par CONTENT_CHANGE_TYPE_DRAG_CANCELLED, CONTENT_CHANGE_TYPE_CONTENT_INVALID, CONTENT_CHANGE_TYPE_ERROR, + CONTENT_CHANGE_TYPE_ENABLED, }) public @interface ContentChangeTypes {} @@ -1105,6 +1118,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par case CONTENT_CHANGE_TYPE_CONTENT_INVALID: return "CONTENT_CHANGE_TYPE_CONTENT_INVALID"; case CONTENT_CHANGE_TYPE_ERROR: return "CONTENT_CHANGE_TYPE_ERROR"; + case CONTENT_CHANGE_TYPE_ENABLED: return "CONTENT_CHANGE_TYPE_ENABLED"; default: return Integer.toHexString(type); } } diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 307c55cfc2e7..d0405f0e5991 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -267,6 +267,12 @@ import java.util.function.Consumer; * they can switch to it, to confirm with the system that they know about it * and want to make it available for use.</p> * </ul> + * + * <p>If your app targets Android 11 (API level 30) or higher, the methods in + * this class each return a filtered result by the rules of + * <a href="/training/basics/intents/package-visibility">package visibility</a>, + * except for the currently connected IME. Apps having a query for the + * {@link InputMethod#SERVICE_INTERFACE} see all IMEs.</p> */ @SystemService(Context.INPUT_METHOD_SERVICE) @RequiresFeature(PackageManager.FEATURE_INPUT_METHODS) diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.java b/packages/SystemUI/src/com/android/systemui/flags/Flags.java index 2634b03e02dd..fcf11ef350fd 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.java +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.java @@ -218,7 +218,7 @@ public class Flags { /***************************************/ // 900 - media - public static final UnreleasedFlag MEDIA_TAP_TO_TRANSFER = new UnreleasedFlag(900); + public static final ReleasedFlag MEDIA_TAP_TO_TRANSFER = new ReleasedFlag(900); public static final UnreleasedFlag MEDIA_SESSION_ACTIONS = new UnreleasedFlag(901); public static final ReleasedFlag MEDIA_NEARBY_DEVICES = new ReleasedFlag(903); public static final ReleasedFlag MEDIA_MUTE_AWAIT = new ReleasedFlag(904); diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt index 2cd564ff4e32..9dd18b21cc71 100644 --- a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt +++ b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt @@ -886,7 +886,8 @@ class MediaCarouselController @Inject constructor( interactedSubcardRank, interactedSubcardCardinality, receivedLatencyMillis, - null // Media cards cannot have subcards. + null, // Media cards cannot have subcards. + null // Media cards don't have dimensions today. ) /* ktlint-disable max-line-length */ if (DEBUG) { diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 00974e44e8bd..2be84d059286 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -2036,9 +2036,11 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub if (resolvedUserIds.length != 1) { return Collections.emptyList(); } + final int callingUid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { - return getInputMethodListLocked(resolvedUserIds[0], directBootAwareness); + return getInputMethodListLocked( + resolvedUserIds[0], directBootAwareness, callingUid); } finally { Binder.restoreCallingIdentity(ident); } @@ -2057,9 +2059,10 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub if (resolvedUserIds.length != 1) { return Collections.emptyList(); } + final int callingUid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { - return getEnabledInputMethodListLocked(resolvedUserIds[0]); + return getEnabledInputMethodListLocked(resolvedUserIds[0], callingUid); } finally { Binder.restoreCallingIdentity(ident); } @@ -2090,12 +2093,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @GuardedBy("ImfLock.class") private List<InputMethodInfo> getInputMethodListLocked(@UserIdInt int userId, - @DirectBootAwareness int directBootAwareness) { + @DirectBootAwareness int directBootAwareness, int callingUid) { final ArrayList<InputMethodInfo> methodList; + final InputMethodSettings settings; if (userId == mSettings.getCurrentUserId() && directBootAwareness == DirectBootAwareness.AUTO) { // Create a copy. methodList = new ArrayList<>(mMethodList); + settings = mSettings; } else { final ArrayMap<String, InputMethodInfo> methodMap = new ArrayMap<>(); methodList = new ArrayList<>(); @@ -2104,19 +2109,31 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub AdditionalSubtypeUtils.load(additionalSubtypeMap, userId); queryInputMethodServicesInternal(mContext, userId, additionalSubtypeMap, methodMap, methodList, directBootAwareness); + settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); } + // filter caller's access to input methods + methodList.removeIf(imi -> + !canCallerAccessInputMethod(imi.getPackageName(), callingUid, userId, settings)); return methodList; } @GuardedBy("ImfLock.class") - private List<InputMethodInfo> getEnabledInputMethodListLocked(@UserIdInt int userId) { + private List<InputMethodInfo> getEnabledInputMethodListLocked(@UserIdInt int userId, + int callingUid) { + final ArrayList<InputMethodInfo> methodList; + final InputMethodSettings settings; if (userId == mSettings.getCurrentUserId()) { - return mSettings.getEnabledInputMethodListLocked(); + methodList = mSettings.getEnabledInputMethodListLocked(); + settings = mSettings; + } else { + final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); + settings = new InputMethodSettings(mContext, methodMap, userId, true /* copyOnWrite */); + methodList = settings.getEnabledInputMethodListLocked(); } - final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); - final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, - true); - return settings.getEnabledInputMethodListLocked(); + // filter caller's access to input methods + methodList.removeIf(imi -> + !canCallerAccessInputMethod(imi.getPackageName(), callingUid, userId, settings)); + return methodList; } @GuardedBy("ImfLock.class") @@ -2155,10 +2172,11 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } synchronized (ImfLock.class) { + final int callingUid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { return getEnabledInputMethodSubtypeListLocked(imiId, - allowsImplicitlyEnabledSubtypes, userId); + allowsImplicitlyEnabledSubtypes, userId, callingUid); } finally { Binder.restoreCallingIdentity(ident); } @@ -2167,7 +2185,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @GuardedBy("ImfLock.class") private List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked(String imiId, - boolean allowsImplicitlyEnabledSubtypes, @UserIdInt int userId) { + boolean allowsImplicitlyEnabledSubtypes, @UserIdInt int userId, int callingUid) { if (userId == mSettings.getCurrentUserId()) { final InputMethodInfo imi; String selectedMethodId = getSelectedMethodIdLocked(); @@ -2176,7 +2194,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } else { imi = mMethodMap.get(imiId); } - if (imi == null) { + if (imi == null || !canCallerAccessInputMethod( + imi.getPackageName(), callingUid, userId, mSettings)) { return Collections.emptyList(); } return mSettings.getEnabledInputMethodSubtypeListLocked( @@ -2189,6 +2208,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } final InputMethodSettings settings = new InputMethodSettings(mContext, methodMap, userId, true); + if (!canCallerAccessInputMethod(imi.getPackageName(), callingUid, userId, settings)) { + return Collections.emptyList(); + } return settings.getEnabledInputMethodSubtypeListLocked( imi, allowsImplicitlyEnabledSubtypes); } @@ -5438,6 +5460,34 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub return true; } + /** + * Filter the access to the input method by rules of the package visibility. Return {@code true} + * if the given input method is the currently selected one or visible to the caller. + * + * @param targetPkgName The package name of input method to check. + * @param callingUid The caller that is going to access the input method. + * @param userId The user ID where the input method resides. + * @param settings The input method settings under the given user ID. + * @return {@code true} if caller is able to access the input method. + */ + private boolean canCallerAccessInputMethod(@NonNull String targetPkgName, int callingUid, + @UserIdInt int userId, @NonNull InputMethodSettings settings) { + final String methodId = settings.getSelectedInputMethod(); + final ComponentName selectedInputMethod = methodId != null + ? InputMethodUtils.convertIdToComponentName(methodId) : null; + if (selectedInputMethod != null + && selectedInputMethod.getPackageName().equals(targetPkgName)) { + return true; + } + final boolean canAccess = !mPackageManagerInternal.filterAppAccess( + targetPkgName, callingUid, userId); + if (DEBUG && !canAccess) { + Slog.d(TAG, "Input method " + targetPkgName + + " is not visible to the caller " + callingUid); + } + return canAccess; + } + private void publishLocalService() { LocalServices.addService(InputMethodManagerInternal.class, new LocalServiceImpl()); } @@ -5459,14 +5509,15 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @Override public List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId) { synchronized (ImfLock.class) { - return getInputMethodListLocked(userId, DirectBootAwareness.AUTO); + return getInputMethodListLocked(userId, DirectBootAwareness.AUTO, + Process.SYSTEM_UID); } } @Override public List<InputMethodInfo> getEnabledInputMethodListAsUser(@UserIdInt int userId) { synchronized (ImfLock.class) { - return getEnabledInputMethodListLocked(userId); + return getEnabledInputMethodListLocked(userId, Process.SYSTEM_UID); } } @@ -6096,8 +6147,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub try (PrintWriter pr = shellCommand.getOutPrintWriter()) { for (int userId : userIds) { final List<InputMethodInfo> methods = all - ? getInputMethodListLocked(userId, DirectBootAwareness.AUTO) - : getEnabledInputMethodListLocked(userId); + ? getInputMethodListLocked( + userId, DirectBootAwareness.AUTO, Process.SHELL_UID) + : getEnabledInputMethodListLocked(userId, Process.SHELL_UID); if (userIds.length > 1) { pr.print("User #"); pr.print(userId); diff --git a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java index d12f1131acbe..c7ff8caf176b 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java @@ -20,11 +20,13 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserHandleAware; import android.annotation.UserIdInt; +import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; +import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.os.Build; import android.os.UserHandle; @@ -998,4 +1000,16 @@ final class InputMethodUtils { } return new int[]{sourceUserId}; } + + /** + * Convert the input method ID to a component name + * + * @param id A unique ID for this input method. + * @return The component name of the input method. + * @see InputMethodInfo#computeId(ResolveInfo) + */ + @Nullable + public static ComponentName convertIdToComponentName(@NonNull String id) { + return ComponentName.unflattenFromString(id); + } } diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index a3c578025b10..ae998067fa03 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -4194,6 +4194,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mCameraGestureTriggered = true; if (mRequestedOrSleepingDefaultDisplay) { mCameraGestureTriggeredDuringGoingToSleep = true; + // Wake device up early to prevent display doing redundant turning off/on stuff. + wakeUpFromPowerKey(event.getDownTime()); } return true; } diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 2a1efed63dd2..0622612bb064 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -3348,27 +3348,42 @@ public class CarrierConfigManager { public static final String KEY_CARRIER_QUALIFIED_NETWORKS_SERVICE_CLASS_OVERRIDE_STRING = "carrier_qualified_networks_service_class_override_string"; /** - * A list of 4 LTE RSCP thresholds above which a signal level is considered POOR, + * A list of 4 WCDMA RSCP thresholds above which a signal level is considered POOR, * MODERATE, GOOD, or EXCELLENT, to be used in SignalStrength reporting. * * Note that the min and max thresholds are fixed at -120 and -24, as set in 3GPP TS 27.007 * section 8.69. * <p> - * See SignalStrength#MAX_WCDMA_RSCP and SignalStrength#MIN_WDCMA_RSCP. Any signal level outside - * these boundaries is considered invalid. + * See CellSignalStrengthWcdma#WCDMA_RSCP_MAX and CellSignalStrengthWcdma#WCDMA_RSCP_MIN. + * Any signal level outside these boundaries is considered invalid. * @hide */ public static final String KEY_WCDMA_RSCP_THRESHOLDS_INT_ARRAY = "wcdma_rscp_thresholds_int_array"; /** + * A list of 4 WCDMA ECNO thresholds above which a signal level is considered POOR, + * MODERATE, GOOD, or EXCELLENT, to be used in SignalStrength reporting. + * + * Note that the min and max thresholds are fixed at -24 and 1, as set in 3GPP TS 25.215 + * section 5.1.5. + * Any signal level outside these boundaries is considered invalid. + * <p> + * + * The default value is {@code {-24, -14, -6, 1}}. + * @hide + */ + public static final String KEY_WCDMA_ECNO_THRESHOLDS_INT_ARRAY = + "wcdma_ecno_thresholds_int_array"; + + /** * The default measurement to use for signal strength reporting. If this is not specified, the * RSSI is used. * <p> * e.g.) To use RSCP by default, set the value to "rscp". The signal strength level will * then be determined by #KEY_WCDMA_RSCP_THRESHOLDS_INT_ARRAY * <p> - * Currently this supports the value "rscp" and "rssi". + * Currently this supports the value "rscp","rssi" and "ecno". * @hide */ // FIXME: this key and related keys must not be exposed without a consistent philosophy for @@ -9142,6 +9157,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_CHECK_PRICING_WITH_CARRIER_FOR_DATA_ROAMING_BOOL, false); sDefaults.putBoolean(KEY_SHOW_DATA_CONNECTED_ROAMING_NOTIFICATION_BOOL, false); sDefaults.putIntArray(KEY_LTE_RSRP_THRESHOLDS_INT_ARRAY, + // Boundaries: [-140 dBm, -44 dBm] new int[] { -128, /* SIGNAL_STRENGTH_POOR */ -118, /* SIGNAL_STRENGTH_MODERATE */ @@ -9149,6 +9165,7 @@ public class CarrierConfigManager { -98, /* SIGNAL_STRENGTH_GREAT */ }); sDefaults.putIntArray(KEY_LTE_RSRQ_THRESHOLDS_INT_ARRAY, + // Boundaries: [-34 dB, 3 dB] new int[] { -20, /* SIGNAL_STRENGTH_POOR */ -17, /* SIGNAL_STRENGTH_MODERATE */ @@ -9156,6 +9173,7 @@ public class CarrierConfigManager { -11 /* SIGNAL_STRENGTH_GREAT */ }); sDefaults.putIntArray(KEY_LTE_RSSNR_THRESHOLDS_INT_ARRAY, + // Boundaries: [-20 dBm, 30 dBm] new int[] { -3, /* SIGNAL_STRENGTH_POOR */ 1, /* SIGNAL_STRENGTH_MODERATE */ @@ -9163,12 +9181,23 @@ public class CarrierConfigManager { 13 /* SIGNAL_STRENGTH_GREAT */ }); sDefaults.putIntArray(KEY_WCDMA_RSCP_THRESHOLDS_INT_ARRAY, + // Boundaries: [-120 dBm, -25 dBm] new int[] { -115, /* SIGNAL_STRENGTH_POOR */ -105, /* SIGNAL_STRENGTH_MODERATE */ -95, /* SIGNAL_STRENGTH_GOOD */ -85 /* SIGNAL_STRENGTH_GREAT */ }); + // TODO(b/249896055): On enabling ECNO measurement part for Signal Bar level indication + // system functionality,below values to be rechecked. + sDefaults.putIntArray(KEY_WCDMA_ECNO_THRESHOLDS_INT_ARRAY, + // Boundaries: [-24 dBm, 1 dBm] + new int[] { + -24, /* SIGNAL_STRENGTH_POOR */ + -14, /* SIGNAL_STRENGTH_MODERATE */ + -6, /* SIGNAL_STRENGTH_GOOD */ + 1 /* SIGNAL_STRENGTH_GREAT */ + }); sDefaults.putIntArray(KEY_5G_NR_SSRSRP_THRESHOLDS_INT_ARRAY, // Boundaries: [-140 dB, -44 dB] new int[] { |