Zfinix / carrier_info

📱 Carrier Info gets networkType, networkGeneration, mobileCountryCode, mobileCountryCode, e.t.c from both android and iOS devices.
MIT License
34 stars 48 forks source link

Example app on AOSP android 11 gives only null values #14

Closed nicolaspernoud closed 2 years ago

nicolaspernoud commented 2 years ago

Hello,

Running the example app with flutter and a Android 11 AOSP (without google play services) emulator gives null values. That seems to be the same with a AOSP Android 11 Device running on lineageOS (without google play services). Capture d’écran de 2022-01-06 09-23-38

Thanks and best regards.

Zfinix commented 2 years ago

That’s odd, I’ll check it out

On Thu, 6 Jan 2022 at 9:26 AM, Nicolas PERNOUD @.***> wrote:

Hello,

Running the example app with flutter and a Android 11 AOSP (without google play services) emulator gives null values. That seems to be the same with a AOSP Android 11 Device running on lineageOS (without google play services). [image: Capture d’écran de 2022-01-06 09-23-38] https://user-images.githubusercontent.com/28347998/148352412-ea06e18d-2860-464c-b75c-625da418d640.png

Thanks and best regards.

— Reply to this email directly, view it on GitHub https://github.com/Zfinix/carrier_info/issues/14, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGE3JSJ2NFXKGKXNNU6XR7TUUVG2HANCNFSM5LLZDUJQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Chiziaruhoma O.

nicolaspernoud commented 2 years ago

It would seem that is a permission problem : READ_PHONE_STATE and ACCESS_NETWORK_STATE seems missing :

    private fun requestForSpecificPermission(i: Int) {
        ActivityCompat.requestPermissions(this.activity!!, arrayOf(Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.READ_PHONE_STATE, Manifest.permission.ACCESS_NETWORK_STATE), i)
    }

    private fun checkIfAlreadyHavePermission(): Boolean {
        return ContextCompat.checkSelfPermission(this.activity!!, Manifest.permission.ACCESS_WIFI_STATE) == PackageManager.PERMISSION_GRANTED && 
        ContextCompat.checkSelfPermission(this.activity!!, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED && 
        ContextCompat.checkSelfPermission(this.activity!!, Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_GRANTED
    }

Seems to do the trick.

Zfinix commented 2 years ago

Ohh make a PR so I can merge it in On Thu, 6 Jan 2022 at 11:20 AM, Nicolas PERNOUD @.***> wrote:

It would seem that is a permission problem : READ_PHONE_STATE and ACCESS_NETWORK_STATE seems missing :

private fun requestForSpecificPermission(i: Int) {
    ActivityCompat.requestPermissions(this.activity!!, arrayOf(Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.READ_PHONE_STATE, Manifest.permission.ACCESS_NETWORK_STATE), i)
}

private fun checkIfAlreadyHavePermission(): Boolean {
    return ContextCompat.checkSelfPermission(this.activity!!, Manifest.permission.ACCESS_WIFI_STATE) == PackageManager.PERMISSION_GRANTED &&
    ContextCompat.checkSelfPermission(this.activity!!, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED &&
    ContextCompat.checkSelfPermission(this.activity!!, Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_GRANTED
}

Seems to do the trick.

— Reply to this email directly, view it on GitHub https://github.com/Zfinix/carrier_info/issues/14#issuecomment-1006446676, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGE3JSPS4VJFW7JNBZKOXT3UUVUFPANCNFSM5LLZDUJQ . You are receiving this because you commented.Message ID: @.***>

-- Chiziaruhoma O.

nicolaspernoud commented 2 years ago

Yep, I'll do a few more test and do a pull request. Closing for now.

Zfinix commented 2 years ago

Thank you!

On Thu, 6 Jan 2022 at 11:33 AM, Nicolas PERNOUD @.***> wrote:

Closed #14 https://github.com/Zfinix/carrier_info/issues/14.

— Reply to this email directly, view it on GitHub https://github.com/Zfinix/carrier_info/issues/14#event-5851463165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGE3JSNPGCDKGHWEA56RDLDUUVVWXANCNFSM5LLZDUJQ . You are receiving this because you commented.Message ID: @.***>

-- Chiziaruhoma O.