Fix style errors for IpSec associated files

Bug: 204153604
Test: build pass.
Change-Id: I940de8bef7f693dcce8808148a975bea1f36712c
This commit is contained in:
Aaron Huang
2021-12-06 15:18:42 +08:00
parent 8f4e23616c
commit b24f3da2b9
6 changed files with 31 additions and 26 deletions

View File

@@ -297,7 +297,7 @@ public final class IpSecAlgorithm implements Parcelable {
return mTruncLenBits; return mTruncLenBits;
} }
/* Parcelable Implementation */ /** Parcelable Implementation */
public int describeContents() { public int describeContents() {
return 0; return 0;
} }

View File

@@ -99,9 +99,9 @@ public final class IpSecManager {
/** @hide */ /** @hide */
public interface Status { public interface Status {
public static final int OK = 0; int OK = 0;
public static final int RESOURCE_UNAVAILABLE = 1; int RESOURCE_UNAVAILABLE = 1;
public static final int SPI_UNAVAILABLE = 2; int SPI_UNAVAILABLE = 2;
} }
/** @hide */ /** @hide */
@@ -276,7 +276,7 @@ public final class IpSecManager {
* @param destinationAddress the destination address for traffic bearing the requested SPI. * @param destinationAddress the destination address for traffic bearing the requested SPI.
* For inbound traffic, the destination should be an address currently assigned on-device. * For inbound traffic, the destination should be an address currently assigned on-device.
* @return the reserved SecurityParameterIndex * @return the reserved SecurityParameterIndex
* @throws {@link #ResourceUnavailableException} indicating that too many SPIs are * @throws ResourceUnavailableException indicating that too many SPIs are
* currently allocated for this user * currently allocated for this user
*/ */
@NonNull @NonNull
@@ -307,9 +307,9 @@ public final class IpSecManager {
* @param requestedSpi the requested SPI. The range 1-255 is reserved and may not be used. See * @param requestedSpi the requested SPI. The range 1-255 is reserved and may not be used. See
* RFC 4303 Section 2.1. * RFC 4303 Section 2.1.
* @return the reserved SecurityParameterIndex * @return the reserved SecurityParameterIndex
* @throws {@link #ResourceUnavailableException} indicating that too many SPIs are * @throws ResourceUnavailableException indicating that too many SPIs are
* currently allocated for this user * currently allocated for this user
* @throws {@link #SpiUnavailableException} indicating that the requested SPI could not be * @throws SpiUnavailableException indicating that the requested SPI could not be
* reserved * reserved
*/ */
@NonNull @NonNull

View File

@@ -60,7 +60,8 @@ public final class IpSecTransformResponse implements Parcelable {
resourceId = in.readInt(); resourceId = in.readInt();
} }
public static final @android.annotation.NonNull Parcelable.Creator<IpSecTransformResponse> CREATOR = @android.annotation.NonNull
public static final Parcelable.Creator<IpSecTransformResponse> CREATOR =
new Parcelable.Creator<IpSecTransformResponse>() { new Parcelable.Creator<IpSecTransformResponse>() {
public IpSecTransformResponse createFromParcel(Parcel in) { public IpSecTransformResponse createFromParcel(Parcel in) {
return new IpSecTransformResponse(in); return new IpSecTransformResponse(in);

View File

@@ -65,7 +65,8 @@ public final class IpSecTunnelInterfaceResponse implements Parcelable {
interfaceName = in.readString(); interfaceName = in.readString();
} }
public static final @android.annotation.NonNull Parcelable.Creator<IpSecTunnelInterfaceResponse> CREATOR = @android.annotation.NonNull
public static final Parcelable.Creator<IpSecTunnelInterfaceResponse> CREATOR =
new Parcelable.Creator<IpSecTunnelInterfaceResponse>() { new Parcelable.Creator<IpSecTunnelInterfaceResponse>() {
public IpSecTunnelInterfaceResponse createFromParcel(Parcel in) { public IpSecTunnelInterfaceResponse createFromParcel(Parcel in) {
return new IpSecTunnelInterfaceResponse(in); return new IpSecTunnelInterfaceResponse(in);

View File

@@ -18,6 +18,7 @@ package android.net;
import android.os.Parcel; import android.os.Parcel;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.os.Parcelable; import android.os.Parcelable;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.IOException; import java.io.IOException;
@@ -83,7 +84,8 @@ public final class IpSecUdpEncapResponse implements Parcelable {
fileDescriptor = in.readParcelable(ParcelFileDescriptor.class.getClassLoader()); fileDescriptor = in.readParcelable(ParcelFileDescriptor.class.getClassLoader());
} }
public static final @android.annotation.NonNull Parcelable.Creator<IpSecUdpEncapResponse> CREATOR = @android.annotation.NonNull
public static final Parcelable.Creator<IpSecUdpEncapResponse> CREATOR =
new Parcelable.Creator<IpSecUdpEncapResponse>() { new Parcelable.Creator<IpSecUdpEncapResponse>() {
public IpSecUdpEncapResponse createFromParcel(Parcel in) { public IpSecUdpEncapResponse createFromParcel(Parcel in) {
return new IpSecUdpEncapResponse(in); return new IpSecUdpEncapResponse(in);

View File

@@ -132,7 +132,7 @@ public class IpSecService extends IIpSecService.Stub {
interface IpSecServiceConfiguration { interface IpSecServiceConfiguration {
INetd getNetdInstance() throws RemoteException; INetd getNetdInstance() throws RemoteException;
static IpSecServiceConfiguration GETSRVINSTANCE = IpSecServiceConfiguration GETSRVINSTANCE =
new IpSecServiceConfiguration() { new IpSecServiceConfiguration() {
@Override @Override
public INetd getNetdInstance() throws RemoteException { public INetd getNetdInstance() throws RemoteException {
@@ -491,8 +491,8 @@ public class IpSecService extends IIpSecService.Stub {
* <p>This class associates kernel resources with the UID that owns and controls them. * <p>This class associates kernel resources with the UID that owns and controls them.
*/ */
private abstract class OwnedResourceRecord implements IResource { private abstract class OwnedResourceRecord implements IResource {
final int pid; final int mPid;
final int uid; final int mUid;
protected final int mResourceId; protected final int mResourceId;
OwnedResourceRecord(int resourceId) { OwnedResourceRecord(int resourceId) {
@@ -501,8 +501,8 @@ public class IpSecService extends IIpSecService.Stub {
throw new IllegalArgumentException("Resource ID must not be INVALID_RESOURCE_ID"); throw new IllegalArgumentException("Resource ID must not be INVALID_RESOURCE_ID");
} }
mResourceId = resourceId; mResourceId = resourceId;
pid = Binder.getCallingPid(); mPid = Binder.getCallingPid();
uid = Binder.getCallingUid(); mUid = Binder.getCallingUid();
getResourceTracker().take(); getResourceTracker().take();
} }
@@ -512,7 +512,7 @@ public class IpSecService extends IIpSecService.Stub {
/** Convenience method; retrieves the user resource record for the stored UID. */ /** Convenience method; retrieves the user resource record for the stored UID. */
protected UserRecord getUserRecord() { protected UserRecord getUserRecord() {
return mUserResourceTracker.getUserRecord(uid); return mUserResourceTracker.getUserRecord(mUid);
} }
@Override @Override
@@ -527,9 +527,9 @@ public class IpSecService extends IIpSecService.Stub {
.append("{mResourceId=") .append("{mResourceId=")
.append(mResourceId) .append(mResourceId)
.append(", pid=") .append(", pid=")
.append(pid) .append(mPid)
.append(", uid=") .append(", uid=")
.append(uid) .append(mUid)
.append("}") .append("}")
.toString(); .toString();
} }
@@ -545,7 +545,7 @@ public class IpSecService extends IIpSecService.Stub {
SparseArray<RefcountedResource<T>> mArray = new SparseArray<>(); SparseArray<RefcountedResource<T>> mArray = new SparseArray<>();
private final String mTypeName; private final String mTypeName;
public RefcountedResourceArray(String typeName) { RefcountedResourceArray(String typeName) {
this.mTypeName = typeName; this.mTypeName = typeName;
} }
@@ -628,7 +628,7 @@ public class IpSecService extends IIpSecService.Stub {
mSrvConfig mSrvConfig
.getNetdInstance() .getNetdInstance()
.ipSecDeleteSecurityAssociation( .ipSecDeleteSecurityAssociation(
uid, mUid,
mConfig.getSourceAddress(), mConfig.getSourceAddress(),
mConfig.getDestinationAddress(), mConfig.getDestinationAddress(),
spi, spi,
@@ -696,7 +696,7 @@ public class IpSecService extends IIpSecService.Stub {
mSrvConfig mSrvConfig
.getNetdInstance() .getNetdInstance()
.ipSecDeleteSecurityAssociation( .ipSecDeleteSecurityAssociation(
uid, mSourceAddress, mDestinationAddress, mSpi, 0 /* mark */, mUid, mSourceAddress, mDestinationAddress, mSpi, 0 /* mark */,
0 /* mask */, 0 /* if_id */); 0 /* mask */, 0 /* if_id */);
} }
} catch (ServiceSpecificException | RemoteException e) { } catch (ServiceSpecificException | RemoteException e) {
@@ -849,14 +849,14 @@ public class IpSecService extends IIpSecService.Stub {
for (int selAddrFamily : ADDRESS_FAMILIES) { for (int selAddrFamily : ADDRESS_FAMILIES) {
netd.ipSecDeleteSecurityPolicy( netd.ipSecDeleteSecurityPolicy(
uid, mUid,
selAddrFamily, selAddrFamily,
IpSecManager.DIRECTION_OUT, IpSecManager.DIRECTION_OUT,
mOkey, mOkey,
0xffffffff, 0xffffffff,
mIfId); mIfId);
netd.ipSecDeleteSecurityPolicy( netd.ipSecDeleteSecurityPolicy(
uid, mUid,
selAddrFamily, selAddrFamily,
IpSecManager.DIRECTION_IN, IpSecManager.DIRECTION_IN,
mIkey, mIkey,
@@ -1025,7 +1025,7 @@ public class IpSecService extends IIpSecService.Stub {
@NonNull @NonNull
private AppOpsManager getAppOpsManager() { private AppOpsManager getAppOpsManager() {
AppOpsManager appOps = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); AppOpsManager appOps = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
if(appOps == null) throw new RuntimeException("System Server couldn't get AppOps"); if (appOps == null) throw new RuntimeException("System Server couldn't get AppOps");
return appOps; return appOps;
} }
@@ -1054,6 +1054,7 @@ public class IpSecService extends IIpSecService.Stub {
mUidFdTagger = uidFdTagger; mUidFdTagger = uidFdTagger;
} }
/** Called by system server when system is ready. */
public void systemReady() { public void systemReady() {
if (isNetdAlive()) { if (isNetdAlive()) {
Log.d(TAG, "IpSecService is ready"); Log.d(TAG, "IpSecService is ready");
@@ -1229,7 +1230,7 @@ public class IpSecService extends IIpSecService.Stub {
* <p>Since the socket is created on behalf of an unprivileged application, all traffic * <p>Since the socket is created on behalf of an unprivileged application, all traffic
* should be accounted to the UID of the unprivileged application. * should be accounted to the UID of the unprivileged application.
*/ */
public void tag(FileDescriptor fd, int uid) throws IOException; void tag(FileDescriptor fd, int uid) throws IOException;
} }
/** /**
@@ -1771,7 +1772,7 @@ public class IpSecService extends IIpSecService.Stub {
TransformRecord info = userRecord.mTransformRecords.getResourceOrThrow(resourceId); TransformRecord info = userRecord.mTransformRecords.getResourceOrThrow(resourceId);
// TODO: make this a function. // TODO: make this a function.
if (info.pid != getCallingPid() || info.uid != callingUid) { if (info.mPid != getCallingPid() || info.mUid != callingUid) {
throw new SecurityException("Only the owner of an IpSec Transform may apply it!"); throw new SecurityException("Only the owner of an IpSec Transform may apply it!");
} }