Merge "Clear calling identity when executing the callback"

This commit is contained in:
Jiashen Wang
2020-02-10 19:17:47 +00:00
committed by Gerrit Code Review

View File

@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.content.Context; import android.content.Context;
import android.os.Binder;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.service.euicc.EuiccProfileInfo; import android.service.euicc.EuiccProfileInfo;
@@ -165,7 +166,12 @@ public class EuiccCardManager {
new IGetAllProfilesCallback.Stub() { new IGetAllProfilesCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, EuiccProfileInfo[] profiles) { public void onComplete(int resultCode, EuiccProfileInfo[] profiles) {
executor.execute(() -> callback.onComplete(resultCode, profiles)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, profiles));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -189,7 +195,12 @@ public class EuiccCardManager {
new IGetProfileCallback.Stub() { new IGetProfileCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, EuiccProfileInfo profile) { public void onComplete(int resultCode, EuiccProfileInfo profile) {
executor.execute(() -> callback.onComplete(resultCode, profile)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, profile));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -214,7 +225,12 @@ public class EuiccCardManager {
refresh, new IDisableProfileCallback.Stub() { refresh, new IDisableProfileCallback.Stub() {
@Override @Override
public void onComplete(int resultCode) { public void onComplete(int resultCode) {
executor.execute(() -> callback.onComplete(resultCode, null)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, null));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -240,7 +256,12 @@ public class EuiccCardManager {
refresh, new ISwitchToProfileCallback.Stub() { refresh, new ISwitchToProfileCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, EuiccProfileInfo profile) { public void onComplete(int resultCode, EuiccProfileInfo profile) {
executor.execute(() -> callback.onComplete(resultCode, profile)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, profile));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -265,7 +286,12 @@ public class EuiccCardManager {
nickname, new ISetNicknameCallback.Stub() { nickname, new ISetNicknameCallback.Stub() {
@Override @Override
public void onComplete(int resultCode) { public void onComplete(int resultCode) {
executor.execute(() -> callback.onComplete(resultCode, null)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, null));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -289,7 +315,12 @@ public class EuiccCardManager {
new IDeleteProfileCallback.Stub() { new IDeleteProfileCallback.Stub() {
@Override @Override
public void onComplete(int resultCode) { public void onComplete(int resultCode) {
executor.execute(() -> callback.onComplete(resultCode, null)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, null));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -314,7 +345,12 @@ public class EuiccCardManager {
new IResetMemoryCallback.Stub() { new IResetMemoryCallback.Stub() {
@Override @Override
public void onComplete(int resultCode) { public void onComplete(int resultCode) {
executor.execute(() -> callback.onComplete(resultCode, null)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, null));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -337,7 +373,12 @@ public class EuiccCardManager {
new IGetDefaultSmdpAddressCallback.Stub() { new IGetDefaultSmdpAddressCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, String address) { public void onComplete(int resultCode, String address) {
executor.execute(() -> callback.onComplete(resultCode, address)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, address));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -360,7 +401,12 @@ public class EuiccCardManager {
new IGetSmdsAddressCallback.Stub() { new IGetSmdsAddressCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, String address) { public void onComplete(int resultCode, String address) {
executor.execute(() -> callback.onComplete(resultCode, address)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, address));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -385,7 +431,12 @@ public class EuiccCardManager {
new ISetDefaultSmdpAddressCallback.Stub() { new ISetDefaultSmdpAddressCallback.Stub() {
@Override @Override
public void onComplete(int resultCode) { public void onComplete(int resultCode) {
executor.execute(() -> callback.onComplete(resultCode, null)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, null));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -408,7 +459,12 @@ public class EuiccCardManager {
new IGetRulesAuthTableCallback.Stub() { new IGetRulesAuthTableCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, EuiccRulesAuthTable rat) { public void onComplete(int resultCode, EuiccRulesAuthTable rat) {
executor.execute(() -> callback.onComplete(resultCode, rat)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, rat));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -431,7 +487,12 @@ public class EuiccCardManager {
new IGetEuiccChallengeCallback.Stub() { new IGetEuiccChallengeCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, byte[] challenge) { public void onComplete(int resultCode, byte[] challenge) {
executor.execute(() -> callback.onComplete(resultCode, challenge)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, challenge));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -454,7 +515,12 @@ public class EuiccCardManager {
new IGetEuiccInfo1Callback.Stub() { new IGetEuiccInfo1Callback.Stub() {
@Override @Override
public void onComplete(int resultCode, byte[] info) { public void onComplete(int resultCode, byte[] info) {
executor.execute(() -> callback.onComplete(resultCode, info)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, info));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -477,7 +543,12 @@ public class EuiccCardManager {
new IGetEuiccInfo2Callback.Stub() { new IGetEuiccInfo2Callback.Stub() {
@Override @Override
public void onComplete(int resultCode, byte[] info) { public void onComplete(int resultCode, byte[] info) {
executor.execute(() -> callback.onComplete(resultCode, info)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, info));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -519,7 +590,12 @@ public class EuiccCardManager {
new IAuthenticateServerCallback.Stub() { new IAuthenticateServerCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, byte[] response) { public void onComplete(int resultCode, byte[] response) {
executor.execute(() -> callback.onComplete(resultCode, response)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, response));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -558,7 +634,12 @@ public class EuiccCardManager {
new IPrepareDownloadCallback.Stub() { new IPrepareDownloadCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, byte[] response) { public void onComplete(int resultCode, byte[] response) {
executor.execute(() -> callback.onComplete(resultCode, response)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, response));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -586,7 +667,12 @@ public class EuiccCardManager {
new ILoadBoundProfilePackageCallback.Stub() { new ILoadBoundProfilePackageCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, byte[] response) { public void onComplete(int resultCode, byte[] response) {
executor.execute(() -> callback.onComplete(resultCode, response)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, response));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -616,7 +702,12 @@ public class EuiccCardManager {
new ICancelSessionCallback.Stub() { new ICancelSessionCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, byte[] response) { public void onComplete(int resultCode, byte[] response) {
executor.execute(() -> callback.onComplete(resultCode, response)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, response));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -640,7 +731,13 @@ public class EuiccCardManager {
new IListNotificationsCallback.Stub() { new IListNotificationsCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, EuiccNotification[] notifications) { public void onComplete(int resultCode, EuiccNotification[] notifications) {
executor.execute(() -> callback.onComplete(resultCode, notifications)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(
resultCode, notifications));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -664,7 +761,13 @@ public class EuiccCardManager {
events, new IRetrieveNotificationListCallback.Stub() { events, new IRetrieveNotificationListCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, EuiccNotification[] notifications) { public void onComplete(int resultCode, EuiccNotification[] notifications) {
executor.execute(() -> callback.onComplete(resultCode, notifications)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(
resultCode, notifications));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -688,7 +791,13 @@ public class EuiccCardManager {
seqNumber, new IRetrieveNotificationCallback.Stub() { seqNumber, new IRetrieveNotificationCallback.Stub() {
@Override @Override
public void onComplete(int resultCode, EuiccNotification notification) { public void onComplete(int resultCode, EuiccNotification notification) {
executor.execute(() -> callback.onComplete(resultCode, notification)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(
resultCode, notification));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -715,7 +824,12 @@ public class EuiccCardManager {
new IRemoveNotificationFromListCallback.Stub() { new IRemoveNotificationFromListCallback.Stub() {
@Override @Override
public void onComplete(int resultCode) { public void onComplete(int resultCode) {
executor.execute(() -> callback.onComplete(resultCode, null)); final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> callback.onComplete(resultCode, null));
} finally {
Binder.restoreCallingIdentity(token);
}
} }
}); });
} catch (RemoteException e) { } catch (RemoteException e) {