File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
cactus/src/main/java/com/gyf/cactus Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -43,22 +43,22 @@ class Cactus private constructor() {
4343 * 运行时回调广播ACTION
4444 */
4545 @JvmField
46- val CACTUS_WORK = " work" .fieldByPid
46+ val CACTUS_WORK = " work" .fieldById
4747 /* *
4848 * 停止时回调广播ACTION
4949 */
5050 @JvmField
51- val CACTUS_STOP = " stop" .fieldByPid
51+ val CACTUS_STOP = " stop" .fieldById
5252 /* *
5353 * 后台回调广播ACTION
5454 */
5555 @JvmField
56- val CACTUS_BACKGROUND = " background" .fieldByPid
56+ val CACTUS_BACKGROUND = " background" .fieldById
5757 /* *
5858 * 前台后调广播ACTION
5959 */
6060 @JvmField
61- val CACTUS_FOREGROUND = " foreground" .fieldByPid
61+ val CACTUS_FOREGROUND = " foreground" .fieldById
6262 /* *
6363 * key,通过广播形式获取启动次数
6464 */
Original file line number Diff line number Diff line change @@ -377,9 +377,14 @@ internal val Context.isCactusRunning
377377 }
378378
379379/* *
380- * 获得带pid值的字段值
380+ * 获得带id值的字段值
381381 */
382- internal val String .fieldByPid get() = " ${Constant .CACTUS_PACKAGE } .${this } .${Process .myPid()} "
382+ internal val String .fieldById get() = " ${Constant .CACTUS_PACKAGE } .${this } .$id "
383+
384+ /* *
385+ * 获取id
386+ */
387+ internal val id get() = if (Process .myUid() <= 0 ) Process .myPid() else Process .myUid()
383388
384389/* *
385390 * 解除DeathRecipient绑定
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ import android.content.ComponentName
99import android.content.Context
1010import android.content.Intent
1111import android.os.Build
12- import android.os.Process
1312import androidx.annotation.RequiresApi
1413import com.gyf.cactus.entity.CactusConfig
1514import com.gyf.cactus.entity.Constant
@@ -84,7 +83,7 @@ class CactusJobService : JobService() {
8483 if (mJobId != - 1 ) {
8584 mJobScheduler.cancel(mJobId)
8685 }
87- mJobId = Process .myPid()
86+ mJobId = id
8887 saveJobId(mJobId)
8988 val builder = JobInfo .Builder (
9089 mJobId,
You can’t perform that action at this time.
0 commit comments