This commit is contained in:
lunaticbum 2026-04-08 15:58:56 +09:00
parent d7647f57e8
commit 80c06c5ab3
7 changed files with 49 additions and 5 deletions

View File

@ -110,7 +110,8 @@ void Renderer::handleAnimationState(ANativeWindow_Buffer& buffer, int surfaceWid
bool isCycleComplete = animationStrategy_->execute(this, buffer, currentMedia_, surfaceWidth, surfaceHeight); bool isCycleComplete = animationStrategy_->execute(this, buffer, currentMedia_, surfaceWidth, surfaceHeight);
if (isCycleComplete && nextMedia_.isValid()) { if ((isCycleComplete || forceNextFlag_) && nextMedia_.isValid()) {
forceNextFlag_ = false; // 플래그 초기화
lastAnimationState_ = animationStrategy_->getState(); lastAnimationState_ = animationStrategy_->getState();
predictedNextAnimationMode_ = predictNextAnimationMode(); predictedNextAnimationMode_ = predictNextAnimationMode();
currentState_ = RenderState::TRANSITIONING; currentState_ = RenderState::TRANSITIONING;

View File

@ -33,7 +33,10 @@ public:
void startRenderLoop(ANativeWindow* window); void startRenderLoop(ANativeWindow* window);
void stopRenderLoop(); void stopRenderLoop();
bool forceNextFlag_ = false;
// 공개 메서드 추가
void forceNext() { forceNextFlag_ = true; }
void setAnimationSpeed(float speed); void setAnimationSpeed(float speed);
void setAnimationMode(int mode); void setAnimationMode(int mode);
void setFadeDuration(int durationMs); void setFadeDuration(int durationMs);

View File

@ -113,6 +113,16 @@ Java_bums_lunatic_launcher_wall_NativeRenderer_nativeRender(JNIEnv* env, jobject
renderer->renderFrame(window); renderer->renderFrame(window);
ANativeWindow_release(window); ANativeWindow_release(window);
} }
extern "C"
JNIEXPORT void JNICALL
Java_bums_lunatic_launcher_wall_NativeRenderer_nativeForceNext(JNIEnv* env, jobject, jlong nativeHandle) {
Renderer* renderer = reinterpret_cast<Renderer*>(nativeHandle);
if (renderer) {
renderer->forceNext(); // Renderer에 추가할 함수 호출
}
}
extern "C" extern "C"
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_bums_lunatic_launcher_wall_NativeRenderer_nativeSetWeatherBitmap(JNIEnv* env, jobject, jlong nativeHandle, jobject bitmap) { Java_bums_lunatic_launcher_wall_NativeRenderer_nativeSetWeatherBitmap(JNIEnv* env, jobject, jlong nativeHandle, jobject bitmap) {

View File

@ -171,7 +171,11 @@ open class LauncherActivity : CommonActivity() {
// 각 구간별로 실행할 함수들 (예시) // 각 구간별로 실행할 함수들 (예시)
private fun handleTopLongPress() { private fun handleTopLongPress() {
// 상단 전용 기능 showToast("배경화면 전환 중...")
val intent = Intent("ACTION_NEXT_WALLPAPER")
// 같은 앱 내의 리시버로만 한정 (보안 및 정확성)
intent.setPackage(packageName)
sendBroadcast(intent)
} }
private fun handleBottomLongPress() { private fun handleBottomLongPress() {

View File

@ -2,6 +2,7 @@ package bums.lunatic.launcher.wall
import android.app.ActivityManager import android.app.ActivityManager
import android.app.WallpaperManager import android.app.WallpaperManager
import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.graphics.Bitmap import android.graphics.Bitmap
@ -159,6 +160,16 @@ class MyWallpaperService : WallpaperService() {
stopRendering() stopRendering()
} }
} }
private val nextMediaReceiver = object : android.content.BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent?) {
if (intent?.action == "ACTION_NEXT_WALLPAPER") {
Log.d(TAG, "Manual next wallpaper requested via Broadcast")
// 현재 콜백 객체의 함수를 직접 호출하여 다음 미디어로 넘김
nextMediaCallback.onNextMediaRequested()
nativeRenderer?.forceNext()
}
}
}
override fun onCreate(surfaceHolder: SurfaceHolder) { override fun onCreate(surfaceHolder: SurfaceHolder) {
super.onCreate(surfaceHolder) super.onCreate(surfaceHolder)
@ -166,7 +177,12 @@ class MyWallpaperService : WallpaperService() {
Log.d(TAG, "onCreate: Engine created.") Log.d(TAG, "onCreate: Engine created.")
wasInPreview = isPreview() wasInPreview = isPreview()
Log.d(TAG, "onCreate: Engine created. Initial isPreview = $wasInPreview") Log.d(TAG, "onCreate: Engine created. Initial isPreview = $wasInPreview")
val filter = IntentFilter("ACTION_NEXT_WALLPAPER")
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
registerReceiver(nextMediaReceiver, filter, Context.RECEIVER_NOT_EXPORTED)
} else {
registerReceiver(nextMediaReceiver, filter)
}
ensureHandlerThread() ensureHandlerThread()
} }
@ -259,6 +275,11 @@ class MyWallpaperService : WallpaperService() {
if (::handlerThread.isInitialized) { if (::handlerThread.isInitialized) {
handlerThread.quitSafely() handlerThread.quitSafely()
} }
try {
unregisterReceiver(nextMediaReceiver)
} catch (e: Exception) {
// 리시버가 등록되지 않았을 경우 예외 방지
}
} }

View File

@ -41,6 +41,12 @@ open class NativeRenderer {
} }
} }
fun forceNext() {
if (nativeHandle != 0L) {
nativeForceNext(nativeHandle)
}
}
fun startNextPreload(fd: Int) { fun startNextPreload(fd: Int) {
if (nativeHandle != 0L) { if (nativeHandle != 0L) {
nativeStartNextPreload(nativeHandle, fd) nativeStartNextPreload(nativeHandle, fd)
@ -124,6 +130,7 @@ open class NativeRenderer {
private external fun nativeGetDebugInfo(nativeHandle: Long): String private external fun nativeGetDebugInfo(nativeHandle: Long): String
private external fun nativeSetPageTurnDelay(nativeHandle: Long, duration: Int) private external fun nativeSetPageTurnDelay(nativeHandle: Long, duration: Int)
private external fun nativeSetTransitionMode(nativeHandle: Long, mode: Int) private external fun nativeSetTransitionMode(nativeHandle: Long, mode: Int)
private external fun nativeForceNext(nativeHandle: Long)
// --- Companion Object --- // --- Companion Object ---
companion object { companion object {

View File

@ -167,7 +167,6 @@ class TorrentService : Service() {
// 상태가 실제로 변했을 때만 업데이트하여 불필요한 로그와 로직 실행을 방지합니다. // 상태가 실제로 변했을 때만 업데이트하여 불필요한 로그와 로직 실행을 방지합니다.
if (isWifiConnected != wifiNow) { if (isWifiConnected != wifiNow) {
isWifiConnected = wifiNow isWifiConnected = wifiNow
Blog.LOGE("와이파이 상태 변경: $isWifiConnected")
updateSessionState() updateSessionState()
} }
} }
@ -192,7 +191,6 @@ class TorrentService : Service() {
if (curentTime - lastUpdateTime > 5000) { if (curentTime - lastUpdateTime > 5000) {
serviceScope.launch { serviceScope.launch {
lastUpdateTime = curentTime lastUpdateTime = curentTime
Blog.LOGE("isWifiConnected $isWifiConnected isCharging $isCharging")
val vector = session.swig().get_torrents() val vector = session.swig().get_torrents()
// (핸들, 계산된 우선순위 점수) // (핸들, 계산된 우선순위 점수)
val torrentsWithMetadata = mutableListOf<kotlin.Pair<TorrentHandle, Int>>() val torrentsWithMetadata = mutableListOf<kotlin.Pair<TorrentHandle, Int>>()