mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 19:55:33 -04:00
universal7885: FM: Fix sepolicy denial and crash of app
- Don't crash on no headphones detected - Use progressdialog instead of disabling touch - Don't crash while manually updating freqs list - Address selinux denial on aidl
This commit is contained in:
parent
25c497ade3
commit
e682783f6b
6 changed files with 32 additions and 12 deletions
|
|
@ -40,4 +40,5 @@
|
|||
<string name="retry">Retry</string>
|
||||
<string name="exit_app">Exit App</string>
|
||||
<string name="fm_radio_freq">FM %s Mhz</string>
|
||||
<string name="update_freq">Updating channel freqs list</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -64,12 +64,12 @@ class FMRadioService : Service() {
|
|||
}
|
||||
ACTION_START -> {
|
||||
mMediaSession = MediaSession(this, "FMRadio")
|
||||
mContext = this
|
||||
setPlaybackState()
|
||||
mMediaSession.isActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
mContext = this
|
||||
sendMetaData("FM ${mNativeFMInterface.mDefaultCtl.getValue(GetType.GET_TYPE_FM_FREQ).toFloat() / 1000} Mhz")
|
||||
startForeground(51, pushNotification())
|
||||
Log.i("--- FMRadio Background (OUT) ---")
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
|
|||
import com.google.android.material.color.DynamicColors
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import vendor.eureka.hardware.fmradio.SetType
|
||||
import vendor.eureka.hardware.fmradio.GetType
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private lateinit var mIntent: Intent
|
||||
|
|
@ -96,6 +97,7 @@ class MainActivity : AppCompatActivity() {
|
|||
}, 500)
|
||||
}
|
||||
.show()
|
||||
return
|
||||
}
|
||||
val receiverFilter = IntentFilter(Intent.ACTION_HEADSET_PLUG)
|
||||
registerReceiver(mWiredHeadsetReceiver, receiverFilter)
|
||||
|
|
@ -167,16 +169,23 @@ class MainActivity : AppCompatActivity() {
|
|||
override fun onPause() {
|
||||
super.onPause()
|
||||
Log.i("Application onPause")
|
||||
mIntent.action = ACTION_START
|
||||
startService(mIntent)
|
||||
if (mFMInterface.mDefaultCtl.getValue(GetType.GET_TYPE_FM_MUTEX_LOCKED) == 0) {
|
||||
mIntent.action = ACTION_START
|
||||
startService(mIntent)
|
||||
mStartedService = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRestart() {
|
||||
super.onRestart()
|
||||
stopService(mIntent)
|
||||
if (mStartedService) {
|
||||
stopService(mIntent)
|
||||
mStartedService = false
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ACTION_START = "com.eurekateam.fmradio.START"
|
||||
private var mStartedService = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.eurekateam.fmradio.fragments
|
||||
|
||||
import android.app.ProgressDialog
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
|
|
@ -56,19 +57,23 @@ class ChannelListFragment :
|
|||
|
||||
override fun onClick(v: View?) {
|
||||
mNativeIF.mDefaultCtl.setValue(SetType.SET_TYPE_FM_SEARCH_START, 0)
|
||||
requireActivity().window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
|
||||
val loading = ProgressDialog(requireContext())
|
||||
loading.setMessage(requireContext().resources.getString(R.string.update_freq))
|
||||
loading.setCancelable(false)
|
||||
loading.setInverseBackgroundForced(false)
|
||||
loading.show()
|
||||
WaitUntil.setTimer(
|
||||
requireActivity(),
|
||||
object : IWaitUntil {
|
||||
override fun cond(): Boolean = mNativeIF.mDefaultCtl.getValue(GetType.GET_TYPE_FM_MUTEX_LOCKED) == 0
|
||||
override fun todo() {
|
||||
if (isAdded()) {
|
||||
loading.hide()
|
||||
(requireActivity() as MainActivity).getMySupportFragmentManager().apply {
|
||||
beginTransaction().remove(this@ChannelListFragment).commit()
|
||||
executePendingTransactions()
|
||||
beginTransaction().add(R.id.container_view, this@ChannelListFragment).commit()
|
||||
beginTransaction().add(R.id.container_view, this@ChannelListFragment).commit()
|
||||
}
|
||||
requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.eurekateam.fmradio.fragments
|
||||
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Configuration
|
||||
|
|
@ -123,9 +124,12 @@ class MainFragment :
|
|||
mFMInterface.mDefaultCtl.setValue(SetType.SET_TYPE_FM_FREQ, mRestoreFreq)
|
||||
mFMFreq.text = mCleanFormat.format(mRestoreFreq.toFloat() / 1000)
|
||||
mFMInterface.mDevCtl.setValue(SetType.SET_TYPE_FM_THREAD, 1)
|
||||
Toast.makeText(requireContext(), "Updating freqs list... Please wait", Toast.LENGTH_LONG).show()
|
||||
requireActivity().window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
|
||||
mFMInterface.mDefaultCtl.setValue(SetType.SET_TYPE_FM_SEARCH_START, 0)
|
||||
val loading = ProgressDialog(requireContext())
|
||||
loading.setMessage(requireContext().resources.getString(R.string.update_freq))
|
||||
loading.setCancelable(false)
|
||||
loading.setInverseBackgroundForced(false)
|
||||
loading.show()
|
||||
mFMInterface.mDefaultCtl.setValue(SetType.SET_TYPE_FM_SEARCH_START, 0)
|
||||
WaitUntil.setTimer(
|
||||
requireActivity(),
|
||||
object : IWaitUntil {
|
||||
|
|
@ -136,8 +140,7 @@ class MainFragment :
|
|||
if (mSharedPref.getBoolean("fav_$i", false)) mFavList += i
|
||||
}
|
||||
if (!mFMPower) mUpdateEnableDisable(false)
|
||||
requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
|
||||
Toast.makeText(requireContext(), "Done", Toast.LENGTH_SHORT).show()
|
||||
loading.hide()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,5 +13,7 @@ allow hal_fmradio_default sysfs_virtual:dir search;
|
|||
allow hal_fmradio_default fm_radio_device:chr_file { read write open ioctl };
|
||||
|
||||
allow hal_fmradio_default hal_audio_route_service:service_manager find;
|
||||
allow hal_fmradio_default self:capability kill;
|
||||
allow hal_fmradio_default system_app:process signull;
|
||||
|
||||
binder_call(hal_fmradio_default, hal_audio_route_default)
|
||||
|
|
|
|||
Loading…
Reference in a new issue