From e45ccc9216d4bfc94f35a163fbfc29bddbaac95e Mon Sep 17 00:00:00 2001 From: Marco Loaiza Date: Thu, 12 Jan 2023 11:09:47 +0000 Subject: [PATCH] Only notify listeners if device Id changed Bug: 265262866 Test: atest DeviceAssociationTest Change-Id: I9bc58ca3c36f1b3f82b63a1d88ea1b50a35da0e1 --- core/java/android/app/ContextImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 240dbe1eea248..8803cf263e380 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -3053,8 +3053,11 @@ class ContextImpl extends Context { throw new UnsupportedOperationException( "Cannot update device ID on a Context created with createDeviceContext()"); } - mDeviceId = updatedDeviceId; - notifyOnDeviceChangedListeners(updatedDeviceId); + + if (mDeviceId != updatedDeviceId) { + mDeviceId = updatedDeviceId; + notifyOnDeviceChangedListeners(updatedDeviceId); + } } @Override