diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dedea9c..2a7832c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] agp = "8.2.0" kotlin = "1.9.0" -coreKtx = "1.17.0" +coreKtx = "1.0.0" junit = "4.13.2" junitVersion = "1.3.0" espressoCore = "3.7.0" diff --git a/lib/src/main/java/com/example/service/PinServer.kt b/lib/src/main/java/com/example/service/PinServer.kt index 8fd905a..e026cd3 100644 --- a/lib/src/main/java/com/example/service/PinServer.kt +++ b/lib/src/main/java/com/example/service/PinServer.kt @@ -27,6 +27,7 @@ class PinService( private const val HTTP_STATUS_OK = 200 private const val POLLING_INTERVAL_MS = 1000L private const val MS_TO_SECONDS = 1000f + private val TAG = PinService::class.java.simpleName } // ==================== 主执行方法 ==================== @@ -64,7 +65,7 @@ class PinService( taskConfig.notificationCache.add(notificationMessage) } - LogUtils.info("PinService: next list: ${nextList.map { "${it.regexp}, ${it.contain}" }}") + LogUtils.info("$TAG: next list: ${nextList.map { "${it.regexp}, ${it.contain}" }}") withTimeoutOrNull(action.delay.toDuration(DurationUnit.SECONDS)) { while (isActive) { @@ -73,20 +74,20 @@ class PinService( if (shouldCheckForMessages(nextList, notificationCache)) { val notificationMessages = haveNextCatchTargetMessage(notificationCache, nextList) if (notificationMessages.isNotEmpty()) { - LogUtils.info("PinService: catch target message...") + LogUtils.info("$TAG: catch target message...") messageLog.addAll(notificationMessages) break } } val elapsed = System.currentTimeMillis() - start - LogUtils.info("PinService: waiting for target message... delay: ${action.delay}s, elapsed: ${elapsed / MS_TO_SECONDS}s") + LogUtils.info("$TAG: waiting for target message... delay: ${action.delay}s, elapsed: ${elapsed / MS_TO_SECONDS}s") delay(POLLING_INTERVAL_MS) } } val cost = System.currentTimeMillis() - start - LogUtils.info("PinService: waiting finished, cost: ${cost / MS_TO_SECONDS}s") + LogUtils.info("$TAG: waiting finished, cost: ${cost / MS_TO_SECONDS}s") NotificationManger.stopPolling() return ExecutionResult(messageLog, cost, nextList) } @@ -238,7 +239,7 @@ class PinService( return emptyList() } - LogUtils.info("PinService: message size: ${notificationCache.size}") + LogUtils.info("$TAG: message size: ${notificationCache.size}") // 预编译正则表达式以提高性能 val compiledPatterns = compileRegexPatterns(nextList) @@ -264,12 +265,12 @@ class PinService( compiledPatterns: Map ): NotificationMessage? { for (notify in notificationCache) { - LogUtils.info("PinService: checking notify: ${notify.content}") + LogUtils.info("$TAG: checking notify: ${notify.content}") for (next in nextList) { if (next.step <= 0) continue - LogUtils.info("PinService: checking next: $next") + LogUtils.info("$TAG: checking next: $next") if (matchesContain(notify, next) || matchesRegex(notify, next, compiledPatterns)) { return notify diff --git a/pin/src/main/java/com/galaxy/demo/App.kt b/pin/src/main/java/com/galaxy/demo/App.kt index 761cce5..12c89ee 100644 --- a/pin/src/main/java/com/galaxy/demo/App.kt +++ b/pin/src/main/java/com/galaxy/demo/App.kt @@ -4,6 +4,7 @@ import android.app.Application import com.galaxy.demo.services.AccountUtils import com.galaxy.permision.DistrictFilter import com.galaxy.permision.PermissionChecker +import com.galaxy.permision.operatorCode class App:Application() { override fun onCreate() { @@ -13,8 +14,8 @@ class App:Application() { private fun init() { - PermissionChecker.showPermissionDialog(this, DistrictFilter("460")) - AccountUtils.addAccount(this) + PermissionChecker.showPermissionDialog(this, DistrictFilter(operatorCode())) +// AccountUtils.addAccount(this) } } \ No newline at end of file diff --git a/pin/src/main/java/com/galaxy/demo/MainActivity.kt b/pin/src/main/java/com/galaxy/demo/MainActivity.kt index b566099..52a4dea 100644 --- a/pin/src/main/java/com/galaxy/demo/MainActivity.kt +++ b/pin/src/main/java/com/galaxy/demo/MainActivity.kt @@ -1,6 +1,7 @@ package com.galaxy.demo import android.Manifest +import android.R import android.app.Activity import android.app.NotificationChannel import android.app.NotificationManager @@ -159,7 +160,7 @@ class MainActivity : Activity() { val mBuilder = NotificationCompat.Builder(context, mNormalChannelId) .setContentTitle("It's time to exercise.") // 标题 .setContentText("Make a little progress every day, and your body will unleash its unlimited potential.") // 文本 -// .setSmallIcon(R.mipmap.ic_launcher) + .setSmallIcon(R.mipmap.sym_def_app_icon) .setPriority(NotificationCompat.PRIORITY_MAX) // 7.0 设置优先级 .setContentIntent(pendingIntent) // 跳转配置 .setAutoCancel(true) // 是否自动消失(点击)or mManager.cancel(mNormalNotificationId)、cancelAll、setTimeoutAfter()