Partially fix Lockscreen controls

This commit is contained in:
Prathamesh More 2022-07-06 14:43:06 +05:30
parent f5063de70f
commit 31df20ffe5
4 changed files with 13 additions and 8 deletions

View file

@ -22,6 +22,7 @@
android:name="android.permission.WRITE_SETTINGS" android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" /> tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission <uses-permission
android:name="android.permission.BLUETOOTH_CONNECT" android:name="android.permission.BLUETOOTH_CONNECT"
android:usesPermissionFlags="neverForLocation" android:usesPermissionFlags="neverForLocation"
@ -125,7 +126,8 @@
<activity android:name=".activities.PermissionActivity" /> <activity android:name=".activities.PermissionActivity" />
<activity <activity
android:name=".activities.LockScreenActivity" android:name=".activities.LockScreenActivity"
android:launchMode="singleTop" android:excludeFromRecents="true"
android:launchMode="singleTask"
android:showOnLockScreen="true" /> android:showOnLockScreen="true" />
<activity <activity
android:name=".fragments.backup.RestoreActivity" android:name=".fragments.backup.RestoreActivity"

View file

@ -84,12 +84,11 @@ class LockScreenActivity : AbsMusicServiceActivity() {
private fun lockScreenInit() { private fun lockScreenInit() {
if (VersionUtils.hasOreoMR1()) { if (VersionUtils.hasOreoMR1()) {
setShowWhenLocked(true) setShowWhenLocked(true)
val keyguardManager = getSystemService<KeyguardManager>() //setTurnScreenOn(true)
keyguardManager?.requestDismissKeyguard(this, null)
} else { } else {
this.window.addFlags( window.addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED // or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
) )
} }
} }

View file

@ -197,7 +197,7 @@ class MusicService : MediaBrowserServiceCompat(),
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
if (isLockScreen && isPlaying) { if (isLockScreen && isPlaying) {
val lockIntent = Intent(context, LockScreenActivity::class.java) val lockIntent = Intent(context, LockScreenActivity::class.java)
lockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP) lockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(lockIntent) startActivity(lockIntent)
} }
} }
@ -279,7 +279,7 @@ class MusicService : MediaBrowserServiceCompat(),
uiThreadHandler = Handler(Looper.getMainLooper()) uiThreadHandler = Handler(Looper.getMainLooper())
registerReceiver(widgetIntentReceiver, IntentFilter(APP_WIDGET_UPDATE)) registerReceiver(widgetIntentReceiver, IntentFilter(APP_WIDGET_UPDATE))
registerReceiver(updateFavoriteReceiver, IntentFilter(FAVORITE_STATE_CHANGED)) registerReceiver(updateFavoriteReceiver, IntentFilter(FAVORITE_STATE_CHANGED))
registerReceiver(lockScreenReceiver, IntentFilter(Intent.ACTION_SCREEN_OFF)) registerReceiver(lockScreenReceiver, IntentFilter(Intent.ACTION_SCREEN_ON))
sessionToken = mediaSession?.sessionToken sessionToken = mediaSession?.sessionToken
notificationManager = getSystemService() notificationManager = getSystemService()
initNotification() initNotification()

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="download_policy">always</string>
</resources>