Quellcode durchsuchen

feat: delete foreground service

tongmengxiao vor 4 Monaten
Ursprung
Commit
47f77186e9

+ 0 - 3
app/src/main/AndroidManifest.xml

@@ -13,9 +13,6 @@
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.CAMERA"/>
-    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA"/>
-    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
-    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
     <uses-permission android:name="android.permission.RECORD_AUDIO"/>
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

+ 14 - 35
home/src/main/java/com/swago/home/HomeFragment.kt

@@ -107,42 +107,21 @@ class HomeFragment : BaseXFragment<FragmentHomeBinding>() {
         binding.ivLive.setOnClickListener(object :NoDoubleClickListener(){
             override fun onClick() {
                 binding.ivLive.isEnabled = false
-                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE){
-                    PermissionX.init(this@HomeFragment)
-                        .permissions(Manifest.permission.CAMERA,
-                            Manifest.permission.RECORD_AUDIO,
-                            Manifest.permission.FOREGROUND_SERVICE_CAMERA,
-                            Manifest.permission.FOREGROUND_SERVICE_MICROPHONE)
-                        .request { allGranted, grantedList, deniedList ->
-                            if (allGranted) {
-                                ARouter.getInstance().build(ARouteConstant.Room.anchor).navigation()
-                            } else {
-                                binding.ivLive.isEnabled = true
-                                Toast.makeText(
-                                    AppContext.getContext(),
-                                    AppContext.getContext().getString(R.string.these_permissions_denied)+" $deniedList",
-                                    Toast.LENGTH_LONG
-                                ).show()
-                            }
+                PermissionX.init(this@HomeFragment)
+                    .permissions(Manifest.permission.CAMERA,
+                        Manifest.permission.RECORD_AUDIO)
+                    .request { allGranted, grantedList, deniedList ->
+                        if (allGranted) {
+                            ARouter.getInstance().build(ARouteConstant.Room.anchor).navigation()
+                        } else {
+                            binding.ivLive.isEnabled = true
+                            Toast.makeText(
+                                AppContext.getContext(),
+                                AppContext.getContext().getString(R.string.these_permissions_denied)+" $deniedList",
+                                Toast.LENGTH_LONG
+                            ).show()
                         }
-                } else {
-                    PermissionX.init(this@HomeFragment)
-                        .permissions(Manifest.permission.CAMERA,
-                            Manifest.permission.RECORD_AUDIO)
-                        .request { allGranted, grantedList, deniedList ->
-                            if (allGranted) {
-                                ARouter.getInstance().build(ARouteConstant.Room.anchor).navigation()
-                            } else {
-                                binding.ivLive.isEnabled = true
-                                Toast.makeText(
-                                    AppContext.getContext(),
-                                    AppContext.getContext().getString(R.string.these_permissions_denied)+" $deniedList",
-                                    Toast.LENGTH_LONG
-                                ).show()
-                            }
-                        }
-                }
-
+                    }
             }
         })
 

+ 0 - 15
room/src/main/java/com/swago/room/anchor/AnchorRoomActivity.kt

@@ -51,9 +51,6 @@ import com.swago.room.lianmai.LianMaiVm
 import com.swago.room.pk.IPKListener
 import com.swago.room.pk.PKStateManager
 import com.swago.room.pk.PkVm
-import com.swago.room.service.AgoraForegroundService
-import com.swago.room.service.AgoraForegroundService.ACTION_START_FOREGROUND_SERVICE
-import com.swago.room.service.AgoraForegroundService.ACTION_STOP_FOREGROUND_SERVICE
 import com.swago.room.vm.MsgVm
 import com.swago.room.vm.RoomOtherVm
 import com.swago.room.vm.RoomVm
@@ -76,8 +73,6 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
     private val pkVm by viewModels<PkVm>()
     private val lianMaiVm by viewModels<LianMaiVm>()
 
-    private var agoraService: Intent? = null
-
     private val fragments = arrayListOf(NoContentFragment(), AnchorRoomFragment())
 
     private val adapter = SwagoAdapter(fragments, supportFragmentManager)
@@ -109,7 +104,6 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
         AudioRoomManager.addListener(this)
         initPeerAnchorLayoutParams()
         window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
-        agoraService = Intent(this, AgoraForegroundService::class.java)
         AgoraManager.initializeEngine(this, this)
         AgoraManager.setVideoConfiguration()
         AgoraManager.setVideoAudio(pullVideo = true, pullAudio = true, pushVideo = true, pushAudio = true)
@@ -376,25 +370,16 @@ class AnchorRoomActivity : AbsAnchorActivity<ActivityAnchorRoomBinding, IRoomInf
 
     override fun onResume() {
         super.onResume()
-        agoraService?.let {
-            it.action = ACTION_STOP_FOREGROUND_SERVICE
-            startService(it)
-        }
     }
 
     override fun onPause() {
         super.onPause()
-        agoraService?.let {
-            it.action = ACTION_START_FOREGROUND_SERVICE
-            startService(it)
-        }
     }
 
     override fun onDestroy() {
         anchorCloseDialog = null
         PKStateManager.removePKListener(this)
         AudioRoomManager.removeListener(this)
-        agoraService?.let { stopService(it) }
         super.onDestroy()
     }