Skip to content

Commit 5bb86b9

Browse files
Deprecate old API and delegate to deprecated method
1 parent bcd5854 commit 5bb86b9

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

libraries/session/src/main/java/androidx/media3/session/MediaButtonReceiver.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,21 @@ protected boolean shouldStartForegroundService(Context context, Intent intent) {
226226
return true;
227227
}
228228

229+
/**
230+
* @deprecated Use {@link #onForegroundServiceStartNotAllowedException(Context, Intent,
231+
* ForegroundServiceStartNotAllowedException)} instead.
232+
*/
233+
@Deprecated
234+
@RequiresApi(31)
235+
protected void onForegroundServiceStartNotAllowedException(
236+
Intent intent, ForegroundServiceStartNotAllowedException e) {
237+
Log.e(
238+
TAG,
239+
"caught exception when trying to start a foreground service from the "
240+
+ "background: "
241+
+ e.getMessage());
242+
}
243+
229244
/**
230245
* This method is called when an exception is thrown when calling {@link
231246
* Context#startForegroundService(Intent)} as a result of receiving a media button event.
@@ -254,14 +269,11 @@ protected boolean shouldStartForegroundService(Context context, Intent intent) {
254269
* starting the foreground service}.
255270
* @param e The exception thrown by the system and caught by this broadcast receiver.
256271
*/
272+
@SuppressWarnings("deprecation")
257273
@RequiresApi(31)
258274
protected void onForegroundServiceStartNotAllowedException(
259275
Context context, Intent intent, ForegroundServiceStartNotAllowedException e) {
260-
Log.e(
261-
TAG,
262-
"caught exception when trying to start a foreground service from the "
263-
+ "background: "
264-
+ e.getMessage());
276+
onForegroundServiceStartNotAllowedException(intent, e);
265277
}
266278

267279
@SuppressWarnings("QueryPermissionsNeeded") // Needs to be provided in the app manifest.

0 commit comments

Comments
 (0)