mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-08 14:47:54 -05:00
Merge yuzu-emu#12964
This commit is contained in:
parent
0b624b8bfa
commit
8495adfed5
@ -12,8 +12,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<uses-feature android:name="android.hardware.vulkan.version" android:version="0x401000" android:required="true" />
|
<uses-feature android:name="android.hardware.vulkan.version" android:version="0x401000" android:required="true" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
|
||||||
<uses-permission android:name="android.permission.NFC" />
|
<uses-permission android:name="android.permission.NFC" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
|
||||||
@ -80,10 +78,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
android:resource="@xml/nfc_tech_filter" />
|
android:resource="@xml/nfc_tech_filter" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service android:name="org.yuzu.yuzu_emu.utils.ForegroundService" android:foregroundServiceType="specialUse">
|
|
||||||
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="Keep emulation running in background"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name=".features.DocumentProvider"
|
android:name=".features.DocumentProvider"
|
||||||
android:authorities="${applicationId}.user"
|
android:authorities="${applicationId}.user"
|
||||||
|
@ -17,17 +17,6 @@ fun Context.getPublicFilesDir(): File = getExternalFilesDir(null) ?: filesDir
|
|||||||
|
|
||||||
class YuzuApplication : Application() {
|
class YuzuApplication : Application() {
|
||||||
private fun createNotificationChannels() {
|
private fun createNotificationChannels() {
|
||||||
val emulationChannel = NotificationChannel(
|
|
||||||
getString(R.string.emulation_notification_channel_id),
|
|
||||||
getString(R.string.emulation_notification_channel_name),
|
|
||||||
NotificationManager.IMPORTANCE_LOW
|
|
||||||
)
|
|
||||||
emulationChannel.description = getString(
|
|
||||||
R.string.emulation_notification_channel_description
|
|
||||||
)
|
|
||||||
emulationChannel.setSound(null, null)
|
|
||||||
emulationChannel.vibrationPattern = null
|
|
||||||
|
|
||||||
val noticeChannel = NotificationChannel(
|
val noticeChannel = NotificationChannel(
|
||||||
getString(R.string.notice_notification_channel_id),
|
getString(R.string.notice_notification_channel_id),
|
||||||
getString(R.string.notice_notification_channel_name),
|
getString(R.string.notice_notification_channel_name),
|
||||||
@ -39,7 +28,6 @@ class YuzuApplication : Application() {
|
|||||||
// Register the channel with the system; you can't change the importance
|
// Register the channel with the system; you can't change the importance
|
||||||
// or other notification behaviors after this
|
// or other notification behaviors after this
|
||||||
val notificationManager = getSystemService(NotificationManager::class.java)
|
val notificationManager = getSystemService(NotificationManager::class.java)
|
||||||
notificationManager.createNotificationChannel(emulationChannel)
|
|
||||||
notificationManager.createNotificationChannel(noticeChannel)
|
notificationManager.createNotificationChannel(noticeChannel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
package org.yuzu.yuzu_emu.activities
|
package org.yuzu.yuzu_emu.activities
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.app.PictureInPictureParams
|
import android.app.PictureInPictureParams
|
||||||
import android.app.RemoteAction
|
import android.app.RemoteAction
|
||||||
@ -45,7 +44,6 @@ import org.yuzu.yuzu_emu.features.settings.model.IntSetting
|
|||||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||||
import org.yuzu.yuzu_emu.model.EmulationViewModel
|
import org.yuzu.yuzu_emu.model.EmulationViewModel
|
||||||
import org.yuzu.yuzu_emu.model.Game
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
import org.yuzu.yuzu_emu.utils.ForegroundService
|
|
||||||
import org.yuzu.yuzu_emu.utils.InputHandler
|
import org.yuzu.yuzu_emu.utils.InputHandler
|
||||||
import org.yuzu.yuzu_emu.utils.Log
|
import org.yuzu.yuzu_emu.utils.Log
|
||||||
import org.yuzu.yuzu_emu.utils.MemoryUtil
|
import org.yuzu.yuzu_emu.utils.MemoryUtil
|
||||||
@ -74,11 +72,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
|
|
||||||
private val emulationViewModel: EmulationViewModel by viewModels()
|
private val emulationViewModel: EmulationViewModel by viewModels()
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
stopForegroundService(this)
|
|
||||||
super.onDestroy()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
Log.gameLaunched = true
|
Log.gameLaunched = true
|
||||||
ThemeHelper.setTheme(this)
|
ThemeHelper.setTheme(this)
|
||||||
@ -125,10 +118,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a foreground service to prevent the app from getting killed in the background
|
|
||||||
val startIntent = Intent(this, ForegroundService::class.java)
|
|
||||||
startForegroundService(startIntent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||||
@ -481,12 +470,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
activity.startActivity(launcher)
|
activity.startActivity(launcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopForegroundService(activity: Activity) {
|
|
||||||
val startIntent = Intent(activity, ForegroundService::class.java)
|
|
||||||
startIntent.action = ForegroundService.ACTION_STOP
|
|
||||||
activity.startForegroundService(startIntent)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun areCoordinatesOutside(view: View?, x: Float, y: Float): Boolean {
|
private fun areCoordinatesOutside(view: View?, x: Float, y: Float): Boolean {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
return true
|
return true
|
||||||
|
@ -34,7 +34,6 @@ import kotlinx.coroutines.launch
|
|||||||
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
import org.yuzu.yuzu_emu.R
|
import org.yuzu.yuzu_emu.R
|
||||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
|
||||||
import org.yuzu.yuzu_emu.databinding.ActivityMainBinding
|
import org.yuzu.yuzu_emu.databinding.ActivityMainBinding
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||||
import org.yuzu.yuzu_emu.fragments.AddGameFolderDialogFragment
|
import org.yuzu.yuzu_emu.fragments.AddGameFolderDialogFragment
|
||||||
@ -177,9 +176,6 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dismiss previous notifications (should not happen unless a crash occurred)
|
|
||||||
EmulationActivity.stopForegroundService(this)
|
|
||||||
|
|
||||||
setInsets()
|
setInsets()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,11 +294,6 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
EmulationActivity.stopForegroundService(this)
|
|
||||||
super.onDestroy()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setInsets() =
|
private fun setInsets() =
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(
|
ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
binding.root
|
binding.root
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
package org.yuzu.yuzu_emu.utils
|
|
||||||
|
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.app.Service
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.IBinder
|
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
import androidx.core.app.NotificationManagerCompat
|
|
||||||
import org.yuzu.yuzu_emu.R
|
|
||||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A service that shows a permanent notification in the background to avoid the app getting
|
|
||||||
* cleared from memory by the system.
|
|
||||||
*/
|
|
||||||
class ForegroundService : Service() {
|
|
||||||
companion object {
|
|
||||||
const val EMULATION_RUNNING_NOTIFICATION = 0x1000
|
|
||||||
|
|
||||||
const val ACTION_STOP = "stop"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showRunningNotification() {
|
|
||||||
// Intent is used to resume emulation if the notification is clicked
|
|
||||||
val contentIntent = PendingIntent.getActivity(
|
|
||||||
this,
|
|
||||||
0,
|
|
||||||
Intent(this, EmulationActivity::class.java),
|
|
||||||
PendingIntent.FLAG_IMMUTABLE
|
|
||||||
)
|
|
||||||
val builder =
|
|
||||||
NotificationCompat.Builder(this, getString(R.string.emulation_notification_channel_id))
|
|
||||||
.setSmallIcon(R.drawable.ic_stat_notification_logo)
|
|
||||||
.setContentTitle(getString(R.string.app_name))
|
|
||||||
.setContentText(getString(R.string.emulation_notification_running))
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
|
||||||
.setOngoing(true)
|
|
||||||
.setVibrate(null)
|
|
||||||
.setSound(null)
|
|
||||||
.setContentIntent(contentIntent)
|
|
||||||
startForeground(EMULATION_RUNNING_NOTIFICATION, builder.build())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBind(intent: Intent): IBinder? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate() {
|
|
||||||
showRunningNotification()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
||||||
if (intent == null) {
|
|
||||||
return START_NOT_STICKY
|
|
||||||
}
|
|
||||||
if (intent.action == ACTION_STOP) {
|
|
||||||
NotificationManagerCompat.from(this).cancel(EMULATION_RUNNING_NOTIFICATION)
|
|
||||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
|
||||||
stopSelfResult(startId)
|
|
||||||
}
|
|
||||||
return START_STICKY
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
NotificationManagerCompat.from(this).cancel(EMULATION_RUNNING_NOTIFICATION)
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,10 +4,6 @@
|
|||||||
<!-- General application strings -->
|
<!-- General application strings -->
|
||||||
<string name="app_name" translatable="false">yuzu</string>
|
<string name="app_name" translatable="false">yuzu</string>
|
||||||
<string name="app_disclaimer">This software will run games for the Nintendo Switch game console. No game titles or keys are included.<br /><br />Before you begin, please locate your <![CDATA[<b> prod.keys </b>]]> file on your device storage.<br /><br /><![CDATA[<a href="https://yuzu-emu.org/help/quickstart">Learn more</a>]]></string>
|
<string name="app_disclaimer">This software will run games for the Nintendo Switch game console. No game titles or keys are included.<br /><br />Before you begin, please locate your <![CDATA[<b> prod.keys </b>]]> file on your device storage.<br /><br /><![CDATA[<a href="https://yuzu-emu.org/help/quickstart">Learn more</a>]]></string>
|
||||||
<string name="emulation_notification_channel_name">Emulation is Active</string>
|
|
||||||
<string name="emulation_notification_channel_id" translatable="false">emulationIsActive</string>
|
|
||||||
<string name="emulation_notification_channel_description">Shows a persistent notification when emulation is running.</string>
|
|
||||||
<string name="emulation_notification_running">yuzu is running</string>
|
|
||||||
<string name="notice_notification_channel_name">Notices and errors</string>
|
<string name="notice_notification_channel_name">Notices and errors</string>
|
||||||
<string name="notice_notification_channel_id" translatable="false">noticesAndErrors</string>
|
<string name="notice_notification_channel_id" translatable="false">noticesAndErrors</string>
|
||||||
<string name="notice_notification_channel_description">Shows notifications when something goes wrong.</string>
|
<string name="notice_notification_channel_description">Shows notifications when something goes wrong.</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user