Loading media/java/android/media/CallbackDataSourceDesc.java +1 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package android.media; import android.annotation.NonNull; import com.android.internal.util.Preconditions; /** * @hide * Structure for file data source descriptor. Loading Loading @@ -105,7 +103,7 @@ public class CallbackDataSourceDesc extends DataSourceDesc { * @throws NullPointerException if m2ds is null. */ public @NonNull Builder setDataSource(@NonNull Media2DataSource m2ds) { Preconditions.checkNotNull(m2ds); Media2Utils.checkArgument(m2ds != null, "data source cannot be null."); mMedia2DataSource = m2ds; return this; } Loading media/java/android/media/DataSourceDesc.java +1 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package android.media; import android.annotation.NonNull; import com.android.internal.util.Preconditions; /** * @hide * Base class of data source descriptor. Loading Loading @@ -118,7 +116,7 @@ public class DataSourceDesc { * @return the same instance of subclass of {@link DataSourceDesc} */ void build(@NonNull DataSourceDesc dsd) { Preconditions.checkNotNull(dsd); Media2Utils.checkArgument(dsd != null, "dsd cannot be null."); if (mStartPositionMs > mEndPositionMs) { throw new IllegalStateException("Illegal start/end position: " Loading media/java/android/media/FileDataSourceDesc.java +2 −4 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package android.media; import android.annotation.NonNull; import com.android.internal.util.Preconditions; import java.io.FileDescriptor; /** Loading Loading @@ -141,7 +139,7 @@ public class FileDataSourceDesc extends DataSourceDesc { * @throws NullPointerException if fd is null. */ public @NonNull Builder setDataSource(@NonNull FileDescriptor fd) { Preconditions.checkNotNull(fd); Media2Utils.checkArgument(fd != null, "fd cannot be null."); resetDataSource(); mFD = fd; return this; Loading @@ -163,7 +161,7 @@ public class FileDataSourceDesc extends DataSourceDesc { */ public @NonNull Builder setDataSource( @NonNull FileDescriptor fd, long offset, long length) { Preconditions.checkNotNull(fd); Media2Utils.checkArgument(fd != null, "fd cannot be null."); if (offset < 0) { offset = 0; } Loading media/java/android/media/Media2Utils.java +14 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,20 @@ public class Media2Utils { private Media2Utils() { } /** * Ensures that an expression checking an argument is true. * * @param expression the expression to check * @param errorMessage the exception message to use if the check fails; will * be converted to a string using {@link String#valueOf(Object)} * @throws IllegalArgumentException if {@code expression} is false */ public static void checkArgument(boolean expression, String errorMessage) { if (!expression) { throw new IllegalArgumentException(errorMessage); } } public static synchronized void storeCookies(List<HttpCookie> cookies) { CookieHandler cookieHandler = CookieHandler.getDefault(); if (cookieHandler == null) { Loading media/java/android/media/MediaPlayer2.java +6 −12 Original line number Diff line number Diff line Loading @@ -693,7 +693,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_DATA_SOURCE, false) { @Override void process() throws IOException { checkArgument(dsd != null, "the DataSourceDesc cannot be null"); Media2Utils.checkArgument(dsd != null, "the DataSourceDesc cannot be null"); int state = getState(); if (state != PLAYER_STATE_ERROR && state != PLAYER_STATE_IDLE) { throw new IllegalStateException("called in wrong state " + state); Loading @@ -719,7 +719,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_NEXT_DATA_SOURCE, false) { @Override void process() { checkArgument(dsd != null, "the DataSourceDesc cannot be null"); Media2Utils.checkArgument(dsd != null, "the DataSourceDesc cannot be null"); synchronized (mSrcLock) { mNextSourceInfos.clear(); mNextSourceInfos.add(new SourceInfo(dsd)); Loading Loading @@ -788,7 +788,7 @@ public class MediaPlayer2 implements AutoCloseable private void handleDataSource(boolean isCurrent, @NonNull DataSourceDesc dsd, long srcId) throws IOException { checkArgument(dsd != null, "the DataSourceDesc cannot be null"); Media2Utils.checkArgument(dsd != null, "the DataSourceDesc cannot be null"); if (dsd instanceof CallbackDataSourceDesc) { CallbackDataSourceDesc cbDSD = (CallbackDataSourceDesc) dsd; Loading Loading @@ -1513,7 +1513,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_BUFFERING_PARAMS, false) { @Override void process() { checkArgument(params != null, "the BufferingParams cannot be null"); Media2Utils.checkArgument(params != null, "the BufferingParams cannot be null"); native_setBufferingParams(params); } }); Loading @@ -1536,7 +1536,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_PLAYBACK_PARAMS, false) { @Override void process() { checkArgument(params != null, "the PlaybackParams cannot be null"); Media2Utils.checkArgument(params != null, "the PlaybackParams cannot be null"); native_setPlaybackParams(params); } }); Loading Loading @@ -1564,7 +1564,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_SYNC_PARAMS, false) { @Override void process() { checkArgument(params != null, "the SyncParams cannot be null"); Media2Utils.checkArgument(params != null, "the SyncParams cannot be null"); native_setSyncParams(params); } }); Loading Loading @@ -2690,12 +2690,6 @@ public class MediaPlayer2 implements AutoCloseable } } private static void checkArgument(boolean expression, String errorMessage) { if (!expression) { throw new IllegalArgumentException(errorMessage); } } private void sendEvent(final EventNotifier notifier) { synchronized (mEventCbLock) { try { Loading Loading
media/java/android/media/CallbackDataSourceDesc.java +1 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package android.media; import android.annotation.NonNull; import com.android.internal.util.Preconditions; /** * @hide * Structure for file data source descriptor. Loading Loading @@ -105,7 +103,7 @@ public class CallbackDataSourceDesc extends DataSourceDesc { * @throws NullPointerException if m2ds is null. */ public @NonNull Builder setDataSource(@NonNull Media2DataSource m2ds) { Preconditions.checkNotNull(m2ds); Media2Utils.checkArgument(m2ds != null, "data source cannot be null."); mMedia2DataSource = m2ds; return this; } Loading
media/java/android/media/DataSourceDesc.java +1 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package android.media; import android.annotation.NonNull; import com.android.internal.util.Preconditions; /** * @hide * Base class of data source descriptor. Loading Loading @@ -118,7 +116,7 @@ public class DataSourceDesc { * @return the same instance of subclass of {@link DataSourceDesc} */ void build(@NonNull DataSourceDesc dsd) { Preconditions.checkNotNull(dsd); Media2Utils.checkArgument(dsd != null, "dsd cannot be null."); if (mStartPositionMs > mEndPositionMs) { throw new IllegalStateException("Illegal start/end position: " Loading
media/java/android/media/FileDataSourceDesc.java +2 −4 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package android.media; import android.annotation.NonNull; import com.android.internal.util.Preconditions; import java.io.FileDescriptor; /** Loading Loading @@ -141,7 +139,7 @@ public class FileDataSourceDesc extends DataSourceDesc { * @throws NullPointerException if fd is null. */ public @NonNull Builder setDataSource(@NonNull FileDescriptor fd) { Preconditions.checkNotNull(fd); Media2Utils.checkArgument(fd != null, "fd cannot be null."); resetDataSource(); mFD = fd; return this; Loading @@ -163,7 +161,7 @@ public class FileDataSourceDesc extends DataSourceDesc { */ public @NonNull Builder setDataSource( @NonNull FileDescriptor fd, long offset, long length) { Preconditions.checkNotNull(fd); Media2Utils.checkArgument(fd != null, "fd cannot be null."); if (offset < 0) { offset = 0; } Loading
media/java/android/media/Media2Utils.java +14 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,20 @@ public class Media2Utils { private Media2Utils() { } /** * Ensures that an expression checking an argument is true. * * @param expression the expression to check * @param errorMessage the exception message to use if the check fails; will * be converted to a string using {@link String#valueOf(Object)} * @throws IllegalArgumentException if {@code expression} is false */ public static void checkArgument(boolean expression, String errorMessage) { if (!expression) { throw new IllegalArgumentException(errorMessage); } } public static synchronized void storeCookies(List<HttpCookie> cookies) { CookieHandler cookieHandler = CookieHandler.getDefault(); if (cookieHandler == null) { Loading
media/java/android/media/MediaPlayer2.java +6 −12 Original line number Diff line number Diff line Loading @@ -693,7 +693,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_DATA_SOURCE, false) { @Override void process() throws IOException { checkArgument(dsd != null, "the DataSourceDesc cannot be null"); Media2Utils.checkArgument(dsd != null, "the DataSourceDesc cannot be null"); int state = getState(); if (state != PLAYER_STATE_ERROR && state != PLAYER_STATE_IDLE) { throw new IllegalStateException("called in wrong state " + state); Loading @@ -719,7 +719,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_NEXT_DATA_SOURCE, false) { @Override void process() { checkArgument(dsd != null, "the DataSourceDesc cannot be null"); Media2Utils.checkArgument(dsd != null, "the DataSourceDesc cannot be null"); synchronized (mSrcLock) { mNextSourceInfos.clear(); mNextSourceInfos.add(new SourceInfo(dsd)); Loading Loading @@ -788,7 +788,7 @@ public class MediaPlayer2 implements AutoCloseable private void handleDataSource(boolean isCurrent, @NonNull DataSourceDesc dsd, long srcId) throws IOException { checkArgument(dsd != null, "the DataSourceDesc cannot be null"); Media2Utils.checkArgument(dsd != null, "the DataSourceDesc cannot be null"); if (dsd instanceof CallbackDataSourceDesc) { CallbackDataSourceDesc cbDSD = (CallbackDataSourceDesc) dsd; Loading Loading @@ -1513,7 +1513,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_BUFFERING_PARAMS, false) { @Override void process() { checkArgument(params != null, "the BufferingParams cannot be null"); Media2Utils.checkArgument(params != null, "the BufferingParams cannot be null"); native_setBufferingParams(params); } }); Loading @@ -1536,7 +1536,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_PLAYBACK_PARAMS, false) { @Override void process() { checkArgument(params != null, "the PlaybackParams cannot be null"); Media2Utils.checkArgument(params != null, "the PlaybackParams cannot be null"); native_setPlaybackParams(params); } }); Loading Loading @@ -1564,7 +1564,7 @@ public class MediaPlayer2 implements AutoCloseable return addTask(new Task(CALL_COMPLETED_SET_SYNC_PARAMS, false) { @Override void process() { checkArgument(params != null, "the SyncParams cannot be null"); Media2Utils.checkArgument(params != null, "the SyncParams cannot be null"); native_setSyncParams(params); } }); Loading Loading @@ -2690,12 +2690,6 @@ public class MediaPlayer2 implements AutoCloseable } } private static void checkArgument(boolean expression, String errorMessage) { if (!expression) { throw new IllegalArgumentException(errorMessage); } } private void sendEvent(final EventNotifier notifier) { synchronized (mEventCbLock) { try { Loading