Loading AndroidManifest.xml +10 −3 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 Andrew Neal Copyright (C) 2014 The CyanogenMod Project Copyright (C) 2019-2022 The LineageOS Project Copyright (C) 2019-2023 The LineageOS Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. Loading Loading @@ -78,6 +78,9 @@ android:taskAffinity="org.lineageos.eleven.task" android:theme="@style/Eleven.Theme"> <meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc"/> <!-- Main activity --> <activity android:name="org.lineageos.eleven.ui.activities.HomeActivity" Loading Loading @@ -216,8 +219,12 @@ <!-- Music service --> <service android:name="org.lineageos.eleven.MusicPlaybackService" android:exported="false" android:exported="true" android:label="@string/app_name" android:process=":main" /> android:process=":main"> <intent-filter> <action android:name="android.media.browse.MediaBrowserService"/> </intent-filter> </service> </application> </manifest> res/xml/automotive_app_desc.xml 0 → 100644 +20 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2023 The LineageOS Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <automotiveApp> <!-- Tell Android Auto that Eleven can act as a media app. --> <uses name="media"/> </automotiveApp> src/org/lineageos/eleven/MusicPlaybackService.java +19 −2 Original line number Diff line number Diff line /* * Copyright (C) 2012 Andrew Neal * Copyright (C) 2014-2016 The CyanogenMod Project * Copyright (C) 2018-2021 The LineageOS Project * Copyright (C) 2018-2023 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -46,9 +46,11 @@ import android.media.MediaDescription; import android.media.MediaMetadata; import android.media.MediaPlayer; import android.media.audiofx.AudioEffect; import android.media.browse.MediaBrowser; import android.media.session.MediaSession; import android.media.session.PlaybackState; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; Loading @@ -60,12 +62,14 @@ import android.provider.BaseColumns; import android.provider.MediaStore; import android.provider.MediaStore.Audio.AlbumColumns; import android.provider.MediaStore.Audio.AudioColumns; import android.service.media.MediaBrowserService; import android.text.TextUtils; import android.util.Log; import android.util.LongSparseArray; import android.view.KeyEvent; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import org.lineageos.eleven.Config.IdType; import org.lineageos.eleven.appwidgets.AppWidgetLarge; Loading Loading @@ -100,7 +104,7 @@ import java.util.concurrent.Executors; * A background {@link Service} used to keep music playing between activities * and when the user moves Eleven into the background. */ public class MusicPlaybackService extends Service public class MusicPlaybackService extends MediaBrowserService implements AudioManager.OnAudioFocusChangeListener { private static final String TAG = "MusicPlaybackService"; private static final boolean D = false; Loading Loading @@ -557,6 +561,19 @@ public class MusicPlaybackService extends Service return mBinder; } @Nullable @Override public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, @Nullable Bundle bundle) { return new BrowserRoot("root", null); } @Override public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowser.MediaItem>> result) { result.detach(); } @Override public boolean onUnbind(final Intent intent) { if (D) Log.d(TAG, "Service unbound"); Loading Loading
AndroidManifest.xml +10 −3 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 Andrew Neal Copyright (C) 2014 The CyanogenMod Project Copyright (C) 2019-2022 The LineageOS Project Copyright (C) 2019-2023 The LineageOS Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. Loading Loading @@ -78,6 +78,9 @@ android:taskAffinity="org.lineageos.eleven.task" android:theme="@style/Eleven.Theme"> <meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc"/> <!-- Main activity --> <activity android:name="org.lineageos.eleven.ui.activities.HomeActivity" Loading Loading @@ -216,8 +219,12 @@ <!-- Music service --> <service android:name="org.lineageos.eleven.MusicPlaybackService" android:exported="false" android:exported="true" android:label="@string/app_name" android:process=":main" /> android:process=":main"> <intent-filter> <action android:name="android.media.browse.MediaBrowserService"/> </intent-filter> </service> </application> </manifest>
res/xml/automotive_app_desc.xml 0 → 100644 +20 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2023 The LineageOS Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <automotiveApp> <!-- Tell Android Auto that Eleven can act as a media app. --> <uses name="media"/> </automotiveApp>
src/org/lineageos/eleven/MusicPlaybackService.java +19 −2 Original line number Diff line number Diff line /* * Copyright (C) 2012 Andrew Neal * Copyright (C) 2014-2016 The CyanogenMod Project * Copyright (C) 2018-2021 The LineageOS Project * Copyright (C) 2018-2023 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -46,9 +46,11 @@ import android.media.MediaDescription; import android.media.MediaMetadata; import android.media.MediaPlayer; import android.media.audiofx.AudioEffect; import android.media.browse.MediaBrowser; import android.media.session.MediaSession; import android.media.session.PlaybackState; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; Loading @@ -60,12 +62,14 @@ import android.provider.BaseColumns; import android.provider.MediaStore; import android.provider.MediaStore.Audio.AlbumColumns; import android.provider.MediaStore.Audio.AudioColumns; import android.service.media.MediaBrowserService; import android.text.TextUtils; import android.util.Log; import android.util.LongSparseArray; import android.view.KeyEvent; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import org.lineageos.eleven.Config.IdType; import org.lineageos.eleven.appwidgets.AppWidgetLarge; Loading Loading @@ -100,7 +104,7 @@ import java.util.concurrent.Executors; * A background {@link Service} used to keep music playing between activities * and when the user moves Eleven into the background. */ public class MusicPlaybackService extends Service public class MusicPlaybackService extends MediaBrowserService implements AudioManager.OnAudioFocusChangeListener { private static final String TAG = "MusicPlaybackService"; private static final boolean D = false; Loading Loading @@ -557,6 +561,19 @@ public class MusicPlaybackService extends Service return mBinder; } @Nullable @Override public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, @Nullable Bundle bundle) { return new BrowserRoot("root", null); } @Override public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowser.MediaItem>> result) { result.detach(); } @Override public boolean onUnbind(final Intent intent) { if (D) Log.d(TAG, "Service unbound"); Loading