Merge "MediaSessionService: Stop using APIs in the MediaComponents" into pi-dev

This commit is contained in:
Jaewan Kim
2018-03-28 08:40:23 +00:00
committed by Android (Google) Code Review

View File

@@ -101,6 +101,7 @@ import java.util.NoSuchElementException;
*/ */
public class MediaSessionService extends SystemService implements Monitor { public class MediaSessionService extends SystemService implements Monitor {
private static final String TAG = "MediaSessionService"; private static final String TAG = "MediaSessionService";
static final boolean USE_MEDIA2_APIS = false; // TODO: Change this to true when we're ready.
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
// Leave log for key event always. // Leave log for key event always.
private static final boolean DEBUG_KEY_EVENT = true; private static final boolean DEBUG_KEY_EVENT = true;
@@ -508,6 +509,9 @@ public class MediaSessionService extends SystemService implements Monitor {
} }
private void buildMediaSessionService2List() { private void buildMediaSessionService2List() {
if (!USE_MEDIA2_APIS) {
return;
}
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "buildMediaSessionService2List"); Log.d(TAG, "buildMediaSessionService2List");
} }
@@ -1531,6 +1535,9 @@ public class MediaSessionService extends SystemService implements Monitor {
*/ */
@Override @Override
public boolean createSession2(Bundle sessionToken) { public boolean createSession2(Bundle sessionToken) {
if (!USE_MEDIA2_APIS) {
return false;
}
final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid();
final SessionToken2 token = SessionToken2.fromBundle(sessionToken); final SessionToken2 token = SessionToken2.fromBundle(sessionToken);
if (token == null || token.getUid() != uid) { if (token == null || token.getUid() != uid) {
@@ -1570,6 +1577,9 @@ public class MediaSessionService extends SystemService implements Monitor {
*/ */
@Override @Override
public void destroySession2(Bundle sessionToken) { public void destroySession2(Bundle sessionToken) {
if (!USE_MEDIA2_APIS) {
return;
}
final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid();
final SessionToken2 token = SessionToken2.fromBundle(sessionToken); final SessionToken2 token = SessionToken2.fromBundle(sessionToken);
if (token == null || token.getUid() != uid) { if (token == null || token.getUid() != uid) {
@@ -1586,6 +1596,9 @@ public class MediaSessionService extends SystemService implements Monitor {
@Override @Override
public List<Bundle> getSessionTokens(boolean activeSessionOnly, public List<Bundle> getSessionTokens(boolean activeSessionOnly,
boolean sessionServiceOnly, String packageName) throws RemoteException { boolean sessionServiceOnly, String packageName) throws RemoteException {
if (!USE_MEDIA2_APIS) {
return null;
}
final int pid = Binder.getCallingPid(); final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid();
final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
@@ -1614,6 +1627,9 @@ public class MediaSessionService extends SystemService implements Monitor {
@Override @Override
public void addSessionTokensListener(ISessionTokensListener listener, int userId, public void addSessionTokensListener(ISessionTokensListener listener, int userId,
String packageName) throws RemoteException { String packageName) throws RemoteException {
if (!USE_MEDIA2_APIS) {
return;
}
final int pid = Binder.getCallingPid(); final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid();
final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
@@ -1637,6 +1653,9 @@ public class MediaSessionService extends SystemService implements Monitor {
@Override @Override
public void removeSessionTokensListener(ISessionTokensListener listener, public void removeSessionTokensListener(ISessionTokensListener listener,
String packageName) throws RemoteException { String packageName) throws RemoteException {
if (!USE_MEDIA2_APIS) {
return;
}
final int pid = Binder.getCallingPid(); final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid();
final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();