2

I have a .aar which has a android service ( named CommonService ) packaged in it. The .aar is delivered to two apps. Each app will perform startService() on this service.

Will there be two instance of the service running ? Following logs ( taken by executing adb dumpsys activity services CommonService ) suggest that two instances are running.

If I have to restrict the instantiation of the CommonService to one, is it possible when it is being delivered as part of a .aar?

========= Dumpsys Log Start =========================

ACTIVITY MANAGER SERVICES (dumpsys activity services)

User 0 active services:

  • ServiceRecord{63baa27 u0 com.example.wspace1.app2withtestservice/com.example.commservice.CommonService}

    intent={cmp=com.example.wspace1.app2withtestservice/com.example.commservice.CommonService VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)}}

    packageName=com.example.wspace1.app2withtestservice

    processName=com.example.wspace1.app2withtestservice

    baseDir=/data/app/com.example.wspace1.app2withtestservice-2/base.apk

    dataDir=/data/user/0/com.example.wspace1.app2withtestservice

    app=ProcessRecord{b41ccb6 15824:com.example.wspace1.app2withtestservice/u0a264}

    createTime=-4m50s301ms startingBgTimeout=--

    lastActivity=-4m30s679ms restartTime=-4m50s301ms createdFromFg=true

    startRequested=true delayedStop=false stopIfKilled=false callStart=true lastStartId=1

    Bindings:

    • IntentBindRecord{8e6d1a0}:

      intent={cmp=com.example.wspace1.app2withtestservice/com.example.commservice.CommonService VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)}}

      binder=android.os.BinderProxy@fe63159

      requested=true received=true hasBound=false doRebind=false

  • ServiceRecord{76b737e u0 com.example.wspace1.app1withtestservice/com.example.commservice.CommonService}

    intent={cmp=com.example.wspace1.app1withtestservice/com.example.commservice.CommonService VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)}}

    packageName=com.example.wspace1.app1withtestservice

    processName=com.example.wspace1.app1withtestservice

    baseDir=/data/app/com.example.wspace1.app1withtestservice-1/base.apk

    dataDir=/data/user/0/com.example.wspace1.app1withtestservice

    app=ProcessRecord{d0352e6 11338:com.example.wspace1.app1withtestservice/u0a263}

    createTime=-5m54s5ms startingBgTimeout=--

    lastActivity=-5m43s845ms restartTime=-5m54s4ms createdFromFg=true

    startRequested=true delayedStop=false stopIfKilled=false callStart=true lastStartId=1

    Bindings:

    • IntentBindRecord{d8c47df}:

      intent={cmp=com.example.wspace1.app1withtestservice/com.example.commservice.CommonService VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)}}

      binder=android.os.BinderProxy@81abc2c

      requested=true received=true hasBound=false doRebind=false

0 Answers0