towards android 12 fixing
This commit is contained in:
parent
c7d158f860
commit
19c1bafeb8
5 changed files with 99 additions and 97 deletions
|
@ -9,14 +9,14 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
targetSdkVersion 31
|
||||
|
||||
renderscriptTargetApi 29//must match target sdk and build tools
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
applicationId "code.name.monkey.retromusic"
|
||||
versionCode 10519
|
||||
versionName '5.0.0' + "_" + getDate()
|
||||
versionCode 10537
|
||||
versionName '5.2.1 ' + "_" + getDate()
|
||||
|
||||
buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"")
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
tools:targetApi="m">
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/SplashTheme">
|
||||
<intent-filter>
|
||||
|
@ -147,7 +148,8 @@
|
|||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar">
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
|
@ -176,13 +178,17 @@
|
|||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
<receiver android:name=".service.MediaButtonIntentReceiver">
|
||||
<receiver
|
||||
android:name=".service.MediaButtonIntentReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".appwidgets.BootReceiver">
|
||||
<receiver
|
||||
android:name=".appwidgets.BootReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
|
@ -274,17 +280,6 @@
|
|||
android:name="com.android.vending.splits.required"
|
||||
android:value="true" />
|
||||
|
||||
<!-- Android Auto -->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.car.application"
|
||||
android:resource="@xml/automotive_app_desc" />
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.car.application.theme"
|
||||
android:resource="@style/CarTheme" />
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.car.notification.SmallIcon"
|
||||
android:resource="@drawable/ic_notification" />
|
||||
|
||||
<!-- ChromeCast -->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
||||
|
|
|
@ -189,13 +189,13 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
|
||||
private final AppWidgetBig appWidgetBig = AppWidgetBig.Companion.getInstance();
|
||||
|
||||
private final AppWidgetCard appWidgetCard = AppWidgetCard.Companion.getInstance();
|
||||
private final AppWidgetCard appWidgetCard = AppWidgetCard.Companion.getInstance();
|
||||
|
||||
private final AppWidgetClassic appWidgetClassic = AppWidgetClassic.Companion.getInstance();
|
||||
private final AppWidgetClassic appWidgetClassic = AppWidgetClassic.Companion.getInstance();
|
||||
|
||||
private final AppWidgetSmall appWidgetSmall = AppWidgetSmall.Companion.getInstance();
|
||||
private final AppWidgetSmall appWidgetSmall = AppWidgetSmall.Companion.getInstance();
|
||||
|
||||
private final AppWidgetText appWidgetText = AppWidgetText.Companion.getInstance();
|
||||
private final AppWidgetText appWidgetText = AppWidgetText.Companion.getInstance();
|
||||
|
||||
private final BroadcastReceiver widgetIntentReceiver =
|
||||
new BroadcastReceiver() {
|
||||
|
@ -229,15 +229,15 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
}
|
||||
}
|
||||
};
|
||||
private AudioManager audioManager;
|
||||
private final IntentFilter becomingNoisyReceiverIntentFilter =
|
||||
new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
|
||||
private boolean becomingNoisyReceiverRegistered;
|
||||
private final IntentFilter bluetoothConnectedIntentFilter =
|
||||
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
private boolean bluetoothConnectedRegistered = false;
|
||||
private final IntentFilter headsetReceiverIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
|
||||
private boolean headsetReceiverRegistered = false;
|
||||
private AudioManager audioManager;
|
||||
private final IntentFilter becomingNoisyReceiverIntentFilter =
|
||||
new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
|
||||
private boolean becomingNoisyReceiverRegistered;
|
||||
private final IntentFilter bluetoothConnectedIntentFilter =
|
||||
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
private boolean bluetoothConnectedRegistered = false;
|
||||
private final IntentFilter headsetReceiverIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
|
||||
private boolean headsetReceiverRegistered = false;
|
||||
private MediaSessionCompat mediaSession;
|
||||
private ContentObserver mediaStoreObserver;
|
||||
private HandlerThread musicPlayerHandlerThread;
|
||||
|
@ -291,59 +291,59 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
private HandlerThread queueSaveHandlerThread;
|
||||
private boolean queuesRestored;
|
||||
private int repeatMode;
|
||||
private int shuffleMode;
|
||||
private final SongPlayCountHelper songPlayCountHelper = new SongPlayCountHelper();
|
||||
private final BroadcastReceiver bluetoothReceiver =
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action != null) {
|
||||
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)
|
||||
&& PreferenceUtil.INSTANCE.isBluetoothSpeaker()) {
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.M) {
|
||||
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
|
||||
private int shuffleMode;
|
||||
private final SongPlayCountHelper songPlayCountHelper = new SongPlayCountHelper();
|
||||
private final BroadcastReceiver bluetoothReceiver =
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action != null) {
|
||||
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)
|
||||
&& PreferenceUtil.INSTANCE.isBluetoothSpeaker()) {
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.M) {
|
||||
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
|
||||
play();
|
||||
}
|
||||
} else {
|
||||
if (getAudioManager().isBluetoothA2dpOn()) {
|
||||
play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (getAudioManager().isBluetoothA2dpOn()) {
|
||||
play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private final PhoneStateListener phoneStateListener =
|
||||
new PhoneStateListener() {
|
||||
@Override
|
||||
public void onCallStateChanged(int state, String incomingNumber) {
|
||||
switch (state) {
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
// Not in call: Play music
|
||||
play();
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
// A call is dialing, active or on hold
|
||||
pause();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
super.onCallStateChanged(state, incomingNumber);
|
||||
}
|
||||
};
|
||||
private final BroadcastReceiver headsetReceiver =
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action != null) {
|
||||
if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
|
||||
int state = intent.getIntExtra("state", -1);
|
||||
switch (state) {
|
||||
case 0:
|
||||
pause();
|
||||
};
|
||||
private final PhoneStateListener phoneStateListener =
|
||||
new PhoneStateListener() {
|
||||
@Override
|
||||
public void onCallStateChanged(int state, String incomingNumber) {
|
||||
switch (state) {
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
// Not in call: Play music
|
||||
play();
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
// A call is dialing, active or on hold
|
||||
pause();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
super.onCallStateChanged(state, incomingNumber);
|
||||
}
|
||||
};
|
||||
private final BroadcastReceiver headsetReceiver =
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action != null) {
|
||||
if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
|
||||
int state = intent.getIntExtra("state", -1);
|
||||
switch (state) {
|
||||
case 0:
|
||||
pause();
|
||||
break;
|
||||
case 1:
|
||||
play();
|
||||
|
@ -1123,7 +1123,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
if (playback instanceof CrossFadePlayer) {
|
||||
((CrossFadePlayer) playback).sourceChangedByUser();
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
trackEndedByCrossfade = false;
|
||||
}
|
||||
if (openTrackAndPrepareNextAt(position)) {
|
||||
|
@ -1594,15 +1594,18 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||
mediaButtonIntent.setComponent(mediaButtonReceiverComponentName);
|
||||
|
||||
PendingIntent mediaButtonReceiverPendingIntent =
|
||||
PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
|
||||
PendingIntent mediaButtonReceiverPendingIntent;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, PendingIntent.FLAG_MUTABLE);
|
||||
} else {
|
||||
mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
|
||||
}
|
||||
|
||||
mediaSession =
|
||||
new MediaSessionCompat(
|
||||
this,
|
||||
"RetroMusicPlayer",
|
||||
mediaButtonReceiverComponentName,
|
||||
mediaButtonReceiverPendingIntent);
|
||||
mediaSession = new MediaSessionCompat(
|
||||
this,
|
||||
"RetroMusicPlayer",
|
||||
mediaButtonReceiverComponentName,
|
||||
mediaButtonReceiverPendingIntent);
|
||||
MediaSessionCallback mediasessionCallback =
|
||||
new MediaSessionCallback(getApplicationContext(), this);
|
||||
mediaSession.setFlags(
|
||||
|
|
|
@ -69,13 +69,21 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent {
|
|||
action.putExtra(MainActivity.EXPAND_PANEL, PreferenceUtil.isExpandPanel)
|
||||
action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
val clickIntent =
|
||||
PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_IMMUTABLE)
|
||||
} else {
|
||||
PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
}
|
||||
|
||||
val serviceName = ComponentName(service, MusicService::class.java)
|
||||
val intent = Intent(ACTION_QUIT)
|
||||
intent.component = serviceName
|
||||
val deleteIntent = PendingIntent.getService(service, 0, intent, 0)
|
||||
|
||||
val deleteIntent = PendingIntent.getService(
|
||||
service,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
val bigNotificationImageSize = service.resources
|
||||
.getDimensionPixelSize(R.dimen.notification_big_image_size)
|
||||
service.runOnUiThread {
|
||||
|
@ -191,6 +199,6 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent {
|
|||
val serviceName = ComponentName(service, MusicService::class.java)
|
||||
val intent = Intent(action)
|
||||
intent.component = serviceName
|
||||
return PendingIntent.getService(service, 0, intent, 0)
|
||||
return PendingIntent.getService(service, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<automotiveApp>
|
||||
<uses name="media" />
|
||||
</automotiveApp>
|
Loading…
Reference in a new issue