Fixed AccessibilityServiceInfo.getId()

It was throwing a NPE when the component was not set.

Test: atest android.accessibilityservice.cts.AccessibilityServiceInfoTest

Bug: 271166949
Bug: 271188189

Change-Id: I1755082ff40a9fe037084100ced9286639ffc101
This commit is contained in:
Felipe Leme
2023-04-05 00:47:09 +00:00
parent da0db6bd38
commit 895c8e56db

View File

@@ -860,10 +860,10 @@ public class AccessibilityServiceInfo implements Parcelable {
* <p>
* <strong>Generated by the system.</strong>
* </p>
* @return The id.
* @return The id (or {@code null} if the component is not set yet).
*/
public String getId() {
return mComponentName.flattenToShortString();
return mComponentName == null ? null : mComponentName.flattenToShortString();
}
/**