Android Question PhoneStateListener problem on Android 10

Bernd Ludwig

Member
Licensed User
Hi,
I wrote a simple Cellphone-Net-Monitor App using B4 with the PhoneStateListener Library Version 1.3. As Target-SDK I chose 27.
Worked really great on phones from Android 2.4 to Android 9. But today one of my phones was updated to Android 10 !
Oh what a shit: CellLocation is no longer something like "5952, 51522, -1" with the first two values representing lac and cid, the only response now on Android 10 is "<MASKED>".
I hope there will be a solution !

Regards, Bernd
 

Bernd Ludwig

Member
Licensed User
Hi Erel,
and thank you so much for the fast reply.
The problem concerns the Network Cell Identifiers Location Area Code (LAC) and Cell ID (CID), which is returned by PhoneStateListener's Event
onCellLocationChanged(CellLocation As String)

So it does not concern a geographic location, and it doesn't seem to me that FusedLocationProvider could not be helpful.

Here is some of the code:

In Manifest, I granted many permissions, but even the last one does not help:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>

Sub Process_Globals
Dim PSL As PhoneStateListener
Dim cellname As String
.
.

Sub Service_Create
PSL.Initialize ("PSL",False)
PSL.startListening()
.
.

PSL_onCellLocationChanged (CellLocation As String)
cellname = CellLocation
Log (cellname)
.
.

CellLocation returns on Android 9 : [11061,2909698,-1], where 11061 is the LAC, 2909698 is the CID

CellLocation returns on Android 10: [<MASKED>]

I tried an app from the PlayStore, "Netmonitor", and to my surprise it displays both LAC and CID even on Android 10, so there must be a way...?

Regards, Bernd
 
Upvote 0

Bernd Ludwig

Member
Licensed User
Hi again, dear Erel,

sorry, here are the code parts again:

B4X:
Sub Process_Globals
    Dim PSL As PhoneStateListener
    Dim cellname As String
    '.
    '.
End Sub

B4X:
Sub Service_Create
    PSL.Initialize ("PSL",False)
    PSL.startListening()
    '.
    '.
End Sub

B4X:
PSL_onCellLocationChanged (CellLocation As String)
    cellname = CellLocation
    Log (cellname)
    '.
    '.
End Sub


all the permissions come from other libraries or are needed for fuctionality.
You do not really mean only "COURSE" (though I tried it now, but without
result)? ACCESS_COURSE_LOCATION is in the manifest.

And it is working fine on all phones with Android 2.4 to 9, only one phone was
updated to Android 10 and since then LAC and CID are returned as <MASKED>.
It's a real trouble, as the app should mainly work on that phone.

Best regards, Bernd
 
Upvote 0

Bernd Ludwig

Member
Licensed User
Oh, it seems that I missed a lot of important knowlege - permissions at runtime. But I wonder
why everything went fine until now (though I had to set permissions for the app on the phone
back and forth once to make them working).
I'll try to read and struggle on. Thank you!
 
Upvote 0

Bernd Ludwig

Member
Licensed User
Hi once again,
and thank you for the help. But in this case the real problem was not a matter of permissions - though I confess that there is a lot I should learn...

The result of the event PSL_onCellLocationChanged really has changed with the update to Android 10 (at least on my example device - a Samsung Galaxy Xcover 4s with a Telekom.de SIM-card).
The event still comes, but the result (CellLocation as String) is no longer LAC, CID information as under Android 9, now it's only <MASKED>.

But I found out that LAC and CID can be found in the large amount of information in the object PSL.objServiceState.
So the problem is solved.

Maybe this Information might be useful for somebody else.
 
Upvote 0
Top