Merge "[conflict] Merge "Fix errorprone warnings that should be errors" am: 677d6cd780 am: f9df26ae3c am: d3c499dabc"
This commit is contained in:
@@ -2328,10 +2328,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;
|
||||
@@ -6515,15 +6514,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;
|
||||
}
|
||||
@@ -6533,7 +6534,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];
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
@@ -4836,12 +4837,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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -2507,6 +2507,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.
|
||||
|
||||
@@ -28,6 +28,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;
|
||||
@@ -48,7 +49,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);
|
||||
@@ -178,7 +181,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;
|
||||
@@ -201,7 +204,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;
|
||||
@@ -219,7 +222,7 @@ public class DvrRecorder implements AutoCloseable {
|
||||
*/
|
||||
@Result
|
||||
public int flush() {
|
||||
synchronized (mIsStopped) {
|
||||
synchronized (mIsStoppedLock) {
|
||||
if (mIsStopped) {
|
||||
return nativeFlushDvr();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user