Fix a bug where updates of offers won't find existing offers

.equals() only work on cross-process Binder instances if casted to
a Binder instance first.

Bug: 184281544
Test: ConnectivityServiceTest. CTS test for this specific issue to come
Change-Id: I7b9e0df21a3cca59659867a75792289ddee2f1d7
This commit is contained in:
Chalard Jean
2021-04-08 17:37:36 +09:00
parent e0869fbce4
commit f136443be0
2 changed files with 2 additions and 2 deletions

View File

@@ -6601,7 +6601,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
@NonNull final INetworkOfferCallback callback) {
ensureRunningOnConnectivityServiceThread();
for (final NetworkOfferInfo noi : mNetworkOffers) {
if (noi.offer.callback.equals(callback)) return noi;
if (noi.offer.callback.asBinder().equals(callback.asBinder())) return noi;
}
return null;
}

View File

@@ -133,7 +133,7 @@ public class NetworkOffer implements NetworkRanker.Scoreable {
* @param previousOffer the previous offer
*/
public void migrateFrom(@NonNull final NetworkOffer previousOffer) {
if (!callback.equals(previousOffer.callback)) {
if (!callback.asBinder().equals(previousOffer.callback.asBinder())) {
throw new IllegalArgumentException("Can only migrate from a previous version of"
+ " the same offer");
}