Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a28b3ef7
authored
Jul 29, 2022
by
bachinger
Committed by
tonihei
Aug 08, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add interface version of MediaSessionStub
PiperOrigin-RevId: 464052708
parent
3fae9df8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
116 additions
and
33 deletions
libraries/session/src/main/java/androidx/media3/session/ConnectionState.java
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplBase.java
libraries/session/src/main/java/androidx/media3/session/MediaSessionImpl.java
libraries/session/src/main/java/androidx/media3/session/MediaSessionStub.java
libraries/session/src/main/java/androidx/media3/session/SessionToken.java
libraries/session/src/main/java/androidx/media3/session/SessionTokenImplBase.java
libraries/session/src/main/java/androidx/media3/session/SessionTokenImplLegacy.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/SessionTokenTest.java
libraries/session/src/main/java/androidx/media3/session/ConnectionState.java
View file @
a28b3ef7
...
@@ -37,7 +37,9 @@ import java.lang.annotation.Target;
...
@@ -37,7 +37,9 @@ import java.lang.annotation.Target;
*/
*/
/* package */
class
ConnectionState
implements
Bundleable
{
/* package */
class
ConnectionState
implements
Bundleable
{
public
final
int
version
;
public
final
int
libraryVersion
;
public
final
int
sessionInterfaceVersion
;
public
final
IMediaSession
sessionBinder
;
public
final
IMediaSession
sessionBinder
;
...
@@ -54,7 +56,8 @@ import java.lang.annotation.Target;
...
@@ -54,7 +56,8 @@ import java.lang.annotation.Target;
public
final
PlayerInfo
playerInfo
;
public
final
PlayerInfo
playerInfo
;
public
ConnectionState
(
public
ConnectionState
(
int
version
,
int
libraryVersion
,
int
sessionInterfaceVersion
,
IMediaSession
sessionBinder
,
IMediaSession
sessionBinder
,
@Nullable
PendingIntent
sessionActivity
,
@Nullable
PendingIntent
sessionActivity
,
SessionCommands
sessionCommands
,
SessionCommands
sessionCommands
,
...
@@ -62,7 +65,8 @@ import java.lang.annotation.Target;
...
@@ -62,7 +65,8 @@ import java.lang.annotation.Target;
Player
.
Commands
playerCommandsFromPlayer
,
Player
.
Commands
playerCommandsFromPlayer
,
Bundle
tokenExtras
,
Bundle
tokenExtras
,
PlayerInfo
playerInfo
)
{
PlayerInfo
playerInfo
)
{
this
.
version
=
version
;
this
.
libraryVersion
=
libraryVersion
;
this
.
sessionInterfaceVersion
=
sessionInterfaceVersion
;
this
.
sessionBinder
=
sessionBinder
;
this
.
sessionBinder
=
sessionBinder
;
this
.
sessionCommands
=
sessionCommands
;
this
.
sessionCommands
=
sessionCommands
;
this
.
playerCommandsFromSession
=
playerCommandsFromSession
;
this
.
playerCommandsFromSession
=
playerCommandsFromSession
;
...
@@ -78,7 +82,7 @@ import java.lang.annotation.Target;
...
@@ -78,7 +82,7 @@ import java.lang.annotation.Target;
@Retention
(
RetentionPolicy
.
SOURCE
)
@Retention
(
RetentionPolicy
.
SOURCE
)
@Target
(
TYPE_USE
)
@Target
(
TYPE_USE
)
@IntDef
({
@IntDef
({
FIELD_VERSION
,
FIELD_
LIBRARY_
VERSION
,
FIELD_SESSION_BINDER
,
FIELD_SESSION_BINDER
,
FIELD_SESSION_ACTIVITY
,
FIELD_SESSION_ACTIVITY
,
FIELD_SESSION_COMMANDS
,
FIELD_SESSION_COMMANDS
,
...
@@ -86,10 +90,11 @@ import java.lang.annotation.Target;
...
@@ -86,10 +90,11 @@ import java.lang.annotation.Target;
FIELD_PLAYER_COMMANDS_FROM_PLAYER
,
FIELD_PLAYER_COMMANDS_FROM_PLAYER
,
FIELD_TOKEN_EXTRAS
,
FIELD_TOKEN_EXTRAS
,
FIELD_PLAYER_INFO
,
FIELD_PLAYER_INFO
,
FIELD_SESSION_INTERFACE_VERSION
,
})
})
private
@interface
FieldNumber
{}
private
@interface
FieldNumber
{}
private
static
final
int
FIELD_VERSION
=
0
;
private
static
final
int
FIELD_
LIBRARY_
VERSION
=
0
;
private
static
final
int
FIELD_SESSION_BINDER
=
1
;
private
static
final
int
FIELD_SESSION_BINDER
=
1
;
private
static
final
int
FIELD_SESSION_ACTIVITY
=
2
;
private
static
final
int
FIELD_SESSION_ACTIVITY
=
2
;
private
static
final
int
FIELD_SESSION_COMMANDS
=
3
;
private
static
final
int
FIELD_SESSION_COMMANDS
=
3
;
...
@@ -97,12 +102,13 @@ import java.lang.annotation.Target;
...
@@ -97,12 +102,13 @@ import java.lang.annotation.Target;
private
static
final
int
FIELD_PLAYER_COMMANDS_FROM_PLAYER
=
5
;
private
static
final
int
FIELD_PLAYER_COMMANDS_FROM_PLAYER
=
5
;
private
static
final
int
FIELD_TOKEN_EXTRAS
=
6
;
private
static
final
int
FIELD_TOKEN_EXTRAS
=
6
;
private
static
final
int
FIELD_PLAYER_INFO
=
7
;
private
static
final
int
FIELD_PLAYER_INFO
=
7
;
// Next field key = 8
private
static
final
int
FIELD_SESSION_INTERFACE_VERSION
=
8
;
// Next field key = 9
@Override
@Override
public
Bundle
toBundle
()
{
public
Bundle
toBundle
()
{
Bundle
bundle
=
new
Bundle
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
keyForField
(
FIELD_
VERSION
),
v
ersion
);
bundle
.
putInt
(
keyForField
(
FIELD_
LIBRARY_VERSION
),
libraryV
ersion
);
BundleCompat
.
putBinder
(
bundle
,
keyForField
(
FIELD_SESSION_BINDER
),
sessionBinder
.
asBinder
());
BundleCompat
.
putBinder
(
bundle
,
keyForField
(
FIELD_SESSION_BINDER
),
sessionBinder
.
asBinder
());
bundle
.
putParcelable
(
keyForField
(
FIELD_SESSION_ACTIVITY
),
sessionActivity
);
bundle
.
putParcelable
(
keyForField
(
FIELD_SESSION_ACTIVITY
),
sessionActivity
);
bundle
.
putBundle
(
keyForField
(
FIELD_SESSION_COMMANDS
),
sessionCommands
.
toBundle
());
bundle
.
putBundle
(
keyForField
(
FIELD_SESSION_COMMANDS
),
sessionCommands
.
toBundle
());
...
@@ -124,6 +130,7 @@ import java.lang.annotation.Target;
...
@@ -124,6 +130,7 @@ import java.lang.annotation.Target;
/* excludeTimeline= */
false
,
/* excludeTimeline= */
false
,
/* excludeTracks= */
!
playerCommandsFromPlayer
.
contains
(
Player
.
COMMAND_GET_TRACKS
)
/* excludeTracks= */
!
playerCommandsFromPlayer
.
contains
(
Player
.
COMMAND_GET_TRACKS
)
||
!
playerCommandsFromSession
.
contains
(
Player
.
COMMAND_GET_TRACKS
)));
||
!
playerCommandsFromSession
.
contains
(
Player
.
COMMAND_GET_TRACKS
)));
bundle
.
putInt
(
keyForField
(
FIELD_SESSION_INTERFACE_VERSION
),
sessionInterfaceVersion
);
return
bundle
;
return
bundle
;
}
}
...
@@ -131,7 +138,9 @@ import java.lang.annotation.Target;
...
@@ -131,7 +138,9 @@ import java.lang.annotation.Target;
public
static
final
Creator
<
ConnectionState
>
CREATOR
=
ConnectionState:
:
fromBundle
;
public
static
final
Creator
<
ConnectionState
>
CREATOR
=
ConnectionState:
:
fromBundle
;
private
static
ConnectionState
fromBundle
(
Bundle
bundle
)
{
private
static
ConnectionState
fromBundle
(
Bundle
bundle
)
{
int
version
=
bundle
.
getInt
(
keyForField
(
FIELD_VERSION
),
/* defaultValue= */
0
);
int
libraryVersion
=
bundle
.
getInt
(
keyForField
(
FIELD_LIBRARY_VERSION
),
/* defaultValue= */
0
);
int
sessionInterfaceVersion
=
bundle
.
getInt
(
keyForField
(
FIELD_SESSION_INTERFACE_VERSION
),
/* defaultValue= */
0
);
IBinder
sessionBinder
=
IBinder
sessionBinder
=
checkNotNull
(
BundleCompat
.
getBinder
(
bundle
,
keyForField
(
FIELD_SESSION_BINDER
)));
checkNotNull
(
BundleCompat
.
getBinder
(
bundle
,
keyForField
(
FIELD_SESSION_BINDER
)));
@Nullable
@Nullable
...
@@ -162,7 +171,8 @@ import java.lang.annotation.Target;
...
@@ -162,7 +171,8 @@ import java.lang.annotation.Target;
?
PlayerInfo
.
DEFAULT
?
PlayerInfo
.
DEFAULT
:
PlayerInfo
.
CREATOR
.
fromBundle
(
playerInfoBundle
);
:
PlayerInfo
.
CREATOR
.
fromBundle
(
playerInfoBundle
);
return
new
ConnectionState
(
return
new
ConnectionState
(
version
,
libraryVersion
,
sessionInterfaceVersion
,
IMediaSession
.
Stub
.
asInterface
(
sessionBinder
),
IMediaSession
.
Stub
.
asInterface
(
sessionBinder
),
sessionActivity
,
sessionActivity
,
sessionCommands
,
sessionCommands
,
...
...
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplBase.java
View file @
a28b3ef7
...
@@ -2326,7 +2326,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -2326,7 +2326,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
new
SessionToken
(
new
SessionToken
(
token
.
getUid
(),
token
.
getUid
(),
TYPE_SESSION
,
TYPE_SESSION
,
result
.
version
,
result
.
libraryVersion
,
result
.
sessionInterfaceVersion
,
token
.
getPackageName
(),
token
.
getPackageName
(),
result
.
sessionBinder
,
result
.
sessionBinder
,
result
.
tokenExtras
);
result
.
tokenExtras
);
...
...
libraries/session/src/main/java/androidx/media3/session/MediaSessionImpl.java
View file @
a28b3ef7
...
@@ -177,6 +177,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
...
@@ -177,6 +177,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
Process
.
myUid
(),
Process
.
myUid
(),
SessionToken
.
TYPE_SESSION
,
SessionToken
.
TYPE_SESSION
,
MediaLibraryInfo
.
VERSION_INT
,
MediaLibraryInfo
.
VERSION_INT
,
MediaSessionStub
.
VERSION_INT
,
context
.
getPackageName
(),
context
.
getPackageName
(),
sessionStub
,
sessionStub
,
tokenExtras
);
tokenExtras
);
...
...
libraries/session/src/main/java/androidx/media3/session/MediaSessionStub.java
View file @
a28b3ef7
...
@@ -102,6 +102,9 @@ import java.util.concurrent.ExecutionException;
...
@@ -102,6 +102,9 @@ import java.util.concurrent.ExecutionException;
private
static
final
String
TAG
=
"MediaSessionStub"
;
private
static
final
String
TAG
=
"MediaSessionStub"
;
/** The version of the IMediaSession interface. */
public
static
final
int
VERSION_INT
=
1
;
private
final
WeakReference
<
MediaSessionImpl
>
sessionImpl
;
private
final
WeakReference
<
MediaSessionImpl
>
sessionImpl
;
private
final
MediaSessionManager
sessionManager
;
private
final
MediaSessionManager
sessionManager
;
private
final
ConnectedControllersManager
<
IBinder
>
connectedControllersManager
;
private
final
ConnectedControllersManager
<
IBinder
>
connectedControllersManager
;
...
@@ -446,6 +449,7 @@ import java.util.concurrent.ExecutionException;
...
@@ -446,6 +449,7 @@ import java.util.concurrent.ExecutionException;
ConnectionState
state
=
ConnectionState
state
=
new
ConnectionState
(
new
ConnectionState
(
MediaLibraryInfo
.
VERSION_INT
,
MediaLibraryInfo
.
VERSION_INT
,
MediaSessionStub
.
VERSION_INT
,
MediaSessionStub
.
this
,
MediaSessionStub
.
this
,
sessionImpl
.
getSessionActivity
(),
sessionImpl
.
getSessionActivity
(),
connectionResult
.
availableSessionCommands
,
connectionResult
.
availableSessionCommands
,
...
...
libraries/session/src/main/java/androidx/media3/session/SessionToken.java
View file @
a28b3ef7
...
@@ -133,11 +133,14 @@ public final class SessionToken implements Bundleable {
...
@@ -133,11 +133,14 @@ public final class SessionToken implements Bundleable {
/* package */
SessionToken
(
/* package */
SessionToken
(
int
uid
,
int
uid
,
int
type
,
int
type
,
int
version
,
int
libraryVersion
,
int
interfaceVersion
,
String
packageName
,
String
packageName
,
IMediaSession
iSession
,
IMediaSession
iSession
,
Bundle
tokenExtras
)
{
Bundle
tokenExtras
)
{
impl
=
new
SessionTokenImplBase
(
uid
,
type
,
version
,
packageName
,
iSession
,
tokenExtras
);
impl
=
new
SessionTokenImplBase
(
uid
,
type
,
libraryVersion
,
interfaceVersion
,
packageName
,
iSession
,
tokenExtras
);
}
}
/* package */
SessionToken
(
Context
context
,
MediaSessionCompat
.
Token
compatToken
)
{
/* package */
SessionToken
(
Context
context
,
MediaSessionCompat
.
Token
compatToken
)
{
...
@@ -230,7 +233,16 @@ public final class SessionToken implements Bundleable {
...
@@ -230,7 +233,16 @@ public final class SessionToken implements Bundleable {
* {@code 1000000} if the session is a legacy session.
* {@code 1000000} if the session is a legacy session.
*/
*/
public
int
getSessionVersion
()
{
public
int
getSessionVersion
()
{
return
impl
.
getSessionVersion
();
return
impl
.
getLibraryVersion
();
}
/**
* Returns the interface version of the session if the {@link #getType() type} is {@link
* #TYPE_SESSION}. Otherwise, it returns {@code 0}.
*/
@UnstableApi
public
int
getInterfaceVersion
()
{
return
impl
.
getInterfaceVersion
();
}
}
/**
/**
...
@@ -412,7 +424,9 @@ public final class SessionToken implements Bundleable {
...
@@ -412,7 +424,9 @@ public final class SessionToken implements Bundleable {
@TokenType
@TokenType
int
getType
();
int
getType
();
int
getSessionVersion
();
int
getLibraryVersion
();
int
getInterfaceVersion
();
Bundle
getExtras
();
Bundle
getExtras
();
...
...
libraries/session/src/main/java/androidx/media3/session/SessionTokenImplBase.java
View file @
a28b3ef7
...
@@ -40,7 +40,9 @@ import java.lang.annotation.Target;
...
@@ -40,7 +40,9 @@ import java.lang.annotation.Target;
@SessionToken
.
TokenType
private
final
int
type
;
@SessionToken
.
TokenType
private
final
int
type
;
private
final
int
version
;
private
final
int
libraryVersion
;
private
final
int
interfaceVersion
;
private
final
String
packageName
;
private
final
String
packageName
;
...
@@ -56,7 +58,8 @@ import java.lang.annotation.Target;
...
@@ -56,7 +58,8 @@ import java.lang.annotation.Target;
this
(
this
(
uid
,
uid
,
type
,
type
,
/* version= */
0
,
/* libraryVersion= */
0
,
/* interfaceVersion= */
0
,
checkNotNull
(
serviceComponent
).
getPackageName
(),
checkNotNull
(
serviceComponent
).
getPackageName
(),
/* serviceName= */
serviceComponent
.
getClassName
(),
/* serviceName= */
serviceComponent
.
getClassName
(),
/* componentName= */
serviceComponent
,
/* componentName= */
serviceComponent
,
...
@@ -67,14 +70,16 @@ import java.lang.annotation.Target;
...
@@ -67,14 +70,16 @@ import java.lang.annotation.Target;
public
SessionTokenImplBase
(
public
SessionTokenImplBase
(
int
uid
,
int
uid
,
int
type
,
int
type
,
int
version
,
int
libraryVersion
,
int
interfaceVersion
,
String
packageName
,
String
packageName
,
IMediaSession
iSession
,
IMediaSession
iSession
,
Bundle
tokenExtras
)
{
Bundle
tokenExtras
)
{
this
(
this
(
uid
,
uid
,
type
,
type
,
version
,
libraryVersion
,
interfaceVersion
,
checkNotNull
(
packageName
),
checkNotNull
(
packageName
),
/* serviceName= */
""
,
/* serviceName= */
""
,
/* componentName= */
null
,
/* componentName= */
null
,
...
@@ -85,7 +90,8 @@ import java.lang.annotation.Target;
...
@@ -85,7 +90,8 @@ import java.lang.annotation.Target;
private
SessionTokenImplBase
(
private
SessionTokenImplBase
(
int
uid
,
int
uid
,
int
type
,
int
type
,
int
version
,
int
libraryVersion
,
int
interfaceVersion
,
String
packageName
,
String
packageName
,
String
serviceName
,
String
serviceName
,
@Nullable
ComponentName
componentName
,
@Nullable
ComponentName
componentName
,
...
@@ -93,7 +99,8 @@ import java.lang.annotation.Target;
...
@@ -93,7 +99,8 @@ import java.lang.annotation.Target;
Bundle
extras
)
{
Bundle
extras
)
{
this
.
uid
=
uid
;
this
.
uid
=
uid
;
this
.
type
=
type
;
this
.
type
=
type
;
this
.
version
=
version
;
this
.
libraryVersion
=
libraryVersion
;
this
.
interfaceVersion
=
interfaceVersion
;
this
.
packageName
=
packageName
;
this
.
packageName
=
packageName
;
this
.
serviceName
=
serviceName
;
this
.
serviceName
=
serviceName
;
this
.
componentName
=
componentName
;
this
.
componentName
=
componentName
;
...
@@ -103,7 +110,15 @@ import java.lang.annotation.Target;
...
@@ -103,7 +110,15 @@ import java.lang.annotation.Target;
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
Objects
.
hashCode
(
uid
,
type
,
version
,
packageName
,
serviceName
,
componentName
,
iSession
);
return
Objects
.
hashCode
(
uid
,
type
,
libraryVersion
,
interfaceVersion
,
packageName
,
serviceName
,
componentName
,
iSession
);
}
}
@Override
@Override
...
@@ -114,7 +129,8 @@ import java.lang.annotation.Target;
...
@@ -114,7 +129,8 @@ import java.lang.annotation.Target;
SessionTokenImplBase
other
=
(
SessionTokenImplBase
)
obj
;
SessionTokenImplBase
other
=
(
SessionTokenImplBase
)
obj
;
return
uid
==
other
.
uid
return
uid
==
other
.
uid
&&
type
==
other
.
type
&&
type
==
other
.
type
&&
version
==
other
.
version
&&
libraryVersion
==
other
.
libraryVersion
&&
interfaceVersion
==
other
.
interfaceVersion
&&
TextUtils
.
equals
(
packageName
,
other
.
packageName
)
&&
TextUtils
.
equals
(
packageName
,
other
.
packageName
)
&&
TextUtils
.
equals
(
serviceName
,
other
.
serviceName
)
&&
TextUtils
.
equals
(
serviceName
,
other
.
serviceName
)
&&
Util
.
areEqual
(
componentName
,
other
.
componentName
)
&&
Util
.
areEqual
(
componentName
,
other
.
componentName
)
...
@@ -127,8 +143,10 @@ import java.lang.annotation.Target;
...
@@ -127,8 +143,10 @@ import java.lang.annotation.Target;
+
packageName
+
packageName
+
" type="
+
" type="
+
type
+
type
+
" version="
+
" libraryVersion="
+
version
+
libraryVersion
+
" interfaceVersion="
+
interfaceVersion
+
" service="
+
" service="
+
serviceName
+
serviceName
+
" IMediaSession="
+
" IMediaSession="
...
@@ -171,8 +189,13 @@ import java.lang.annotation.Target;
...
@@ -171,8 +189,13 @@ import java.lang.annotation.Target;
}
}
@Override
@Override
public
int
getSessionVersion
()
{
public
int
getLibraryVersion
()
{
return
version
;
return
libraryVersion
;
}
@Override
public
int
getInterfaceVersion
()
{
return
interfaceVersion
;
}
}
@Override
@Override
...
@@ -194,35 +217,39 @@ import java.lang.annotation.Target;
...
@@ -194,35 +217,39 @@ import java.lang.annotation.Target;
@IntDef
({
@IntDef
({
FIELD_UID
,
FIELD_UID
,
FIELD_TYPE
,
FIELD_TYPE
,
FIELD_VERSION
,
FIELD_
LIBRARY_
VERSION
,
FIELD_PACKAGE_NAME
,
FIELD_PACKAGE_NAME
,
FIELD_SERVICE_NAME
,
FIELD_SERVICE_NAME
,
FIELD_ISESSION
,
FIELD_ISESSION
,
FIELD_COMPONENT_NAME
,
FIELD_COMPONENT_NAME
,
FIELD_EXTRAS
FIELD_EXTRAS
,
FIELD_INTERFACE_VERSION
})
})
private
@interface
FieldNumber
{}
private
@interface
FieldNumber
{}
private
static
final
int
FIELD_UID
=
0
;
private
static
final
int
FIELD_UID
=
0
;
private
static
final
int
FIELD_TYPE
=
1
;
private
static
final
int
FIELD_TYPE
=
1
;
private
static
final
int
FIELD_VERSION
=
2
;
private
static
final
int
FIELD_
LIBRARY_
VERSION
=
2
;
private
static
final
int
FIELD_PACKAGE_NAME
=
3
;
private
static
final
int
FIELD_PACKAGE_NAME
=
3
;
private
static
final
int
FIELD_SERVICE_NAME
=
4
;
private
static
final
int
FIELD_SERVICE_NAME
=
4
;
private
static
final
int
FIELD_COMPONENT_NAME
=
5
;
private
static
final
int
FIELD_COMPONENT_NAME
=
5
;
private
static
final
int
FIELD_ISESSION
=
6
;
private
static
final
int
FIELD_ISESSION
=
6
;
private
static
final
int
FIELD_EXTRAS
=
7
;
private
static
final
int
FIELD_EXTRAS
=
7
;
private
static
final
int
FIELD_INTERFACE_VERSION
=
8
;
// Next field key = 9
@Override
@Override
public
Bundle
toBundle
()
{
public
Bundle
toBundle
()
{
Bundle
bundle
=
new
Bundle
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
keyForField
(
FIELD_UID
),
uid
);
bundle
.
putInt
(
keyForField
(
FIELD_UID
),
uid
);
bundle
.
putInt
(
keyForField
(
FIELD_TYPE
),
type
);
bundle
.
putInt
(
keyForField
(
FIELD_TYPE
),
type
);
bundle
.
putInt
(
keyForField
(
FIELD_
VERSION
),
v
ersion
);
bundle
.
putInt
(
keyForField
(
FIELD_
LIBRARY_VERSION
),
libraryV
ersion
);
bundle
.
putString
(
keyForField
(
FIELD_PACKAGE_NAME
),
packageName
);
bundle
.
putString
(
keyForField
(
FIELD_PACKAGE_NAME
),
packageName
);
bundle
.
putString
(
keyForField
(
FIELD_SERVICE_NAME
),
serviceName
);
bundle
.
putString
(
keyForField
(
FIELD_SERVICE_NAME
),
serviceName
);
BundleCompat
.
putBinder
(
bundle
,
keyForField
(
FIELD_ISESSION
),
iSession
);
BundleCompat
.
putBinder
(
bundle
,
keyForField
(
FIELD_ISESSION
),
iSession
);
bundle
.
putParcelable
(
keyForField
(
FIELD_COMPONENT_NAME
),
componentName
);
bundle
.
putParcelable
(
keyForField
(
FIELD_COMPONENT_NAME
),
componentName
);
bundle
.
putBundle
(
keyForField
(
FIELD_EXTRAS
),
extras
);
bundle
.
putBundle
(
keyForField
(
FIELD_EXTRAS
),
extras
);
bundle
.
putInt
(
keyForField
(
FIELD_INTERFACE_VERSION
),
interfaceVersion
);
return
bundle
;
return
bundle
;
}
}
...
@@ -234,7 +261,9 @@ import java.lang.annotation.Target;
...
@@ -234,7 +261,9 @@ import java.lang.annotation.Target;
int
uid
=
bundle
.
getInt
(
keyForField
(
FIELD_UID
));
int
uid
=
bundle
.
getInt
(
keyForField
(
FIELD_UID
));
checkArgument
(
bundle
.
containsKey
(
keyForField
(
FIELD_TYPE
)),
"type should be set."
);
checkArgument
(
bundle
.
containsKey
(
keyForField
(
FIELD_TYPE
)),
"type should be set."
);
int
type
=
bundle
.
getInt
(
keyForField
(
FIELD_TYPE
));
int
type
=
bundle
.
getInt
(
keyForField
(
FIELD_TYPE
));
int
version
=
bundle
.
getInt
(
keyForField
(
FIELD_VERSION
),
/* defaultValue= */
0
);
int
libraryVersion
=
bundle
.
getInt
(
keyForField
(
FIELD_LIBRARY_VERSION
),
/* defaultValue= */
0
);
int
interfaceVersion
=
bundle
.
getInt
(
keyForField
(
FIELD_INTERFACE_VERSION
),
/* defaultValue= */
0
);
String
packageName
=
String
packageName
=
checkNotEmpty
(
checkNotEmpty
(
bundle
.
getString
(
keyForField
(
FIELD_PACKAGE_NAME
)),
"package name should be set."
);
bundle
.
getString
(
keyForField
(
FIELD_PACKAGE_NAME
)),
"package name should be set."
);
...
@@ -245,7 +274,8 @@ import java.lang.annotation.Target;
...
@@ -245,7 +274,8 @@ import java.lang.annotation.Target;
return
new
SessionTokenImplBase
(
return
new
SessionTokenImplBase
(
uid
,
uid
,
type
,
type
,
version
,
libraryVersion
,
interfaceVersion
,
packageName
,
packageName
,
serviceName
,
serviceName
,
componentName
,
componentName
,
...
...
libraries/session/src/main/java/androidx/media3/session/SessionTokenImplLegacy.java
View file @
a28b3ef7
...
@@ -154,7 +154,12 @@ import java.lang.annotation.Target;
...
@@ -154,7 +154,12 @@ import java.lang.annotation.Target;
}
}
@Override
@Override
public
int
getSessionVersion
()
{
public
int
getLibraryVersion
()
{
return
0
;
}
@Override
public
int
getInterfaceVersion
()
{
return
0
;
return
0
;
}
}
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java
View file @
a28b3ef7
...
@@ -54,6 +54,7 @@ import androidx.media3.common.DeviceInfo;
...
@@ -54,6 +54,7 @@ import androidx.media3.common.DeviceInfo;
import
androidx.media3.common.FlagSet
;
import
androidx.media3.common.FlagSet
;
import
androidx.media3.common.Format
;
import
androidx.media3.common.Format
;
import
androidx.media3.common.MediaItem
;
import
androidx.media3.common.MediaItem
;
import
androidx.media3.common.MediaLibraryInfo
;
import
androidx.media3.common.MediaMetadata
;
import
androidx.media3.common.MediaMetadata
;
import
androidx.media3.common.PlaybackException
;
import
androidx.media3.common.PlaybackException
;
import
androidx.media3.common.PlaybackParameters
;
import
androidx.media3.common.PlaybackParameters
;
...
@@ -230,6 +231,18 @@ public class MediaControllerListenerTest {
...
@@ -230,6 +231,18 @@ public class MediaControllerListenerTest {
}
}
@Test
@Test
public
void
connection_correctVersions
()
throws
Exception
{
SessionToken
token
=
new
SessionToken
(
context
,
MOCK_MEDIA3_SESSION_SERVICE
);
MediaController
controller
=
controllerTestRule
.
createController
(
token
);
assertThat
(
controller
.
getConnectedToken
().
getInterfaceVersion
())
.
isEqualTo
(
MediaSessionStub
.
VERSION_INT
);
assertThat
(
controller
.
getConnectedToken
().
getSessionVersion
())
.
isEqualTo
(
MediaLibraryInfo
.
VERSION_INT
);
}
@Test
@LargeTest
@LargeTest
public
void
noInteractionAfterSessionClose_session
()
throws
Exception
{
public
void
noInteractionAfterSessionClose_session
()
throws
Exception
{
SessionToken
token
=
remoteSession
.
getToken
();
SessionToken
token
=
remoteSession
.
getToken
();
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/SessionTokenTest.java
View file @
a28b3ef7
...
@@ -71,6 +71,8 @@ public class SessionTokenTest {
...
@@ -71,6 +71,8 @@ public class SessionTokenTest {
assertThat
(
token
.
getPackageName
()).
isEqualTo
(
context
.
getPackageName
());
assertThat
(
token
.
getPackageName
()).
isEqualTo
(
context
.
getPackageName
());
assertThat
(
token
.
getUid
()).
isEqualTo
(
Process
.
myUid
());
assertThat
(
token
.
getUid
()).
isEqualTo
(
Process
.
myUid
());
assertThat
(
token
.
getType
()).
isEqualTo
(
SessionToken
.
TYPE_SESSION_SERVICE
);
assertThat
(
token
.
getType
()).
isEqualTo
(
SessionToken
.
TYPE_SESSION_SERVICE
);
assertThat
(
token
.
getInterfaceVersion
()).
isEqualTo
(
0
);
assertThat
(
token
.
getSessionVersion
()).
isEqualTo
(
0
);
}
}
@Test
@Test
...
@@ -84,6 +86,8 @@ public class SessionTokenTest {
...
@@ -84,6 +86,8 @@ public class SessionTokenTest {
assertThat
(
token
.
getUid
()).
isEqualTo
(
Process
.
myUid
());
assertThat
(
token
.
getUid
()).
isEqualTo
(
Process
.
myUid
());
assertThat
(
token
.
getType
()).
isEqualTo
(
SessionToken
.
TYPE_LIBRARY_SERVICE
);
assertThat
(
token
.
getType
()).
isEqualTo
(
SessionToken
.
TYPE_LIBRARY_SERVICE
);
assertThat
(
token
.
getServiceName
()).
isEqualTo
(
testComponentName
.
getClassName
());
assertThat
(
token
.
getServiceName
()).
isEqualTo
(
testComponentName
.
getClassName
());
assertThat
(
token
.
getInterfaceVersion
()).
isEqualTo
(
0
);
assertThat
(
token
.
getSessionVersion
()).
isEqualTo
(
0
);
}
}
@Test
@Test
...
@@ -101,6 +105,7 @@ public class SessionTokenTest {
...
@@ -101,6 +105,7 @@ public class SessionTokenTest {
assertThat
(
token
.
getUid
()).
isEqualTo
(
Process
.
myUid
());
assertThat
(
token
.
getUid
()).
isEqualTo
(
Process
.
myUid
());
assertThat
(
token
.
getType
()).
isEqualTo
(
SessionToken
.
TYPE_SESSION
);
assertThat
(
token
.
getType
()).
isEqualTo
(
SessionToken
.
TYPE_SESSION
);
assertThat
(
token
.
getSessionVersion
()).
isEqualTo
(
MediaLibraryInfo
.
VERSION_INT
);
assertThat
(
token
.
getSessionVersion
()).
isEqualTo
(
MediaLibraryInfo
.
VERSION_INT
);
assertThat
(
token
.
getInterfaceVersion
()).
isEqualTo
(
MediaSessionStub
.
VERSION_INT
);
assertThat
(
TestUtils
.
equals
(
testTokenExtras
,
token
.
getExtras
())).
isTrue
();
assertThat
(
TestUtils
.
equals
(
testTokenExtras
,
token
.
getExtras
())).
isTrue
();
assertThat
(
token
.
getServiceName
()).
isEmpty
();
assertThat
(
token
.
getServiceName
()).
isEmpty
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment