Merge "Tighten up Binder.clearCallingIdentity() usage."

This commit is contained in:
Treehugger Robot
2020-11-25 09:14:23 +00:00
committed by Gerrit Code Review

View File

@@ -974,7 +974,7 @@ public class Vpn {
/** Prepare the VPN for the given package. Does not perform permission checks. */ /** Prepare the VPN for the given package. Does not perform permission checks. */
@GuardedBy("this") @GuardedBy("this")
private void prepareInternal(String newPackage) { private void prepareInternal(String newPackage) {
long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try { try {
// Reset the interface. // Reset the interface.
if (mInterface != null) { if (mInterface != null) {
@@ -1262,7 +1262,7 @@ public class Vpn {
mNetworkCapabilities.setAdministratorUids(new int[] {mOwnerUID}); mNetworkCapabilities.setAdministratorUids(new int[] {mOwnerUID});
mNetworkCapabilities.setUids(createUserAndRestrictedProfilesRanges(mUserId, mNetworkCapabilities.setUids(createUserAndRestrictedProfilesRanges(mUserId,
mConfig.allowedApplications, mConfig.disallowedApplications)); mConfig.allowedApplications, mConfig.disallowedApplications));
long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try { try {
mNetworkAgent = new NetworkAgent(mLooper, mContext, NETWORKTYPE /* logtag */, mNetworkAgent = new NetworkAgent(mLooper, mContext, NETWORKTYPE /* logtag */,
mNetworkInfo, mNetworkCapabilities, lp, mNetworkInfo, mNetworkCapabilities, lp,
@@ -1281,7 +1281,7 @@ public class Vpn {
} }
private boolean canHaveRestrictedProfile(int userId) { private boolean canHaveRestrictedProfile(int userId) {
long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try { try {
return UserManager.get(mContext).canHaveRestrictedProfile(userId); return UserManager.get(mContext).canHaveRestrictedProfile(userId);
} finally { } finally {
@@ -1328,7 +1328,7 @@ public class Vpn {
// Check if the service is properly declared. // Check if the service is properly declared.
Intent intent = new Intent(VpnConfig.SERVICE_INTERFACE); Intent intent = new Intent(VpnConfig.SERVICE_INTERFACE);
intent.setClassName(mPackage, config.user); intent.setClassName(mPackage, config.user);
long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try { try {
// Restricted users are not allowed to create VPNs, they are tied to Owner // Restricted users are not allowed to create VPNs, they are tied to Owner
enforceNotRestrictedUser(); enforceNotRestrictedUser();
@@ -2063,7 +2063,7 @@ public class Vpn {
*/ */
public void startLegacyVpn(VpnProfile profile, KeyStore keyStore, LinkProperties egress) { public void startLegacyVpn(VpnProfile profile, KeyStore keyStore, LinkProperties egress) {
enforceControlPermission(); enforceControlPermission();
long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try { try {
startLegacyVpnPrivileged(profile, keyStore, egress); startLegacyVpnPrivileged(profile, keyStore, egress);
} finally { } finally {