This commit is part of a large scale change to fix errorprone errors that have been downgraded to warnings in the android source tree, so that they can be promoted to errors again. The full list of changes include the following, but not all will be present in any one individual commit: BadAnnotationImplementation BadShiftAmount BanJNDI BoxedPrimitiveEquality ComparableType ComplexBooleanConstant CollectionToArraySafeParameter ConditionalExpressionNumericPromotion DangerousLiteralNull DoubleBraceInitialization DurationFrom DurationTemporalUnit EmptyTopLevelDeclaration EqualsNull EqualsReference FormatString FromTemporalAccessor GetClassOnAnnotation GetClassOnClass HashtableContains IdentityBinaryExpression IdentityHashMapBoxing InstantTemporalUnit InvalidTimeZoneID InvalidZoneId IsInstanceIncompatibleType JUnitParameterMethodNotFound LockOnBoxedPrimitive MathRoundIntLong MislabeledAndroidString MisusedDayOfYear MissingSuperCall MisusedWeekYear ModifyingCollectionWithItself NoCanIgnoreReturnValueOnClasses NonRuntimeAnnotation NullableOnContainingClass NullTernary OverridesJavaxInjectableMethod ParcelableCreator PeriodFrom PreconditionsInvalidPlaceholder ProtoBuilderReturnValueIgnored ProtoFieldNullComparison RandomModInteger RectIntersectReturnValueIgnored ReturnValueIgnored SelfAssignment SelfComparison SelfEquals SizeGreaterThanOrEqualsZero StringBuilderInitWithChar TreeToString TryFailThrowable UnnecessaryCheckNotNull UnusedCollectionModifiedInPlace XorPower See https://errorprone.info/bugpatterns for more information on the checks. Bug: 253827323 Test: m RUN_ERROR_PRONE=true javac-check Change-Id: I29f691a22617b1fc834680ff1cf4ab4244203f06
45 lines
1.1 KiB
Java
45 lines
1.1 KiB
Java
package com.android.settings.vpn2;
|
|
|
|
import android.annotation.NonNull;
|
|
|
|
import com.android.internal.util.Preconditions;
|
|
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* Holds packageName:userId pairs without any heavyweight fields.
|
|
* {@see ApplicationInfo}
|
|
*/
|
|
class AppVpnInfo implements Comparable<AppVpnInfo> {
|
|
public final int userId;
|
|
public final String packageName;
|
|
|
|
public AppVpnInfo(int userId, @NonNull String packageName) {
|
|
this.userId = userId;
|
|
this.packageName = Preconditions.checkNotNull(packageName);
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(AppVpnInfo other) {
|
|
int result = packageName.compareTo(other.packageName);
|
|
if (result == 0) {
|
|
result = other.userId - userId;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object other) {
|
|
if (other instanceof AppVpnInfo) {
|
|
AppVpnInfo that = (AppVpnInfo) other;
|
|
return userId == that.userId && Objects.equals(packageName, that.packageName);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(packageName, userId);
|
|
}
|
|
}
|