SlideShare a Scribd company logo
1 of 26
Download to read offline
Android Media Hacks
@KeithYokoma - Drivemode, Inc.
potatotips #18
@KeithYokoma
Keishin Yokomaku at Drivemode, Inc. as Android Engineer
Experience
1.SNS client and photo book application for Android
2.Driver’s application for Android
Publications
1.Android Training
2.Mixi official smartphone application development guide
Like
Motorsport, Bicycle, Photography, Tumblr
Media Playback Control
Put media playback controller on…
• Notification
• AppWidgets
• Android Auto App
• Lock Screen(KeyGuard)
Media Playback Control
Different implementations for each API level
• RemoteController (from KitKat)
• RemoteControlClient(from ICS)
These system are based on PendingIntent
From Lollipop…
• MediaSession and MediaController
MediaController
Standardized media playback control API from Lollipop
System will use this API in…
• Notification.MediaStyle
• Android Auto App
How it works on Notification
Media Application
MediaSession
System Notification
MediaController
Token
Transport Control
How it works on Android Auto
Media Application
MediaSession
Android Auto
MediaController
Token & Media Contents
Bind
MediaBrowserService MediaBrowser
Token Token
Transport Control
Watching Notification…
NotificationListenerService
NotificationListenerService
Event receiver for status bar notification available from JB-MR2
We can access following data in the notification…
• Title
• Message
• ContentView
• HeadsUpContentView
• Extras
NotificationListenerService
Event receiver for status bar notification available from JB-MR2
We can access following data in the notification…
• Title
• Message
• ContentView
• HeadsUpContentView
• Extras
Notification.MediaStyle
Notification.MediaStyle
MediaController
MediaController
–Me
“Yes, you can steal a media session token
without invading private APIs”
–Me
“And you can set the token to your own MediaController”
–Someone
“This is more like session hijacking”
Take control of music playback
public class MusicNotificationWatcher extends NotificationListenerService {
private Bus eventBus;
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
MediaSession.Token token =
sbn.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION);
eventBus.post(new NewMusicNotification(token));
}
}
public class MyActivity extends Activity {
private MediaController controller;
@Subscribe
public void onNewMusicNotificationAdded(NewMusicNotification event) {
controller = new MediaController(this, event.getToken())
}
}
Take control of music playback
public class MusicNotificationWatcher extends NotificationListenerService {
private Bus eventBus;
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
MediaSession.Token token =
sbn.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION);
eventBus.post(new NewMusicNotification(token));
}
}
public class MyActivity extends Activity {
private MediaController controller;
@Subscribe
public void onNewMusicNotificationAdded(NewMusicNotification event) {
controller = new MediaController(this, event.getToken())
}
}
Take control of music playback
public class MusicNotificationWatcher extends NotificationListenerService {
private Bus eventBus;
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
MediaSession.Token token =
sbn.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION);
eventBus.post(new NewMusicNotification(token));
}
}
public class MyActivity extends Activity {
private MediaController controller;
@Subscribe
public void onNewMusicNotificationAdded(NewMusicNotification event) {
controller = new MediaController(this, event.getToken())
}
}
It only works for Google Play Music
Conclusion
• Do not put PRIVATE things on your notification
• Crackers are watching you
• Consider using MediaSession and MediaController
• For better interaction with Auto, Notification and

your partners’ applications
Conclusion
• For a OS compatibility reason, you can use
RemoteControlClient and AudioManager
• Still you need some dirty hacks…
• For an application compatibility reason, you should use
RemoteController
• Even though it is deprecated now, it works on Lollipop
Android Media Hacks
@KeithYokoma - Drivemode, Inc.
potatotips #18

More Related Content

Similar to Android Media Hacks

Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
Krazy Koder
 
Flash runtime on mobile
Flash runtime on mobileFlash runtime on mobile
Flash runtime on mobile
howard-wu
 

Similar to Android Media Hacks (20)

Making an OpenSource Automotive IVI Media Manager
Making an OpenSource Automotive IVI Media ManagerMaking an OpenSource Automotive IVI Media Manager
Making an OpenSource Automotive IVI Media Manager
 
Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
 
Desenvolver para Chromecast
Desenvolver para ChromecastDesenvolver para Chromecast
Desenvolver para Chromecast
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
 
BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in Android
 
Android App development III
Android App development IIIAndroid App development III
Android App development III
 
First meet with Android Auto
First meet with Android AutoFirst meet with Android Auto
First meet with Android Auto
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in Android
 
J2me
J2meJ2me
J2me
 
Android App Development - 13 Broadcast receivers and app widgets
Android App Development - 13 Broadcast receivers and app widgetsAndroid App Development - 13 Broadcast receivers and app widgets
Android App Development - 13 Broadcast receivers and app widgets
 
Notifications
NotificationsNotifications
Notifications
 
Implementing cast in android
Implementing cast in androidImplementing cast in android
Implementing cast in android
 
The unconventional devices for the Android video streaming
The unconventional devices for the Android video streamingThe unconventional devices for the Android video streaming
The unconventional devices for the Android video streaming
 
Yapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web PlayerYapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web Player
 
App widget
App widgetApp widget
App widget
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application Development
 
Flash runtime on mobile
Flash runtime on mobileFlash runtime on mobile
Flash runtime on mobile
 
The Glass Class - Tutorial 4 - GDK-Live Cards
The Glass Class - Tutorial 4 - GDK-Live CardsThe Glass Class - Tutorial 4 - GDK-Live Cards
The Glass Class - Tutorial 4 - GDK-Live Cards
 

More from Keishin Yokomaku

More from Keishin Yokomaku (13)

UI optimization for night
UI optimization for nightUI optimization for night
UI optimization for night
 
Popup view on Mortar
Popup view on MortarPopup view on Mortar
Popup view on Mortar
 
Regexp in Android and Java
Regexp in Android and JavaRegexp in Android and Java
Regexp in Android and Java
 
Make it compatible
Make it compatibleMake it compatible
Make it compatible
 
Signature
SignatureSignature
Signature
 
Null, the Abyss
Null, the AbyssNull, the Abyss
Null, the Abyss
 
?
??
?
 
Building stable and flexible libraries
Building stable and flexible librariesBuilding stable and flexible libraries
Building stable and flexible libraries
 
Typeface
TypefaceTypeface
Typeface
 
Version Management
Version ManagementVersion Management
Version Management
 
イカしたライブラリを作った話
イカしたライブラリを作った話イカしたライブラリを作った話
イカしたライブラリを作った話
 
Google I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleGoogle I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と Gradle
 
自己組織化
自己組織化自己組織化
自己組織化
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Android Media Hacks

  • 1. Android Media Hacks @KeithYokoma - Drivemode, Inc. potatotips #18
  • 2. @KeithYokoma Keishin Yokomaku at Drivemode, Inc. as Android Engineer Experience 1.SNS client and photo book application for Android 2.Driver’s application for Android Publications 1.Android Training 2.Mixi official smartphone application development guide Like Motorsport, Bicycle, Photography, Tumblr
  • 3. Media Playback Control Put media playback controller on… • Notification • AppWidgets • Android Auto App • Lock Screen(KeyGuard)
  • 4. Media Playback Control Different implementations for each API level • RemoteController (from KitKat) • RemoteControlClient(from ICS) These system are based on PendingIntent From Lollipop… • MediaSession and MediaController
  • 5. MediaController Standardized media playback control API from Lollipop System will use this API in… • Notification.MediaStyle • Android Auto App
  • 6. How it works on Notification Media Application MediaSession System Notification MediaController Token Transport Control
  • 7. How it works on Android Auto Media Application MediaSession Android Auto MediaController Token & Media Contents Bind MediaBrowserService MediaBrowser Token Token Transport Control
  • 10. NotificationListenerService Event receiver for status bar notification available from JB-MR2 We can access following data in the notification… • Title • Message • ContentView • HeadsUpContentView • Extras
  • 11. NotificationListenerService Event receiver for status bar notification available from JB-MR2 We can access following data in the notification… • Title • Message • ContentView • HeadsUpContentView • Extras
  • 16. –Me “Yes, you can steal a media session token without invading private APIs”
  • 17. –Me “And you can set the token to your own MediaController”
  • 18. –Someone “This is more like session hijacking”
  • 19. Take control of music playback public class MusicNotificationWatcher extends NotificationListenerService { private Bus eventBus; @Override public void onNotificationPosted(StatusBarNotification sbn) { MediaSession.Token token = sbn.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION); eventBus.post(new NewMusicNotification(token)); } } public class MyActivity extends Activity { private MediaController controller; @Subscribe public void onNewMusicNotificationAdded(NewMusicNotification event) { controller = new MediaController(this, event.getToken()) } }
  • 20. Take control of music playback public class MusicNotificationWatcher extends NotificationListenerService { private Bus eventBus; @Override public void onNotificationPosted(StatusBarNotification sbn) { MediaSession.Token token = sbn.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION); eventBus.post(new NewMusicNotification(token)); } } public class MyActivity extends Activity { private MediaController controller; @Subscribe public void onNewMusicNotificationAdded(NewMusicNotification event) { controller = new MediaController(this, event.getToken()) } }
  • 21. Take control of music playback public class MusicNotificationWatcher extends NotificationListenerService { private Bus eventBus; @Override public void onNotificationPosted(StatusBarNotification sbn) { MediaSession.Token token = sbn.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION); eventBus.post(new NewMusicNotification(token)); } } public class MyActivity extends Activity { private MediaController controller; @Subscribe public void onNewMusicNotificationAdded(NewMusicNotification event) { controller = new MediaController(this, event.getToken()) } }
  • 22.
  • 23. It only works for Google Play Music
  • 24. Conclusion • Do not put PRIVATE things on your notification • Crackers are watching you • Consider using MediaSession and MediaController • For better interaction with Auto, Notification and
 your partners’ applications
  • 25. Conclusion • For a OS compatibility reason, you can use RemoteControlClient and AudioManager • Still you need some dirty hacks… • For an application compatibility reason, you should use RemoteController • Even though it is deprecated now, it works on Lollipop
  • 26. Android Media Hacks @KeithYokoma - Drivemode, Inc. potatotips #18