Fix errorprone warnings that should be errors

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: I8446f9076a45ebf7e7ffa06cb0d4ddb1001b6c00
This commit is contained in:
Cole Faust 2022-10-15 21:33:29 -07:00
parent 81c4fd8041
commit 7da659bb6c
115 changed files with 572 additions and 606 deletions

View File

@ -59,4 +59,10 @@ android_test {
test_suites: ["device-tests"],
certificate: "platform",
errorprone: {
javacflags: [
"-Xep:ReturnValueIgnored:WARN",
],
},
}

View File

@ -118,7 +118,7 @@ public class ReferencePerfTest {
int got = count.get();
if (n != got) {
throw new IllegalStateException(
String.format("Only %i of %i objects finalized?", got, n));
String.format("Only %d of %d objects finalized?", got, n));
}
}
}

View File

@ -396,6 +396,17 @@ public final class SearchableInfo implements Parcelable {
private final String mSuggestActionMsg;
private final String mSuggestActionMsgColumn;
public static final Parcelable.Creator<ActionKeyInfo> CREATOR =
new Parcelable.Creator<ActionKeyInfo>() {
public ActionKeyInfo createFromParcel(Parcel in) {
return new ActionKeyInfo(in);
}
public ActionKeyInfo[] newArray(int size) {
return new ActionKeyInfo[size];
}
};
/**
* Create one object using attributeset as input data.
* @param activityContext runtime context of the activity that the action key information

View File

@ -31,5 +31,4 @@ public class ActivityNotFoundException extends RuntimeException
{
super(name);
}
};
}

View File

@ -261,8 +261,8 @@ public abstract class AtomicFormula extends IntegrityFormula {
}
LongAtomicFormula that = (LongAtomicFormula) o;
return getKey() == that.getKey()
&& mValue == that.mValue
&& mOperator == that.mOperator;
&& Objects.equals(mValue, that.mValue)
&& Objects.equals(mOperator, that.mOperator);
}
@Override
@ -628,7 +628,7 @@ public abstract class AtomicFormula extends IntegrityFormula {
return false;
}
BooleanAtomicFormula that = (BooleanAtomicFormula) o;
return getKey() == that.getKey() && mValue == that.mValue;
return getKey() == that.getKey() && Objects.equals(mValue, that.mValue);
}
@Override

View File

@ -189,12 +189,12 @@ public abstract class PackageManager {
@VisibleForTesting
public Property(@NonNull String name, int type,
@NonNull String packageName, @Nullable String className) {
assert name != null;
assert type >= TYPE_BOOLEAN && type <= TYPE_STRING;
assert packageName != null;
this.mName = name;
if (type < TYPE_BOOLEAN || type > TYPE_STRING) {
throw new IllegalArgumentException("Invalid type");
}
this.mName = Objects.requireNonNull(name);
this.mType = type;
this.mPackageName = packageName;
this.mPackageName = Objects.requireNonNull(packageName);
this.mClassName = className;
}
/** @hide */
@ -442,9 +442,8 @@ public abstract class PackageManager {
*/
public ComponentEnabledSetting(@NonNull ComponentName componentName,
@EnabledState int newState, @EnabledFlags int flags) {
Objects.nonNull(componentName);
mPackageName = null;
mComponentName = componentName;
mComponentName = Objects.requireNonNull(componentName);
mEnabledState = newState;
mEnabledFlags = flags;
}
@ -460,8 +459,7 @@ public abstract class PackageManager {
*/
public ComponentEnabledSetting(@NonNull String packageName,
@EnabledState int newState, @EnabledFlags int flags) {
Objects.nonNull(packageName);
mPackageName = packageName;
mPackageName = Objects.requireNonNull(packageName);
mComponentName = null;
mEnabledState = newState;
mEnabledFlags = flags;

View File

@ -50,6 +50,7 @@ import android.view.contentcapture.ContentCaptureContext;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;
import java.lang.IllegalArgumentException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@ -1360,7 +1361,9 @@ public final class ShortcutInfo implements Parcelable {
@NonNull
public Builder setIntents(@NonNull Intent[] intents) {
Objects.requireNonNull(intents, "intents cannot be null");
Objects.requireNonNull(intents.length, "intents cannot be empty");
if (intents.length == 0) {
throw new IllegalArgumentException("intents cannot be empty");
}
for (Intent intent : intents) {
Objects.requireNonNull(intent, "intents cannot contain null");
Objects.requireNonNull(intent.getAction(), "intent's action must be set");
@ -1398,7 +1401,9 @@ public final class ShortcutInfo implements Parcelable {
@NonNull
public Builder setPersons(@NonNull Person[] persons) {
Objects.requireNonNull(persons, "persons cannot be null");
Objects.requireNonNull(persons.length, "persons cannot be empty");
if (persons.length == 0) {
throw new IllegalArgumentException("persons cannot be empty");
}
for (Person person : persons) {
Objects.requireNonNull(person, "persons cannot contain null");
}

View File

@ -60,4 +60,4 @@ public class CameraInfo implements Parcelable {
return new CameraInfo[size];
}
};
};
}

View File

@ -68,4 +68,4 @@ public class CameraStatus implements Parcelable {
return new CameraStatus[size];
}
};
};
}

View File

@ -118,4 +118,4 @@ public class CryptoObject {
}
return AndroidKeyStoreProvider.getKeyStoreOperationHandle(mCrypto);
}
};
}

View File

@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
@ -63,11 +64,11 @@ public class FrameNumberTracker {
}
private void update() {
Iterator iter = mFutureErrorMap.entrySet().iterator();
Iterator<Map.Entry<Long, Integer>> iter = mFutureErrorMap.entrySet().iterator();
while (iter.hasNext()) {
TreeMap.Entry pair = (TreeMap.Entry)iter.next();
Long errorFrameNumber = (Long)pair.getKey();
int requestType = (int) pair.getValue();
Map.Entry<Long, Integer> pair = iter.next();
long errorFrameNumber = pair.getKey();
int requestType = pair.getValue();
Boolean removeError = false;
if (errorFrameNumber == mCompletedFrameNumber[requestType] + 1) {
removeError = true;

View File

@ -103,6 +103,7 @@ public class MarshalQueryableEnum<T extends Enum<T>> implements MarshalQueryable
return new MarshalerEnum(managedType, nativeType);
}
@SuppressWarnings("ReturnValueIgnored")
@Override
public boolean isTypeMappingSupported(TypeReference<T> managedType, int nativeType) {
if (nativeType == TYPE_INT32 || nativeType == TYPE_BYTE) {

View File

@ -1270,7 +1270,8 @@ public final class OutputConfiguration implements Parcelable {
return false;
}
for (int j = 0; j < mSensorPixelModesUsed.size(); j++) {
if (mSensorPixelModesUsed.get(j) != other.mSensorPixelModesUsed.get(j)) {
if (!Objects.equals(
mSensorPixelModesUsed.get(j), other.mSensorPixelModesUsed.get(j))) {
return false;
}
}

View File

@ -69,4 +69,4 @@ public final class Fingerprint extends BiometricAuthenticator.Identifier {
return new Fingerprint[size];
}
};
};
}

View File

@ -53,8 +53,8 @@ import java.lang.annotation.RetentionPolicy;
import java.net.ProtocolException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
@ -89,12 +89,10 @@ public class NetworkStatsDataMigrationUtils {
@Retention(RetentionPolicy.SOURCE)
public @interface Prefix {}
private static final HashMap<String, String> sPrefixLegacyFileNameMap =
new HashMap<String, String>() {{
put(PREFIX_XT, "netstats_xt.bin");
put(PREFIX_UID, "netstats_uid.bin");
put(PREFIX_UID_TAG, "netstats_uid.bin");
}};
private static final Map<String, String> sPrefixLegacyFileNameMap = Map.of(
PREFIX_XT, "netstats_xt.bin",
PREFIX_UID, "netstats_uid.bin",
PREFIX_UID_TAG, "netstats_uid.bin");
// These version constants are copied from NetworkStatsCollection/History, which is okay for
// OEMs to modify to adapt their own logic.

View File

@ -53,7 +53,7 @@ public final class TunnelConnectionParamsUtils {
if (in.keySet().size() != EXPECTED_BUNDLE_KEY_CNT) {
throw new IllegalArgumentException(
String.format(
"Expect PersistableBundle to have %d element but found: %d",
"Expect PersistableBundle to have %d element but found: %s",
EXPECTED_BUNDLE_KEY_CNT, in.keySet()));
}

View File

@ -61,4 +61,4 @@ public class ExportResult implements Parcelable {
out.writeInt(resultCode);
out.writeByteArray(exportData);
}
};
}

View File

@ -26,6 +26,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
* It is used to replace URLSpans in {@link AccessibilityNodeInfo#setText(CharSequence)}
* @hide
*/
@SuppressWarnings("ParcelableCreator")
public class AccessibilityURLSpan extends URLSpan implements Parcelable {
final AccessibilityClickableSpan mAccessibilityClickableSpan;

View File

@ -40,5 +40,5 @@ public class AndroidException extends Exception {
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
};
}

View File

@ -34,5 +34,4 @@ public class AndroidRuntimeException extends RuntimeException {
public AndroidRuntimeException(Exception cause) {
super(cause);
}
};
}

View File

@ -356,4 +356,4 @@ public final class Range<T extends Comparable<? super T>> {
private final T mLower;
private final T mUpper;
};
}

View File

@ -696,5 +696,5 @@ public class TypedValue {
sb.append("}");
return sb.toString();
}
};
}

View File

@ -394,7 +394,6 @@ public class CutoutSpecification {
Log.e(TAG, "According to SVG definition, it shouldn't happen");
return;
}
spec.trim();
translateMatrix();
final Path newPath = PathParser.createPathFromPathData(spec);

View File

@ -19,6 +19,7 @@ package android.view;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import android.annotation.Nullable;
import android.annotation.NonNull;
import android.app.WindowConfiguration.ActivityType;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.IBinder;
@ -157,7 +158,7 @@ public class RemoteAnimationDefinition implements Parcelable {
}
}
public static final @android.annotation.NonNull Creator<RemoteAnimationDefinition> CREATOR =
public static final @NonNull Creator<RemoteAnimationDefinition> CREATOR =
new Creator<RemoteAnimationDefinition>() {
public RemoteAnimationDefinition createFromParcel(Parcel in) {
return new RemoteAnimationDefinition(in);
@ -199,18 +200,17 @@ public class RemoteAnimationDefinition implements Parcelable {
return 0;
}
private static final @android.annotation.NonNull Creator<RemoteAnimationAdapterEntry> CREATOR
= new Creator<RemoteAnimationAdapterEntry>() {
public static final @NonNull Parcelable.Creator<RemoteAnimationAdapterEntry> CREATOR =
new Parcelable.Creator<RemoteAnimationAdapterEntry>() {
@Override
public RemoteAnimationAdapterEntry createFromParcel(Parcel in) {
return new RemoteAnimationAdapterEntry(in);
}
@Override
public RemoteAnimationAdapterEntry createFromParcel(Parcel in) {
return new RemoteAnimationAdapterEntry(in);
}
@Override
public RemoteAnimationAdapterEntry[] newArray(int size) {
return new RemoteAnimationAdapterEntry[size];
}
};
@Override
public RemoteAnimationAdapterEntry[] newArray(int size) {
return new RemoteAnimationAdapterEntry[size];
}
};
}
}

View File

@ -68,4 +68,4 @@ public class ConsoleMessage {
public int lineNumber() {
return mLineNumber;
}
};
}

View File

@ -25,4 +25,4 @@ public interface ValueCallback<T> {
* @param value The value.
*/
public void onReceiveValue(T value);
};
}

View File

@ -296,7 +296,7 @@ public final class TransitionFilter implements Parcelable {
out.append((i == 0 ? "" : ",") + TransitionInfo.modeToString(mModes[i]));
}
}
out.append("]").toString();
out.append("]");
out.append(" flags=" + TransitionInfo.flagsToString(mFlags));
out.append(" mustBeTask=" + mMustBeTask);
out.append(" order=" + containerOrderToString(mOrder));

View File

@ -59,6 +59,7 @@ public final class AssociationState {
/**
* The state of the source process of an association.
*/
@SuppressWarnings("ParcelableCreator")
public static final class SourceState implements Parcelable {
private @NonNull final ProcessStats mProcessStats;
private @Nullable final AssociationState mAssociationState;

View File

@ -3656,6 +3656,7 @@ public class BatteryStatsImpl extends BatteryStats {
public abstract T instantiateObject();
}
@SuppressWarnings("ParcelableCreator")
public static class ControllerActivityCounterImpl extends ControllerActivityCounter
implements Parcelable {
private final Clock mClock;

View File

@ -735,7 +735,7 @@ public class BinderCallsStats implements BinderInternal.Observer {
}
protected boolean shouldRecordDetailedData() {
return mRandom.nextInt() % mPeriodicSamplingInterval == 0;
return mRandom.nextInt(mPeriodicSamplingInterval) == 0;
}
/**

View File

@ -236,7 +236,7 @@ public class BinderLatencyObserver {
}
protected boolean shouldKeepSample() {
return mRandom.nextInt() % mPeriodicSamplingInterval == 0;
return mRandom.nextInt(mPeriodicSamplingInterval) == 0;
}
/** Updates the sampling interval. */

View File

@ -290,7 +290,7 @@ public class LooperStats implements Looper.Observer {
}
protected boolean shouldCollectDetailedData() {
return ThreadLocalRandom.current().nextInt() % mSamplingInterval == 0;
return ThreadLocalRandom.current().nextInt(mSamplingInterval) == 0;
}
private static class DispatchSession {

View File

@ -413,7 +413,7 @@ public class LatencyTracker {
boolean shouldSample;
int traceThreshold;
synchronized (mLock) {
shouldSample = ThreadLocalRandom.current().nextInt() % mSamplingInterval == 0;
shouldSample = ThreadLocalRandom.current().nextInt(mSamplingInterval) == 0;
traceThreshold = mTraceThresholdPerAction[action];
}

View File

@ -241,4 +241,4 @@ public abstract class BaseSurfaceHolder implements SurfaceHolder {
mSurfaceFrame.right = width;
mSurfaceFrame.bottom = height;
}
};
}

View File

@ -88,6 +88,7 @@ public class ParcelableBenchmark {
}
}
@SuppressWarnings("ParcelableCreator")
@SuppressLint("ParcelCreator")
private static class PointArray implements Parcelable {
Rect mBounds = new Rect();

View File

@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import android.content.pm.PackageManager.Property;
@ -162,40 +163,30 @@ public class PackageManagerPropertyTests {
@Test
public void testProperty_invalidName() throws Exception {
try {
assertThrows(NullPointerException.class, () -> {
final Property p = new Property(null, 1, "android", null);
fail("expected assertion error");
} catch (AssertionError expected) {
}
});
}
@Test
public void testProperty_invalidType() throws Exception {
try {
assertThrows(IllegalArgumentException.class, () -> {
final Property p = new Property("invalidTypeProperty", 0, "android", null);
fail("expected assertion error");
} catch (AssertionError expected) {
}
});
try {
assertThrows(IllegalArgumentException.class, () -> {
final Property p = new Property("invalidTypeProperty", 6, "android", null);
fail("expected assertion error");
} catch (AssertionError expected) {
}
});
try {
assertThrows(IllegalArgumentException.class, () -> {
final Property p = new Property("invalidTypeProperty", -1, "android", null);
fail("expected assertion error");
} catch (AssertionError expected) {
}
});
}
@Test
public void testProperty_noPackageName() throws Exception {
try {
assertThrows(NullPointerException.class, () -> {
final Property p = new Property(null, 1, null, null);
fail("expected assertion error");
} catch (AssertionError expected) {
}
});
}
}

View File

@ -128,6 +128,7 @@ public class RemoteViewsTest {
RemoteViews clone = child.clone();
}
@SuppressWarnings("ReturnValueIgnored")
@Test
public void clone_repeatedly() {
RemoteViews original = new RemoteViews(mPackage, R.layout.remote_views_test);
@ -485,6 +486,7 @@ public class RemoteViewsTest {
}
}
@SuppressWarnings("ReturnValueIgnored")
@Test
public void nestedAddViews() {
RemoteViews views = new RemoteViews(mPackage, R.layout.remote_views_test);
@ -509,6 +511,7 @@ public class RemoteViewsTest {
parcelAndRecreate(views);
}
@SuppressWarnings("ReturnValueIgnored")
@Test
public void nestedLandscapeViews() {
RemoteViews views = new RemoteViews(mPackage, R.layout.remote_views_test);

View File

@ -1054,10 +1054,23 @@ public class BinderCallsStatsTest {
super(new Injector() {
public Random getRandomGenerator() {
return new Random() {
int mCallCount = 0;
int mCallCount = -1;
public int nextInt() {
return mCallCount++;
throw new IllegalStateException("Should not use nextInt()");
}
public int nextInt(int x) {
if (mCallCount == -1) {
// The tests are written such that they expect
// the first call to nextInt() to be on the first
// callEnded(). However, the BinderCallsStats
// constructor also calls nextInt(). Fake 0 being
// rolled twice.
mCallCount++;
return 0;
}
return (mCallCount++) % x;
}
};
}

View File

@ -98,7 +98,7 @@ public class BinderLatencyObserverTest {
assertEquals(1, latencyHistograms.size());
LatencyDims dims = latencyHistograms.keySet().iterator().next();
assertEquals(binder.getClass(), dims.getBinderClass());
assertEquals(1, dims.getTransactionCode());
assertEquals(2, dims.getTransactionCode()); // the first nextInt() is in the constructor
assertThat(latencyHistograms.get(dims)).asList().containsExactly(1, 0, 0, 0, 0).inOrder();
}
@ -313,11 +313,11 @@ public class BinderLatencyObserverTest {
int mCallCount = 0;
public int nextInt() {
return mCallCount++;
throw new IllegalStateException("Should not use nextInt()");
}
public int nextInt(int x) {
return 1;
return (mCallCount++) % x;
}
};
}

View File

@ -16,6 +16,8 @@
package com.android.internal.util;
import static org.junit.Assert.assertThrows;
import android.os.SystemClock;
import android.text.format.DateUtils;
@ -170,10 +172,9 @@ public class TokenBucketTest extends TestCase {
}
void assertThrow(Fn fn) {
try {
assertThrows(Throwable.class, () -> {
fn.call();
fail("expected n exception to be thrown.");
} catch (Throwable t) { }
});
}
interface Fn { void call(); }

View File

@ -31,6 +31,7 @@ public class Test extends ActivityInstrumentationTestCase2<MainActivity> {
assertEquals(3366, getActivity().getValue());
}
@SuppressWarnings("ReturnValueIgnored")
public void testAnnotation() throws Exception {
assertEquals(ReferencedByAnnotation.B,
((AnnotationWithEnum) TestApplication.annotation).value());

View File

@ -20,6 +20,7 @@ import junit.framework.TestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Objects;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -39,11 +40,11 @@ public class CallbackRegistryTest extends TestCase {
Integer argValue;
private void addNotifyCount(Integer callback) {
if (callback == callback1) {
if (Objects.equals(callback, callback1)) {
notify1++;
} else if (callback == callback2) {
} else if (Objects.equals(callback, callback2)) {
notify2++;
} else if (callback == callback3) {
} else if (Objects.equals(callback, callback3)) {
notify3++;
}
deepNotifyCount[callback]++;
@ -114,7 +115,7 @@ public class CallbackRegistryTest extends TestCase {
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
if (callback == callback1) {
if (Objects.equals(callback, callback1)) {
registry.remove(callback1);
registry.remove(callback2);
}
@ -166,9 +167,9 @@ public class CallbackRegistryTest extends TestCase {
public void onNotifyCallback(Integer callback, CallbackRegistryTest sender,
int arg1, Integer arg) {
addNotifyCount(callback);
if (callback == callback1) {
if (Objects.equals(callback, callback1)) {
registry.remove(callback2);
} else if (callback == callback3) {
} else if (Objects.equals(callback, callback3)) {
registry.add(callback2);
}
}

View File

@ -168,6 +168,7 @@ public final class EfficientXmlChecker extends BugChecker
*/
private static final Matcher<ExpressionTree> CONVERT_PRIMITIVE_TO_STRING =
new Matcher<ExpressionTree>() {
@SuppressWarnings("TreeToString") //TODO: Fix me
@Override
public boolean matches(ExpressionTree tree, VisitorState state) {
if (PRIMITIVE_TO_STRING.matches(tree, state)) {
@ -205,6 +206,7 @@ public final class EfficientXmlChecker extends BugChecker
*/
private static final Matcher<ExpressionTree> CONVERT_STRING_TO_PRIMITIVE =
new Matcher<ExpressionTree>() {
@SuppressWarnings("TreeToString") //TODO: Fix me
@Override
public boolean matches(ExpressionTree tree, VisitorState state) {
if (PRIMITIVE_PARSE.matches(tree, state)) {

View File

@ -758,7 +758,7 @@ public class RippleDrawable extends LayerDrawable {
if (mBackground != null) {
mBackground.onHotspotBoundsChanged();
}
float newRadius = Math.round(getComputedRadius());
float newRadius = getComputedRadius();
for (int i = 0; i < mRunningAnimations.size(); i++) {
RippleAnimationSession s = mRunningAnimations.get(i);
s.setRadius(newRadius);

View File

@ -60,7 +60,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
/**
@ -1171,18 +1171,14 @@ public class VectorDrawable extends Drawable {
private static final int NATIVE_ALLOCATION_SIZE = 100;
private static final HashMap<String, Integer> sPropertyIndexMap =
new HashMap<String, Integer>() {
{
put("translateX", TRANSLATE_X_INDEX);
put("translateY", TRANSLATE_Y_INDEX);
put("scaleX", SCALE_X_INDEX);
put("scaleY", SCALE_Y_INDEX);
put("pivotX", PIVOT_X_INDEX);
put("pivotY", PIVOT_Y_INDEX);
put("rotation", ROTATION_INDEX);
}
};
private static final Map<String, Integer> sPropertyIndexMap = Map.of(
"translateX", TRANSLATE_X_INDEX,
"translateY", TRANSLATE_Y_INDEX,
"scaleX", SCALE_X_INDEX,
"scaleY", SCALE_Y_INDEX,
"pivotX", PIVOT_X_INDEX,
"pivotY", PIVOT_Y_INDEX,
"rotation", ROTATION_INDEX);
static int getPropertyIndex(String propertyName) {
if (sPropertyIndexMap.containsKey(propertyName)) {
@ -1285,18 +1281,15 @@ public class VectorDrawable extends Drawable {
}
};
private static final HashMap<String, Property> sPropertyMap =
new HashMap<String, Property>() {
{
put("translateX", TRANSLATE_X);
put("translateY", TRANSLATE_Y);
put("scaleX", SCALE_X);
put("scaleY", SCALE_Y);
put("pivotX", PIVOT_X);
put("pivotY", PIVOT_Y);
put("rotation", ROTATION);
}
};
private static final Map<String, Property> sPropertyMap = Map.of(
"translateX", TRANSLATE_X,
"translateY", TRANSLATE_Y,
"scaleX", SCALE_X,
"scaleY", SCALE_Y,
"pivotX", PIVOT_X,
"pivotY", PIVOT_Y,
"rotation", ROTATION);
// Temp array to store transform values obtained from native.
private float[] mTransform;
/////////////////////////////////////////////////////
@ -1762,19 +1755,15 @@ public class VectorDrawable extends Drawable {
private static final int NATIVE_ALLOCATION_SIZE = 264;
// Property map for animatable attributes.
private final static HashMap<String, Integer> sPropertyIndexMap
= new HashMap<String, Integer> () {
{
put("strokeWidth", STROKE_WIDTH_INDEX);
put("strokeColor", STROKE_COLOR_INDEX);
put("strokeAlpha", STROKE_ALPHA_INDEX);
put("fillColor", FILL_COLOR_INDEX);
put("fillAlpha", FILL_ALPHA_INDEX);
put("trimPathStart", TRIM_PATH_START_INDEX);
put("trimPathEnd", TRIM_PATH_END_INDEX);
put("trimPathOffset", TRIM_PATH_OFFSET_INDEX);
}
};
private static final Map<String, Integer> sPropertyIndexMap = Map.of(
"strokeWidth", STROKE_WIDTH_INDEX,
"strokeColor", STROKE_COLOR_INDEX,
"strokeAlpha", STROKE_ALPHA_INDEX,
"fillColor", FILL_COLOR_INDEX,
"fillAlpha", FILL_ALPHA_INDEX,
"trimPathStart", TRIM_PATH_START_INDEX,
"trimPathEnd", TRIM_PATH_END_INDEX,
"trimPathOffset", TRIM_PATH_OFFSET_INDEX);
// Below are the Properties that wrap the setters to avoid reflection overhead in animations
private static final Property<VFullPath, Float> STROKE_WIDTH =
@ -1881,19 +1870,15 @@ public class VectorDrawable extends Drawable {
}
};
private final static HashMap<String, Property> sPropertyMap
= new HashMap<String, Property> () {
{
put("strokeWidth", STROKE_WIDTH);
put("strokeColor", STROKE_COLOR);
put("strokeAlpha", STROKE_ALPHA);
put("fillColor", FILL_COLOR);
put("fillAlpha", FILL_ALPHA);
put("trimPathStart", TRIM_PATH_START);
put("trimPathEnd", TRIM_PATH_END);
put("trimPathOffset", TRIM_PATH_OFFSET);
}
};
private static final Map<String, Property> sPropertyMap = Map.of(
"strokeWidth", STROKE_WIDTH,
"strokeColor", STROKE_COLOR,
"strokeAlpha", STROKE_ALPHA,
"fillColor", FILL_COLOR,
"fillAlpha", FILL_ALPHA,
"trimPathStart", TRIM_PATH_START,
"trimPathEnd", TRIM_PATH_END,
"trimPathOffset", TRIM_PATH_OFFSET);
// Temp array to store property data obtained from native getter.
private byte[] mPropertyData;

View File

@ -2325,10 +2325,9 @@ public class AudioManager {
return AudioSystem.SUCCESS;
}
private final Map<Integer, Object> mDevRoleForCapturePresetListeners = new HashMap<>(){{
put(AudioSystem.DEVICE_ROLE_PREFERRED,
new DevRoleListeners<OnPreferredDevicesForCapturePresetChangedListener>());
}};
private final Map<Integer, Object> mDevRoleForCapturePresetListeners = Map.of(
AudioSystem.DEVICE_ROLE_PREFERRED,
new DevRoleListeners<OnPreferredDevicesForCapturePresetChangedListener>());
private class DevRoleListenerInfo<T> {
final @NonNull Executor mExecutor;
@ -6483,15 +6482,17 @@ public class AudioManager {
// AudioPort implementation
//
static final int AUDIOPORT_GENERATION_INIT = 0;
static Integer sAudioPortGeneration = new Integer(AUDIOPORT_GENERATION_INIT);
static ArrayList<AudioPort> sAudioPortsCached = new ArrayList<AudioPort>();
static ArrayList<AudioPort> sPreviousAudioPortsCached = new ArrayList<AudioPort>();
static ArrayList<AudioPatch> sAudioPatchesCached = new ArrayList<AudioPatch>();
private static final int AUDIOPORT_GENERATION_INIT = 0;
private static Object sAudioPortGenerationLock = new Object();
@GuardedBy("sAudioPortGenerationLock")
private static int sAudioPortGeneration = AUDIOPORT_GENERATION_INIT;
private static ArrayList<AudioPort> sAudioPortsCached = new ArrayList<AudioPort>();
private static ArrayList<AudioPort> sPreviousAudioPortsCached = new ArrayList<AudioPort>();
private static ArrayList<AudioPatch> sAudioPatchesCached = new ArrayList<AudioPatch>();
static int resetAudioPortGeneration() {
int generation;
synchronized (sAudioPortGeneration) {
synchronized (sAudioPortGenerationLock) {
generation = sAudioPortGeneration;
sAudioPortGeneration = AUDIOPORT_GENERATION_INIT;
}
@ -6501,7 +6502,7 @@ public class AudioManager {
static int updateAudioPortCache(ArrayList<AudioPort> ports, ArrayList<AudioPatch> patches,
ArrayList<AudioPort> previousPorts) {
sAudioPortEventHandler.init();
synchronized (sAudioPortGeneration) {
synchronized (sAudioPortGenerationLock) {
if (sAudioPortGeneration == AUDIOPORT_GENERATION_INIT) {
int[] patchGeneration = new int[1];

View File

@ -30,6 +30,7 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@ -446,14 +447,13 @@ public final class AudioMetadata {
// BaseMap is corresponding to audio_utils::metadata::Data
private static final int AUDIO_METADATA_OBJ_TYPE_BASEMAP = 6;
private static final HashMap<Class, Integer> AUDIO_METADATA_OBJ_TYPES = new HashMap<>() {{
put(Integer.class, AUDIO_METADATA_OBJ_TYPE_INT);
put(Long.class, AUDIO_METADATA_OBJ_TYPE_LONG);
put(Float.class, AUDIO_METADATA_OBJ_TYPE_FLOAT);
put(Double.class, AUDIO_METADATA_OBJ_TYPE_DOUBLE);
put(String.class, AUDIO_METADATA_OBJ_TYPE_STRING);
put(BaseMap.class, AUDIO_METADATA_OBJ_TYPE_BASEMAP);
}};
private static final Map<Class, Integer> AUDIO_METADATA_OBJ_TYPES = Map.of(
Integer.class, AUDIO_METADATA_OBJ_TYPE_INT,
Long.class, AUDIO_METADATA_OBJ_TYPE_LONG,
Float.class, AUDIO_METADATA_OBJ_TYPE_FLOAT,
Double.class, AUDIO_METADATA_OBJ_TYPE_DOUBLE,
String.class, AUDIO_METADATA_OBJ_TYPE_STRING,
BaseMap.class, AUDIO_METADATA_OBJ_TYPE_BASEMAP);
private static final Charset AUDIO_METADATA_CHARSET = StandardCharsets.UTF_8;
@ -634,8 +634,8 @@ public final class AudioMetadata {
* Datum corresponds to Object
****************************************************************************************/
private static final HashMap<Integer, DataPackage<?>> DATA_PACKAGES = new HashMap<>() {{
put(AUDIO_METADATA_OBJ_TYPE_INT, new DataPackage<Integer>() {
private static final Map<Integer, DataPackage<?>> DATA_PACKAGES = Map.of(
AUDIO_METADATA_OBJ_TYPE_INT, new DataPackage<Integer>() {
@Override
@Nullable
public Integer unpack(ByteBuffer buffer) {
@ -647,8 +647,8 @@ public final class AudioMetadata {
output.putInt(obj);
return true;
}
});
put(AUDIO_METADATA_OBJ_TYPE_LONG, new DataPackage<Long>() {
},
AUDIO_METADATA_OBJ_TYPE_LONG, new DataPackage<Long>() {
@Override
@Nullable
public Long unpack(ByteBuffer buffer) {
@ -660,8 +660,8 @@ public final class AudioMetadata {
output.putLong(obj);
return true;
}
});
put(AUDIO_METADATA_OBJ_TYPE_FLOAT, new DataPackage<Float>() {
},
AUDIO_METADATA_OBJ_TYPE_FLOAT, new DataPackage<Float>() {
@Override
@Nullable
public Float unpack(ByteBuffer buffer) {
@ -673,8 +673,8 @@ public final class AudioMetadata {
output.putFloat(obj);
return true;
}
});
put(AUDIO_METADATA_OBJ_TYPE_DOUBLE, new DataPackage<Double>() {
},
AUDIO_METADATA_OBJ_TYPE_DOUBLE, new DataPackage<Double>() {
@Override
@Nullable
public Double unpack(ByteBuffer buffer) {
@ -686,8 +686,8 @@ public final class AudioMetadata {
output.putDouble(obj);
return true;
}
});
put(AUDIO_METADATA_OBJ_TYPE_STRING, new DataPackage<String>() {
},
AUDIO_METADATA_OBJ_TYPE_STRING, new DataPackage<String>() {
@Override
@Nullable
public String unpack(ByteBuffer buffer) {
@ -713,9 +713,9 @@ public final class AudioMetadata {
output.put(valueArr);
return true;
}
});
put(AUDIO_METADATA_OBJ_TYPE_BASEMAP, new BaseMapPackage());
}};
},
AUDIO_METADATA_OBJ_TYPE_BASEMAP, new BaseMapPackage());
// ObjectPackage is a special case that it is expected to unpack audio_utils::metadata::Datum,
// which contains data type and data size besides the payload for the data.
private static final ObjectPackage OBJECT_PACKAGE = new ObjectPackage();

View File

@ -48,8 +48,8 @@ import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.NioUtils;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
@ -1867,26 +1867,24 @@ public class AudioTrack extends PlayerBase
}
// General pair map
private static final HashMap<String, Integer> CHANNEL_PAIR_MAP = new HashMap<>() {{
put("front", AudioFormat.CHANNEL_OUT_FRONT_LEFT
| AudioFormat.CHANNEL_OUT_FRONT_RIGHT);
put("back", AudioFormat.CHANNEL_OUT_BACK_LEFT
| AudioFormat.CHANNEL_OUT_BACK_RIGHT);
put("front of center", AudioFormat.CHANNEL_OUT_FRONT_LEFT_OF_CENTER
| AudioFormat.CHANNEL_OUT_FRONT_RIGHT_OF_CENTER);
put("side", AudioFormat.CHANNEL_OUT_SIDE_LEFT
| AudioFormat.CHANNEL_OUT_SIDE_RIGHT);
put("top front", AudioFormat.CHANNEL_OUT_TOP_FRONT_LEFT
| AudioFormat.CHANNEL_OUT_TOP_FRONT_RIGHT);
put("top back", AudioFormat.CHANNEL_OUT_TOP_BACK_LEFT
| AudioFormat.CHANNEL_OUT_TOP_BACK_RIGHT);
put("top side", AudioFormat.CHANNEL_OUT_TOP_SIDE_LEFT
| AudioFormat.CHANNEL_OUT_TOP_SIDE_RIGHT);
put("bottom front", AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_LEFT
| AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_RIGHT);
put("front wide", AudioFormat.CHANNEL_OUT_FRONT_WIDE_LEFT
| AudioFormat.CHANNEL_OUT_FRONT_WIDE_RIGHT);
}};
private static final Map<String, Integer> CHANNEL_PAIR_MAP = Map.of(
"front", AudioFormat.CHANNEL_OUT_FRONT_LEFT
| AudioFormat.CHANNEL_OUT_FRONT_RIGHT,
"back", AudioFormat.CHANNEL_OUT_BACK_LEFT
| AudioFormat.CHANNEL_OUT_BACK_RIGHT,
"front of center", AudioFormat.CHANNEL_OUT_FRONT_LEFT_OF_CENTER
| AudioFormat.CHANNEL_OUT_FRONT_RIGHT_OF_CENTER,
"side", AudioFormat.CHANNEL_OUT_SIDE_LEFT | AudioFormat.CHANNEL_OUT_SIDE_RIGHT,
"top front", AudioFormat.CHANNEL_OUT_TOP_FRONT_LEFT
| AudioFormat.CHANNEL_OUT_TOP_FRONT_RIGHT,
"top back", AudioFormat.CHANNEL_OUT_TOP_BACK_LEFT
| AudioFormat.CHANNEL_OUT_TOP_BACK_RIGHT,
"top side", AudioFormat.CHANNEL_OUT_TOP_SIDE_LEFT
| AudioFormat.CHANNEL_OUT_TOP_SIDE_RIGHT,
"bottom front", AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_LEFT
| AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_RIGHT,
"front wide", AudioFormat.CHANNEL_OUT_FRONT_WIDE_LEFT
| AudioFormat.CHANNEL_OUT_FRONT_WIDE_RIGHT);
/**
* Convenience method to check that the channel configuration (a.k.a channel mask) is supported
@ -1924,7 +1922,7 @@ public class AudioTrack extends PlayerBase
return false;
}
// Check all pairs to see that they are matched (front duplicated here).
for (HashMap.Entry<String, Integer> e : CHANNEL_PAIR_MAP.entrySet()) {
for (Map.Entry<String, Integer> e : CHANNEL_PAIR_MAP.entrySet()) {
final int positionPair = e.getValue();
if ((channelConfig & positionPair) != 0
&& (channelConfig & positionPair) != positionPair) {

View File

@ -70,6 +70,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Matcher;
@ -4833,12 +4834,13 @@ public class ExifInterface {
for (int i = 1; i < entryValues.length; ++i) {
final Pair<Integer, Integer> guessDataFormat = guessDataFormat(entryValues[i]);
int first = -1, second = -1;
if (guessDataFormat.first == dataFormat.first
|| guessDataFormat.second == dataFormat.first) {
if (Objects.equals(guessDataFormat.first, dataFormat.first)
|| Objects.equals(guessDataFormat.second, dataFormat.first)) {
first = dataFormat.first;
}
if (dataFormat.second != -1 && (guessDataFormat.first == dataFormat.second
|| guessDataFormat.second == dataFormat.second)) {
if (dataFormat.second != -1
&& (Objects.equals(guessDataFormat.first, dataFormat.second)
|| Objects.equals(guessDataFormat.second, dataFormat.second))) {
second = dataFormat.second;
}
if (first == -1 && second == -1) {

View File

@ -21,6 +21,8 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.os.IBinder;
import android.util.Log;
import com.android.internal.annotations.GuardedBy;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.CookieStore;
@ -31,7 +33,9 @@ import java.util.List;
public class MediaHTTPService extends IMediaHTTPService.Stub {
private static final String TAG = "MediaHTTPService";
@Nullable private List<HttpCookie> mCookies;
private Boolean mCookieStoreInitialized = new Boolean(false);
private final Object mCookieStoreInitializedLock = new Object();
@GuardedBy("mCookieStoreInitializedLock")
private boolean mCookieStoreInitialized = false;
public MediaHTTPService(@Nullable List<HttpCookie> cookies) {
mCookies = cookies;
@ -40,7 +44,7 @@ public class MediaHTTPService extends IMediaHTTPService.Stub {
public IMediaHTTPConnection makeHTTPConnection() {
synchronized (mCookieStoreInitialized) {
synchronized (mCookieStoreInitializedLock) {
// Only need to do it once for all connections
if ( !mCookieStoreInitialized ) {
CookieHandler cookieHandler = CookieHandler.getDefault();
@ -78,8 +82,8 @@ public class MediaHTTPService extends IMediaHTTPService.Stub {
Log.v(TAG, "makeHTTPConnection(" + this + "): cookieHandler: " + cookieHandler +
" Cookies: " + mCookies);
} // mCookieStoreInitialized
} // synchronized
}
}
return new MediaHTTPConnection();
}

View File

@ -2473,6 +2473,8 @@ public class MediaPlayer extends PlayerBase
*
* @see android.media.MediaPlayer#getTrackInfo
*/
// The creator needs to be pulic, which requires removing the @UnsupportedAppUsage
@SuppressWarnings("ParcelableCreator")
static public class TrackInfo implements Parcelable {
/**
* Gets the track type.

View File

@ -27,6 +27,7 @@ import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.util.Log;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.FrameworkStatsLog;
import java.util.concurrent.Executor;
@ -47,7 +48,9 @@ public class DvrRecorder implements AutoCloseable {
private static int sInstantId = 0;
private int mSegmentId = 0;
private int mOverflow;
private Boolean mIsStopped = true;
private final Object mIsStoppedLock = new Object();
@GuardedBy("mIsStoppedLock")
private boolean mIsStopped = true;
private final Object mListenerLock = new Object();
private native int nativeAttachFilter(Filter filter);
@ -147,7 +150,7 @@ public class DvrRecorder implements AutoCloseable {
.write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__RECORD,
FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STARTED, mSegmentId, 0);
synchronized (mIsStopped) {
synchronized (mIsStoppedLock) {
int result = nativeStartDvr();
if (result == Tuner.RESULT_SUCCESS) {
mIsStopped = false;
@ -170,7 +173,7 @@ public class DvrRecorder implements AutoCloseable {
.write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__RECORD,
FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STOPPED, mSegmentId, mOverflow);
synchronized (mIsStopped) {
synchronized (mIsStoppedLock) {
int result = nativeStopDvr();
if (result == Tuner.RESULT_SUCCESS) {
mIsStopped = true;
@ -188,7 +191,7 @@ public class DvrRecorder implements AutoCloseable {
*/
@Result
public int flush() {
synchronized (mIsStopped) {
synchronized (mIsStoppedLock) {
if (mIsStopped) {
return nativeFlushDvr();
}

View File

@ -230,7 +230,7 @@ class MtpPropertyGroup {
case MtpConstants.PROPERTY_PERSISTENT_UID:
// The persistent uid must be unique and never reused among all objects,
// and remain the same between sessions.
long puid = (object.getPath().toString().hashCode() << 32)
long puid = (((long) object.getPath().toString().hashCode()) << 32)
+ object.getModifiedTime();
list.append(id, property.code, property.type, puid);
break;

View File

@ -486,11 +486,9 @@ public class EffectFactory {
private Effect instantiateEffect(Class effectClass, String name) {
// Make sure this is an Effect subclass
try {
effectClass.asSubclass(Effect.class);
} catch (ClassCastException e) {
if (!Effect.class.isAssignableFrom(effectClass)) {
throw new IllegalArgumentException("Attempting to allocate effect '" + effectClass
+ "' which is not a subclass of Effect!", e);
+ "' which is not a subclass of Effect!");
}
// Look for the correct constructor

View File

@ -90,9 +90,7 @@ public abstract class Filter {
return false;
}
// Then make sure it's a subclass of Filter.
try {
filterClass.asSubclass(Filter.class);
} catch (ClassCastException e) {
if (!Filter.class.isAssignableFrom(filterClass)) {
return false;
}
return true;

View File

@ -112,9 +112,7 @@ public class FilterFactory {
public Filter createFilterByClass(Class filterClass, String filterName) {
// Make sure this is a Filter subclass
try {
filterClass.asSubclass(Filter.class);
} catch (ClassCastException e) {
if (!Filter.class.isAssignableFrom(filterClass)) {
throw new IllegalArgumentException("Attempting to allocate class '" + filterClass
+ "' which is not a subclass of Filter!");
}

View File

@ -55,12 +55,12 @@ public class KeyValueMap extends HashMap<String, Object> {
public int getInt(String key) {
Object result = get(key);
return result != null ? (Integer)result : null;
return result != null ? (Integer) result : 0;
}
public float getFloat(String key) {
Object result = get(key);
return result != null ? (Float)result : null;
return result != null ? (Float) result : 0;
}
@Override

View File

@ -296,7 +296,7 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
mMemWriter.write("End Memory :" + mEndMemory + "\n");
}
} catch (Exception e) {
e.toString();
// TODO
}
}

View File

@ -264,8 +264,14 @@ public class CameraMetadataTest extends junit.framework.TestCase {
builder.append("**");
}
if (elem instanceof Number) {
builder.append(String.format("%x", elem));
if (elem instanceof Byte) {
builder.append(String.format("%x", (Byte) elem));
} else if (elem instanceof Short) {
builder.append(String.format("%x", (Short) elem));
} else if (elem instanceof Integer) {
builder.append(String.format("%x", (Integer) elem));
} else if (elem instanceof Long) {
builder.append(String.format("%x", (Long) elem));
} else {
builder.append(elem);
}

View File

@ -18,7 +18,7 @@ package com.android.mediaframeworktest.unit;
import android.media.MediaPlayer;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;;
import android.test.suitebuilder.annotation.LargeTest;
/**
* Unit test class to test the set of valid and invalid states that

View File

@ -193,6 +193,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
initUI();
}
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
@Override
protected void onNewIntent(Intent intent) {
// Handle another incoming request (while we are not done with the original - mRequest -

View File

@ -55,18 +55,15 @@ public class CloudPrintPlugin implements PrintServicePlugin {
private static final String PRIVET_SERVICE = "_privet._tcp";
/** The required mDNS service types */
private static final Set<String> PRINTER_SERVICE_TYPE = new HashSet<String>() {{
// Not checking _printer_._sub
add(PRIVET_SERVICE);
}};
private static final Set<String> PRINTER_SERVICE_TYPE = Set.of(
PRIVET_SERVICE); // Not checking _printer_._sub
/** All possible connection states */
private static final Set<String> POSSIBLE_CONNECTION_STATES = new HashSet<String>() {{
add("online");
add("offline");
add("connecting");
add("not-configured");
}};
private static final Set<String> POSSIBLE_CONNECTION_STATES = Set.of(
"online",
"offline",
"connecting",
"not-configured");
private static final byte SUPPORTED_TXTVERS = '1';

View File

@ -37,9 +37,7 @@ import java.util.Set;
public class MDNSFilterPlugin implements PrintServicePlugin {
/** The mDNS service types supported */
private static final Set<String> PRINTER_SERVICE_TYPES = new HashSet<String>() {{
add("_ipp._tcp");
}};
private static final Set<String> PRINTER_SERVICE_TYPES = Set.of("_ipp._tcp");
/**
* The printer filter for {@link MDNSFilteredDiscovery} passing only mDNS results

View File

@ -23,7 +23,6 @@ import android.util.Log;
import com.android.printservice.recommendation.util.MDNSFilteredDiscovery;
import com.android.printservice.recommendation.util.MDNSUtils;
import java.util.HashSet;
import java.util.Set;
/**
@ -32,10 +31,7 @@ import java.util.Set;
class PrinterFilterMopria implements MDNSFilteredDiscovery.PrinterFilter {
private static final String TAG = "PrinterFilterMopria";
static final Set<String> MOPRIA_MDNS_SERVICES = new HashSet<String>() {{
add("_ipp._tcp");
add("_ipps._tcp");
}};
static final Set<String> MOPRIA_MDNS_SERVICES = Set.of("_ipp._tcp", "_ipps._tcp");
private static final String PDL__PDF = "application/pdf";
private static final String PDL__PCLM = "application/PCLm";

View File

@ -25,7 +25,6 @@ import androidx.annotation.NonNull;
import com.android.printservice.recommendation.util.MDNSFilteredDiscovery;
import com.android.printservice.recommendation.util.MDNSUtils;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -36,9 +35,7 @@ import java.util.Set;
class PrinterFilterSamsung implements MDNSFilteredDiscovery.PrinterFilter {
private static final String TAG = "PrinterFilterSamsung";
static final Set<String> SAMSUNG_MDNS_SERVICES = new HashSet<String>() {{
add("_pdl-datastream._tcp");
}};
static final Set<String> SAMSUNG_MDNS_SERVICES = Set.of("_pdl-datastream._tcp");
private static final String[] NOT_SUPPORTED_MODELS = new String[]{
"SCX-5x15",
@ -57,9 +54,7 @@ class PrinterFilterSamsung implements MDNSFilteredDiscovery.PrinterFilter {
private static final String ATTR_PRODUCT = "product";
private static final String ATTR_TY = "ty";
private static Set<String> SAMUNG_VENDOR_SET = new HashSet<String>() {{
add("samsung");
}};
private static final Set<String> SAMUNG_VENDOR_SET = Set.of("samsung");
@Override
public boolean matchesCriteria(NsdServiceInfo nsdServiceInfo) {

View File

@ -29,10 +29,11 @@ import java.util.HashSet;
import java.util.Set;
public class SamsungRecommendationPlugin implements PrintServicePlugin {
private static final Set<String> ALL_MDNS_SERVICES = new HashSet<String>() {{
addAll(PrinterFilterMopria.MOPRIA_MDNS_SERVICES);
addAll(PrinterFilterSamsung.SAMSUNG_MDNS_SERVICES);
}};
private static final Set<String> ALL_MDNS_SERVICES = new HashSet<String>();
static {
ALL_MDNS_SERVICES.addAll(PrinterFilterMopria.MOPRIA_MDNS_SERVICES);
ALL_MDNS_SERVICES.addAll(PrinterFilterSamsung.SAMSUNG_MDNS_SERVICES);
}
private final @NonNull Context mContext;
private final @NonNull MDNSFilteredDiscovery mMDNSFilteredDiscovery;

View File

@ -402,7 +402,7 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis
@Override
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
if ((isOptionsClosed() || isOptionsClosed()) && dy <= 0) {
if (isOptionsClosed() && dy <= 0) {
return;
}

View File

@ -82,4 +82,4 @@ public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {
Log.e(TAG, "localBluetoothAdapter is NULL!!");
}
}
};
}

View File

@ -50,13 +50,12 @@ public class ExtensionFragmentListener<T extends FragmentBase> implements Consum
@Override
public void accept(T extension) {
try {
Fragment.class.cast(extension);
if (Fragment.class.isInstance(extension)) {
mFragmentHostManager.getExtensionManager().setCurrentExtension(mId, mTag,
mOldClass, extension.getClass().getName(), mExtension.getContext());
mOldClass = extension.getClass().getName();
} catch (ClassCastException e) {
Log.e(TAG, extension.getClass().getName() + " must be a Fragment", e);
} else {
Log.e(TAG, extension.getClass().getName() + " must be a Fragment");
}
mExtension.clearItem(true);
}

View File

@ -1093,7 +1093,7 @@ public class PeopleTileViewHelper {
Pair<Integer, Integer> first = emojiIndices.get(i - 1);
// Check if second emoji starts right after first starts
if (second.first == first.second) {
if (Objects.equals(second.first, first.second)) {
// Check if emojis in sequence are the same
if (Objects.equals(emojiTexts.get(i), emojiTexts.get(i - 1))) {
if (DEBUG) {

View File

@ -56,6 +56,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import javax.inject.Inject;
@ -592,7 +593,7 @@ public class NotificationLogger implements StateListener {
return;
}
if (loggedExpansionState != null
&& state.mIsExpanded == loggedExpansionState) {
&& Objects.equals(state.mIsExpanded, loggedExpansionState)) {
return;
}
mLoggedExpansionState.put(key, state.mIsExpanded);

View File

@ -65,7 +65,7 @@ public class ImageExporterTest extends SysuiTestCase {
private static final byte[] EXIF_FILE_TAG = "Exif\u0000\u0000".getBytes(US_ASCII);
private static final ZonedDateTime CAPTURE_TIME =
ZonedDateTime.of(LocalDateTime.of(2020, 12, 15, 13, 15), ZoneId.of("EST"));
ZonedDateTime.of(LocalDateTime.of(2020, 12, 15, 13, 15), ZoneId.of("America/New_York"));
@Test
public void testImageFilename() {

View File

@ -245,6 +245,7 @@ final class RemoteAugmentedAutofillService
});
}
@SuppressWarnings("ReturnValueIgnored")
private void maybeRequestShowInlineSuggestions(int sessionId,
@Nullable InlineSuggestionsRequest request,
@Nullable List<Dataset> inlineSuggestionsData, @Nullable Bundle clientState,

View File

@ -153,4 +153,4 @@ public interface OperationStorage {
* @return a set of operation tokens for operations in that state.
*/
Set<Integer> operationTokensForOpState(@OpState int state);
};
}

View File

@ -353,4 +353,4 @@ public class LifecycleOperationStorage implements OperationStorage {
op.callback.handleCancel(cancelAll);
}
}
};
}

View File

@ -657,7 +657,6 @@ public final class ContentCaptureManagerService extends
int sessionId, int flags, @NonNull IResultReceiver result) {
Objects.requireNonNull(activityToken);
Objects.requireNonNull(shareableActivityToken);
Objects.requireNonNull(sessionId);
final int userId = UserHandle.getCallingUserId();
final ActivityPresentationInfo activityPresentationInfo = getAmInternal()
@ -676,7 +675,6 @@ public final class ContentCaptureManagerService extends
@Override
public void finishSession(int sessionId) {
Objects.requireNonNull(sessionId);
final int userId = UserHandle.getCallingUserId();
synchronized (mLock) {

View File

@ -7551,7 +7551,6 @@ public class AppOpsService extends IAppOpsService.Stub {
Objects.requireNonNull(stackTrace);
Preconditions.checkArgument(op >= 0);
Preconditions.checkArgument(op < AppOpsManager._NUM_OP);
Objects.requireNonNull(version);
NoteOpTrace noteOpTrace = new NoteOpTrace(stackTrace, op, packageName, version);

View File

@ -25,7 +25,7 @@ enum FrequencyBand {
AM_LW,
AM_MW,
AM_SW,
};
}
class Utils {
private static final String TAG = "BcRadio2Srv.utils";

View File

@ -20,6 +20,8 @@ import static com.android.server.hdmi.Constants.ADDR_BACKUP_1;
import static com.android.server.hdmi.Constants.ADDR_BACKUP_2;
import static com.android.server.hdmi.Constants.ADDR_TV;
import static java.util.Map.entry;
import android.annotation.Nullable;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
@ -45,7 +47,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -57,38 +58,34 @@ final class HdmiUtils {
private static final String TAG = "HdmiUtils";
private static final Map<Integer, List<Integer>> ADDRESS_TO_TYPE =
new HashMap<Integer, List<Integer>>() {
{
put(Constants.ADDR_TV, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TV));
put(Constants.ADDR_RECORDER_1,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_RECORDER));
put(Constants.ADDR_RECORDER_2,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_RECORDER));
put(Constants.ADDR_TUNER_1, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER));
put(Constants.ADDR_PLAYBACK_1,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK));
put(Constants.ADDR_AUDIO_SYSTEM,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM));
put(Constants.ADDR_TUNER_2, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER));
put(Constants.ADDR_TUNER_3, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER));
put(Constants.ADDR_PLAYBACK_2,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK));
put(Constants.ADDR_RECORDER_3,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_RECORDER));
put(Constants.ADDR_TUNER_4, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER));
put(Constants.ADDR_PLAYBACK_3,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK));
put(Constants.ADDR_BACKUP_1, Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK,
HdmiDeviceInfo.DEVICE_RECORDER, HdmiDeviceInfo.DEVICE_TUNER,
HdmiDeviceInfo.DEVICE_VIDEO_PROCESSOR));
put(Constants.ADDR_BACKUP_2, Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK,
HdmiDeviceInfo.DEVICE_RECORDER, HdmiDeviceInfo.DEVICE_TUNER,
HdmiDeviceInfo.DEVICE_VIDEO_PROCESSOR));
put(Constants.ADDR_SPECIFIC_USE, Lists.newArrayList(ADDR_TV));
put(Constants.ADDR_UNREGISTERED, Collections.emptyList());
}
};
private static final Map<Integer, List<Integer>> ADDRESS_TO_TYPE = Map.ofEntries(
entry(Constants.ADDR_TV, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TV)),
entry(Constants.ADDR_RECORDER_1,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_RECORDER)),
entry(Constants.ADDR_RECORDER_2,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_RECORDER)),
entry(Constants.ADDR_TUNER_1, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER)),
entry(Constants.ADDR_PLAYBACK_1,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK)),
entry(Constants.ADDR_AUDIO_SYSTEM,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM)),
entry(Constants.ADDR_TUNER_2, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER)),
entry(Constants.ADDR_TUNER_3, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER)),
entry(Constants.ADDR_PLAYBACK_2,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK)),
entry(Constants.ADDR_RECORDER_3,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_RECORDER)),
entry(Constants.ADDR_TUNER_4, Lists.newArrayList(HdmiDeviceInfo.DEVICE_TUNER)),
entry(Constants.ADDR_PLAYBACK_3,
Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK)),
entry(Constants.ADDR_BACKUP_1, Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK,
HdmiDeviceInfo.DEVICE_RECORDER, HdmiDeviceInfo.DEVICE_TUNER,
HdmiDeviceInfo.DEVICE_VIDEO_PROCESSOR)),
entry(Constants.ADDR_BACKUP_2, Lists.newArrayList(HdmiDeviceInfo.DEVICE_PLAYBACK,
HdmiDeviceInfo.DEVICE_RECORDER, HdmiDeviceInfo.DEVICE_TUNER,
HdmiDeviceInfo.DEVICE_VIDEO_PROCESSOR)),
entry(Constants.ADDR_SPECIFIC_USE, Lists.newArrayList(ADDR_TV)),
entry(Constants.ADDR_UNREGISTERED, Collections.emptyList()));
private static final String[] DEFAULT_NAMES = {
"TV",

View File

@ -1799,8 +1799,8 @@ public class InputManagerService extends IInputManager.Stub
*/
public boolean transferTouchFocus(@NonNull IBinder fromChannelToken,
@NonNull IBinder toChannelToken) {
Objects.nonNull(fromChannelToken);
Objects.nonNull(toChannelToken);
Objects.requireNonNull(fromChannelToken);
Objects.requireNonNull(toChannelToken);
return mNative.transferTouchFocus(fromChannelToken, toChannelToken,
false /* isDragDrop */);
}

View File

@ -519,9 +519,9 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override
public String toString() {
StringBuilder sb = new StringBuilder(100);
TransactionRecord[] arr;
ContextHubServiceTransaction[] arr;
synchronized (this) {
arr = mTransactionQueue.toArray(new TransactionRecord[0]);
arr = mTransactionQueue.toArray(new ContextHubServiceTransaction[0]);
}
for (int i = 0; i < arr.length; i++) {
sb.append(i + ": " + arr[i] + "\n");

View File

@ -260,26 +260,24 @@ public class GnssConfiguration {
Log.e(TAG, "Unable to set " + CONFIG_ES_EXTENSION_SEC + ": " + mEsExtensionSec);
}
Map<String, SetCarrierProperty> map = new HashMap<String, SetCarrierProperty>() {
{
put(CONFIG_SUPL_VER, GnssConfiguration::native_set_supl_version);
put(CONFIG_SUPL_MODE, GnssConfiguration::native_set_supl_mode);
Map<String, SetCarrierProperty> map = new HashMap<String, SetCarrierProperty>();
if (isConfigSuplEsSupported(gnssConfigurationIfaceVersion)) {
put(CONFIG_SUPL_ES, GnssConfiguration::native_set_supl_es);
}
map.put(CONFIG_SUPL_VER, GnssConfiguration::native_set_supl_version);
map.put(CONFIG_SUPL_MODE, GnssConfiguration::native_set_supl_mode);
put(CONFIG_LPP_PROFILE, GnssConfiguration::native_set_lpp_profile);
put(CONFIG_A_GLONASS_POS_PROTOCOL_SELECT,
GnssConfiguration::native_set_gnss_pos_protocol_select);
put(CONFIG_USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL,
GnssConfiguration::native_set_emergency_supl_pdn);
if (isConfigSuplEsSupported(gnssConfigurationIfaceVersion)) {
map.put(CONFIG_SUPL_ES, GnssConfiguration::native_set_supl_es);
}
if (isConfigGpsLockSupported(gnssConfigurationIfaceVersion)) {
put(CONFIG_GPS_LOCK, GnssConfiguration::native_set_gps_lock);
}
}
};
map.put(CONFIG_LPP_PROFILE, GnssConfiguration::native_set_lpp_profile);
map.put(CONFIG_A_GLONASS_POS_PROTOCOL_SELECT,
GnssConfiguration::native_set_gnss_pos_protocol_select);
map.put(CONFIG_USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL,
GnssConfiguration::native_set_emergency_supl_pdn);
if (isConfigGpsLockSupported(gnssConfigurationIfaceVersion)) {
map.put(CONFIG_GPS_LOCK, GnssConfiguration::native_set_gps_lock);
}
for (Entry<String, SetCarrierProperty> entry : map.entrySet()) {
String propertyName = entry.getKey();

View File

@ -852,7 +852,9 @@ public class PreferencesHelper implements RankingConfig {
Objects.requireNonNull(pkg);
Objects.requireNonNull(group);
Objects.requireNonNull(group.getId());
Objects.requireNonNull(!TextUtils.isEmpty(group.getName()));
if (TextUtils.isEmpty(group.getName())) {
throw new IllegalArgumentException("group.getName() can't be empty");
}
boolean needsDndChange = false;
synchronized (mPackagePreferences) {
PackagePreferences r = getOrCreatePackagePreferencesLocked(pkg, uid);

View File

@ -16,7 +16,7 @@
package com.android.server.pm;
import android.annotation.NonNull;;
import android.annotation.NonNull;
import android.text.TextUtils;
import com.android.internal.util.HexDump;

View File

@ -295,6 +295,7 @@ public final class DexoptUtils {
* NOTE: Keep this in sync with the dexopt expectations! Right now that is either "PCL[path]"
* for a PathClassLoader or "DLC[path]" for a DelegateLastClassLoader.
*/
@SuppressWarnings("ReturnValueIgnored")
/*package*/ static String encodeClassLoader(String classpath, String classLoaderName) {
classpath.getClass(); // Throw NPE if classpath is null
String classLoaderDexoptEncoding = classLoaderName;

View File

@ -86,6 +86,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
@ -1924,7 +1925,7 @@ final class DefaultPermissionGrantPolicy {
mPkgRequestingPerm, newRestrictionExcemptFlags, -1, mUser);
}
if (newGranted != null && newGranted != mOriginalGranted) {
if (newGranted != null && !Objects.equals(newGranted, mOriginalGranted)) {
if (newGranted) {
NO_PM_CACHE.grantPermission(mPermission, mPkgRequestingPerm, mUser);
} else {

View File

@ -1888,12 +1888,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
}
}
private static final HashMap<Integer, String> sWallpaperType = new HashMap<Integer, String>() {
{
put(FLAG_SYSTEM, RECORD_FILE);
put(FLAG_LOCK, RECORD_LOCK_FILE);
}
};
private static final Map<Integer, String> sWallpaperType = Map.of(
FLAG_SYSTEM, RECORD_FILE,
FLAG_LOCK, RECORD_LOCK_FILE);
private void errorCheck(int userID) {
sWallpaperType.forEach((type, filename) -> {

View File

@ -436,11 +436,12 @@ class DisplayWindowSettings {
mRemoveContentMode = other.mRemoveContentMode;
changed = true;
}
if (other.mShouldShowWithInsecureKeyguard != mShouldShowWithInsecureKeyguard) {
if (!Objects.equals(
other.mShouldShowWithInsecureKeyguard, mShouldShowWithInsecureKeyguard)) {
mShouldShowWithInsecureKeyguard = other.mShouldShowWithInsecureKeyguard;
changed = true;
}
if (other.mShouldShowSystemDecors != mShouldShowSystemDecors) {
if (!Objects.equals(other.mShouldShowSystemDecors, mShouldShowSystemDecors)) {
mShouldShowSystemDecors = other.mShouldShowSystemDecors;
changed = true;
}
@ -452,15 +453,15 @@ class DisplayWindowSettings {
mFixedToUserRotation = other.mFixedToUserRotation;
changed = true;
}
if (other.mIgnoreOrientationRequest != mIgnoreOrientationRequest) {
if (!Objects.equals(other.mIgnoreOrientationRequest, mIgnoreOrientationRequest)) {
mIgnoreOrientationRequest = other.mIgnoreOrientationRequest;
changed = true;
}
if (other.mIgnoreDisplayCutout != mIgnoreDisplayCutout) {
if (!Objects.equals(other.mIgnoreDisplayCutout, mIgnoreDisplayCutout)) {
mIgnoreDisplayCutout = other.mIgnoreDisplayCutout;
changed = true;
}
if (other.mDontMoveToTop != mDontMoveToTop) {
if (!Objects.equals(other.mDontMoveToTop, mDontMoveToTop)) {
mDontMoveToTop = other.mDontMoveToTop;
changed = true;
}
@ -516,14 +517,13 @@ class DisplayWindowSettings {
mRemoveContentMode = delta.mRemoveContentMode;
changed = true;
}
if (delta.mShouldShowWithInsecureKeyguard != null
&& delta.mShouldShowWithInsecureKeyguard
!= mShouldShowWithInsecureKeyguard) {
if (delta.mShouldShowWithInsecureKeyguard != null && !Objects.equals(
delta.mShouldShowWithInsecureKeyguard, mShouldShowWithInsecureKeyguard)) {
mShouldShowWithInsecureKeyguard = delta.mShouldShowWithInsecureKeyguard;
changed = true;
}
if (delta.mShouldShowSystemDecors != null
&& delta.mShouldShowSystemDecors != mShouldShowSystemDecors) {
if (delta.mShouldShowSystemDecors != null && !Objects.equals(
delta.mShouldShowSystemDecors, mShouldShowSystemDecors)) {
mShouldShowSystemDecors = delta.mShouldShowSystemDecors;
changed = true;
}
@ -537,18 +537,18 @@ class DisplayWindowSettings {
mFixedToUserRotation = delta.mFixedToUserRotation;
changed = true;
}
if (delta.mIgnoreOrientationRequest != null
&& delta.mIgnoreOrientationRequest != mIgnoreOrientationRequest) {
if (delta.mIgnoreOrientationRequest != null && !Objects.equals(
delta.mIgnoreOrientationRequest, mIgnoreOrientationRequest)) {
mIgnoreOrientationRequest = delta.mIgnoreOrientationRequest;
changed = true;
}
if (delta.mIgnoreDisplayCutout != null
&& delta.mIgnoreDisplayCutout != mIgnoreDisplayCutout) {
if (delta.mIgnoreDisplayCutout != null && !Objects.equals(
delta.mIgnoreDisplayCutout, mIgnoreDisplayCutout)) {
mIgnoreDisplayCutout = delta.mIgnoreDisplayCutout;
changed = true;
}
if (delta.mDontMoveToTop != null
&& delta.mDontMoveToTop != mDontMoveToTop) {
if (delta.mDontMoveToTop != null && !Objects.equals(
delta.mDontMoveToTop, mDontMoveToTop)) {
mDontMoveToTop = delta.mDontMoveToTop;
changed = true;
}

View File

@ -21,7 +21,7 @@ import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST;
import static android.os.Process.myTid;
import static android.os.Process.setThreadPriority;
import static com.android.server.LockGuard.INDEX_WINDOW;;
import static com.android.server.LockGuard.INDEX_WINDOW;
import com.android.internal.annotations.GuardedBy;
import com.android.server.AnimationThread;

View File

@ -53,6 +53,7 @@ import com.android.server.people.data.DataManager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
/**
@ -372,7 +373,8 @@ public class PeopleService extends SystemService {
@Override
public boolean equals(Object o) {
ListenerKey key = (ListenerKey) o;
return key.getPackageName().equals(mPackageName) && key.getUserId() == mUserId
return key.getPackageName().equals(mPackageName)
&& Objects.equals(key.getUserId(), mUserId)
&& key.getShortcutId().equals(mShortcutId);
}

View File

@ -30,7 +30,7 @@ import android.hardware.camera2.CameraMetadata;
import android.view.Display;
import android.view.Surface;
import java.util.HashMap;
import java.util.Map;
@RunWith(JUnit4.class)
public class CameraServiceProxyTest {
@ -75,24 +75,22 @@ public class CameraServiceProxyTest {
/*ignoreResizableAndSdkCheck*/true)).isEqualTo(
CameraMetadata.SCALER_ROTATE_AND_CROP_NONE);
// Check rotation and lens facing combinations
HashMap<Integer, Integer> backFacingMap = new HashMap<Integer, Integer>() {{
put(Surface.ROTATION_0, CameraMetadata.SCALER_ROTATE_AND_CROP_NONE);
put(Surface.ROTATION_90, CameraMetadata.SCALER_ROTATE_AND_CROP_90);
put(Surface.ROTATION_270, CameraMetadata.SCALER_ROTATE_AND_CROP_270);
put(Surface.ROTATION_180, CameraMetadata.SCALER_ROTATE_AND_CROP_180);
}};
Map<Integer, Integer> backFacingMap = Map.of(
Surface.ROTATION_0, CameraMetadata.SCALER_ROTATE_AND_CROP_NONE,
Surface.ROTATION_90, CameraMetadata.SCALER_ROTATE_AND_CROP_90,
Surface.ROTATION_270, CameraMetadata.SCALER_ROTATE_AND_CROP_270,
Surface.ROTATION_180, CameraMetadata.SCALER_ROTATE_AND_CROP_180);
taskInfo.isFixedOrientationPortrait = true;
backFacingMap.forEach((key, value) -> {
assertThat(CameraServiceProxy.getCropRotateScale(ctx, ctx.getPackageName(), taskInfo,
key, CameraCharacteristics.LENS_FACING_BACK,
/*ignoreResizableAndSdkCheck*/true)).isEqualTo(value);
});
HashMap<Integer, Integer> frontFacingMap = new HashMap<Integer, Integer>() {{
put(Surface.ROTATION_0, CameraMetadata.SCALER_ROTATE_AND_CROP_NONE);
put(Surface.ROTATION_90, CameraMetadata.SCALER_ROTATE_AND_CROP_270);
put(Surface.ROTATION_270, CameraMetadata.SCALER_ROTATE_AND_CROP_90);
put(Surface.ROTATION_180, CameraMetadata.SCALER_ROTATE_AND_CROP_180);
}};
Map<Integer, Integer> frontFacingMap = Map.of(
Surface.ROTATION_0, CameraMetadata.SCALER_ROTATE_AND_CROP_NONE,
Surface.ROTATION_90, CameraMetadata.SCALER_ROTATE_AND_CROP_270,
Surface.ROTATION_270, CameraMetadata.SCALER_ROTATE_AND_CROP_90,
Surface.ROTATION_180, CameraMetadata.SCALER_ROTATE_AND_CROP_180);
frontFacingMap.forEach((key, value) -> {
assertThat(CameraServiceProxy.getCropRotateScale(ctx, ctx.getPackageName(), taskInfo,
key, CameraCharacteristics.LENS_FACING_FRONT,

View File

@ -424,7 +424,7 @@ public class AmbientBrightnessStatsTrackerTest {
@Override
public LocalDate getLocalDate() {
return LocalDate.from(mLocalDate);
return mLocalDate;
}
}

View File

@ -367,6 +367,7 @@ public class InputMethodSubtypeSwitchingControllerTest {
assertFalse(item_en_us_allcaps.mIsSystemLocale);
}
@SuppressWarnings("SelfComparison")
@Test
public void testImeSubtypeListComparator() throws Exception {
final ComponentName imeX1 = new ComponentName("com.example.imeX", "Ime1");

View File

@ -58,4 +58,4 @@ public class PasswordSlotManagerTestable extends PasswordSlotManager {
} catch (Exception e) {
}
}
};
}

View File

@ -2727,7 +2727,7 @@ public class PreferencesHelperTest extends UiServiceTestCase {
@Test
public void testCreateChannel_addToGroup() {
NotificationChannelGroup group = new NotificationChannelGroup("group", "");
NotificationChannelGroup group = new NotificationChannelGroup("group", "group");
mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, group, true);
NotificationChannel nc = new NotificationChannel("id", "hello", IMPORTANCE_DEFAULT);
assertTrue(mHelper.createNotificationChannel(PKG_N_MR1, UID_N_MR1, nc, true, false));
@ -3177,8 +3177,8 @@ public class PreferencesHelperTest extends UiServiceTestCase {
@Test
public void testGetNotificationChannelGroupWithChannels() throws Exception {
NotificationChannelGroup group = new NotificationChannelGroup("group", "");
NotificationChannelGroup other = new NotificationChannelGroup("something else", "");
NotificationChannelGroup group = new NotificationChannelGroup("group", "group");
NotificationChannelGroup other = new NotificationChannelGroup("something else", "name");
mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, group, true);
mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, other, true);

View File

@ -46,4 +46,4 @@ public final class UsbVCInputTerminal extends UsbVCInterface {
// TODO Add reporting specific to this descriptor
super.report(canvas);
}
};
}

View File

@ -46,4 +46,4 @@ public final class UsbVCOutputTerminal extends UsbVCInterface {
super.report(canvas);
// TODO Add reporting specific to this descriptor
}
};
}

View File

@ -47,4 +47,4 @@ public final class UsbVCProcessingUnit extends UsbVCInterface {
super.report(canvas);
// TODO Add reporting specific to this descriptor
}
};
}

View File

@ -47,4 +47,4 @@ public final class UsbVCSelectorUnit extends UsbVCInterface {
super.report(canvas);
// TODO Add reporting specific to this descriptor
}
};
}

View File

@ -1196,4 +1196,4 @@ final class HotwordDetectionConnection {
private static final String OP_MESSAGE =
"Providing hotword detection result to VoiceInteractionService";
};
}

Some files were not shown because too many files have changed in this diff Show More