app/build/intermediates/desugar_graph/debug/dexBuilderDebug/out/currentProject/dirs_bucket_9/graph.binBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tabBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.atBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tabBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.atBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tabBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.atBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tabBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.atBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tabBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.atBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab
@@ -1,2 +1,2 @@ 4 5 0 app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tabBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.atBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tabBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystreamBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.lenBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.lenBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.atBinary files differ
app/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_iBinary files differ
app/src/main/java/com/safeluck/floatwindow/MainActivity.kt
@@ -22,6 +22,9 @@ class MainActivity : ComponentActivity() { private var mediaAidlInterface: IMediaAidlInterface? = null private var serviceConnection: ServiceConnection? = null private var isServiceBound = false private val isServiceBoundState = mutableStateOf(false) private val callback = object : IMyCallback.Stub() { @Throws(RemoteException::class) @@ -36,18 +39,18 @@ super.onCreate(savedInstanceState) enableEdgeToEdge() var isServiceBoundState by mutableStateOf(false) val serviceConnection = object : ServiceConnection { serviceConnection = object : ServiceConnection { override fun onServiceConnected(name: ComponentName?, service: IBinder?) { mediaAidlInterface = IMediaAidlInterface.Stub.asInterface(service) isServiceBoundState = true isServiceBound = true isServiceBoundState.value = true Timber.d("FloatingService connected") } override fun onServiceDisconnected(name: ComponentName?) { mediaAidlInterface = null isServiceBoundState = false isServiceBound = false isServiceBoundState.value = false Timber.d("FloatingService disconnected") } } @@ -59,26 +62,16 @@ color = MaterialTheme.colorScheme.background ) { MainScreen( isServiceBound = isServiceBoundState, isServiceBound = isServiceBoundState.value, onBindService = { if (!isServiceBoundState) { if (!isServiceBoundState.value && serviceConnection != null) { val intent = Intent(this@MainActivity, FloatingService::class.java) bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) bindService(intent, serviceConnection!!, Context.BIND_AUTO_CREATE) Timber.d("Binding FloatingService") } }, onUnbindService = { if (isServiceBoundState) { try { mediaAidlInterface?.unregisterCallback(callback) } catch (e: RemoteException) { Timber.e(e, "Error unregistering callback") } unbindService(serviceConnection) isServiceBoundState = false mediaAidlInterface = null Timber.d("Unbinding FloatingService") } unbindServiceInternal() }, onStartAndroidRecord = { startAndroidRecord() }, onStopAndroidRecord = { stopAndroidRecord() }, @@ -210,15 +203,28 @@ } } override fun onDestroy() { super.onDestroy() if (mediaAidlInterface != null) { private fun unbindServiceInternal() { if (isServiceBound && serviceConnection != null) { try { mediaAidlInterface?.unregisterCallback(callback) } catch (e: RemoteException) { Timber.e(e, "Error unregistering callback") } try { unbindService(serviceConnection!!) Timber.d("Unbinding FloatingService") } catch (e: Exception) { Timber.e(e, "Error unbinding service") } isServiceBound = false isServiceBoundState.value = false mediaAidlInterface = null } } override fun onDestroy() { super.onDestroy() unbindServiceInternal() } } app/src/main/java/com/safeluck/floatwindow/manager/AndroidCameraRecordManager.java
@@ -186,15 +186,31 @@ } // 设置MediaRecorder // 注意:MediaRecorder的设置顺序非常重要,必须严格按照以下顺序: mediaRecorder = new MediaRecorder(); // 1. 设置数据源(必须在setOutputFormat之前) mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE); // 2. 设置输出格式(必须在setOutputFile和编码器之前) mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); // 3. 设置输出文件(必须在编码器之前) mediaRecorder.setOutputFile(currentVideoFile.getAbsolutePath()); // 4. 设置编码器(必须在setOutputFormat之后) mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); // 5. 设置编码参数(必须在编码器之后) mediaRecorder.setAudioEncodingBitRate(64000); // 64kbps mediaRecorder.setAudioSamplingRate(44100); // 44.1kHz mediaRecorder.setVideoEncodingBitRate(width * height * 3); mediaRecorder.setVideoFrameRate(20); mediaRecorder.setVideoSize(width, height); mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); // 6. 准备MediaRecorder mediaRecorder.prepare(); // 创建Surface