Clear binder identity in callback of IMS IPC interfaces

The binder identity does get cleared when goes from client process
into phone process. When it comes back from phone to client, the
binder identity should also be cleared.

Bug: 193923945
Test: atest android.telephony.cts.TelephonyManagerTest
Test: atest ImsServiceTest RcsFeatureControllerTest ImsMmTelManagerTest
Change-Id: I34225e32111879e155c9f7865f0045430d171467
This commit is contained in:
Rambo Wang
2021-07-19 12:27:38 -07:00
parent 0df5bbfe90
commit c18002c465
3 changed files with 42 additions and 7 deletions

View File

@@ -13425,7 +13425,12 @@ public class TelephonyManager {
IBooleanConsumer aidlConsumer = callback == null ? null : new IBooleanConsumer.Stub() {
@Override
public void accept(boolean result) {
executor.execute(() -> callback.accept(result));
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.accept(result));
} finally {
Binder.restoreCallingIdentity(identity);
}
}
};

View File

@@ -444,7 +444,12 @@ public class ImsMmTelManager implements RegistrationManager {
iTelephony.getImsMmTelRegistrationState(mSubId, new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> stateCallback.accept(result));
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> stateCallback.accept(result));
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
} catch (RemoteException e) {
@@ -485,7 +490,12 @@ public class ImsMmTelManager implements RegistrationManager {
new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> transportTypeCallback.accept(result));
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> transportTypeCallback.accept(result));
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
} catch (RemoteException e) {
@@ -802,7 +812,12 @@ public class ImsMmTelManager implements RegistrationManager {
iTelephony.isMmTelCapabilitySupported(mSubId, new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> callback.accept(result == 1));
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.accept(result == 1));
} finally {
Binder.restoreCallingIdentity(identity);
}
}
}, capability, transportType);
} catch (ServiceSpecificException sse) {
@@ -1348,7 +1363,12 @@ public class ImsMmTelManager implements RegistrationManager {
iTelephony.getImsMmTelFeatureState(mSubId, new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> callback.accept(result));
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.accept(result));
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
} catch (ServiceSpecificException sse) {

View File

@@ -299,7 +299,12 @@ public class ImsRcsManager {
imsRcsController.getImsRcsRegistrationState(mSubId, new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> stateCallback.accept(result));
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> stateCallback.accept(result));
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
} catch (RemoteException e) {
@@ -343,7 +348,12 @@ public class ImsRcsManager {
new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> transportTypeCallback.accept(result));
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> transportTypeCallback.accept(result));
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
} catch (RemoteException e) {