From 09b711871d1cfb6979b4fa0a07cba107db7a5976 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Mon, 16 Nov 2026 13:57:15 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=AA=85=EC=96=B8/=EC=9A=B4=EC=84=B8?= =?UTF-8?q?=20API=20=EC=88=98=EC=A7=91=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=EB=B0=8F=20=EC=95=A0=ED=94=8C=EB=AE=A4=EC=A7=81=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EC=8B=A4=ED=96=89=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ForeGroundService.kt: * QuoteFetchWorker.doWork() 즉시 Result.success() 반환으로 zenquotes/korean-advice API 호출 비활성화 * refreshFeeds()에서 QuoteFetchWork 주기적 등록 제거 및 workManager.cancelUniqueWork("QuoteFetchWork") 호출로 기존 예약 작업 취소 * launchAppleMusic() 메서드 및 bluetoothreceiver 내 애플뮤직 자동 실행 관련 주석 코드 제거 - 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (16s, 133 actionable tasks) --- .../launcher/helpers/ForeGroundService.kt | 75 +------------------ 1 file changed, 4 insertions(+), 71 deletions(-) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt b/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt index 4f34d128..d4222912 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/helpers/ForeGroundService.kt @@ -87,13 +87,8 @@ data class KorAdviceResponse(val author: String, val message: String) class QuoteFetchWorker(private val context: Context, params: WorkerParameters) : CoroutineWorker(context, params) { override suspend fun doWork(): Result { - return try { - fetchAndSaveQuotes() - Result.success() - } catch (e: Exception) { - Blog.LOGE("QuoteFetchWorker Failed", e) - Result.retry() // 실패 시 재시도 - } + // 명언/운세 API 수집 비활성화 + return Result.success() } private suspend fun fetchAndSaveQuotes() { @@ -739,22 +734,8 @@ class ForeGroundService : Service() { workManager.enqueueUniquePeriodicWork("AggregatedSystemWork", ExistingPeriodicWorkPolicy.KEEP, systemRequest) workManager.enqueueUniquePeriodicWork("AggregatedNewsWork", ExistingPeriodicWorkPolicy.KEEP, newsRequest) - - val quoteRequest = PeriodicWorkRequestBuilder( - 2, TimeUnit.HOURS // 1시간 간격 설정 - ) - .setConstraints( - Constraints.Builder() - .setRequiredNetworkType(NetworkType.CONNECTED) // 네트워크가 연결된 상태에서만 실행 - .build() - ) - .build() - - workManager.enqueueUniquePeriodicWork( - "QuoteFetchWork", - ExistingPeriodicWorkPolicy.KEEP, - quoteRequest - ) + // 명언/운세 API 수집 비활성화: 기존 예약 작업 취소 + workManager.cancelUniqueWork("QuoteFetchWork") } @@ -866,60 +847,12 @@ class ForeGroundService : Service() { val majorClass = device?.bluetoothClass?.majorDeviceClass if (majorClass == BluetoothClass.Device.Major.AUDIO_VIDEO) { Blog.LOGE("Audio Bluetooth Connected: ${device?.name ?: "Unknown"}") -// if ("BUMz pod".equals(device?.name)) { -// launchAppleMusic(context) -// } } } } } - private fun launchAppleMusic(context: Context) { - try { - val appleMusicPackage = "com.apple.android.music" - val launchIntent = context.packageManager.getLaunchIntentForPackage(appleMusicPackage) - - if (launchIntent != null) { - // 서비스(백그라운드)에서 화면을 띄우려면 NEW_TASK 플래그가 필수입니다. - launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) - context.startActivity(launchIntent) - Blog.LOGE("애플뮤직 자동 실행 완료") - serviceScope.launch(Dispatchers.Main) { - delay(1500) // 1.5초 대기 (기기 속도에 따라 1000~2000 사이로 조절 가능) - - val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager - val eventTime = SystemClock.uptimeMillis() - - // 재생 버튼 누름 (ACTION_DOWN) - val downEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY, 0) - audioManager.dispatchMediaKeyEvent(downEvent) - - // 재생 버튼 뗌 (ACTION_UP) - val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY, 0) - audioManager.dispatchMediaKeyEvent(upEvent) - - Blog.LOGE("애플뮤직 미디어 재생(Play) 명령 전송 완료 🎵") - delay(300) // 시스템이 재생 명령을 처리할 수 있도록 아주 잠깐 대기 - - // 💡 3. 홈 화면(런처)으로 즉시 강제 복귀 - val homeIntent = Intent(Intent.ACTION_MAIN).apply { - addCategory(Intent.CATEGORY_HOME) - flags = Intent.FLAG_ACTIVITY_NEW_TASK - } - context.startActivity(homeIntent) - Blog.LOGE("런처(홈) 화면으로 복귀 완료") - } - - } else { - Blog.LOGE("애플뮤직 앱이 기기에 설치되어 있지 않습니다.") - } - } catch (e: Exception) { - e.printStackTrace() - Blog.LOGE("애플뮤직 실행 중 오류 발생: ${e.message}") - } - } - override fun onDestroy() { try { unregisterReceiver(bluetoothreceiver)