Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Blocking getDeviceId or getSubscriberId forces GSM type: CDMA getCellLocation cannot be cast to GsmCellLocation #1843

Closed
rcchan opened this issue Jul 31, 2014 · 2 comments

Comments

@rcchan
Copy link

rcchan commented Jul 31, 2014

Goal:
Prevent an app from accessing MEID while still allowing location access on a CDMA phone.

Blocking getDeviceId and/or getSubscriberId forces getPhoneType to return a type of TelephonyManager.PHONE_TYPE_GSM

Source around line 202 of XTelephonyManager.java

if (mMethod == Methods.getPhoneType) {
                // TODO: add network type extra
                if (isRestricted(param) || isRestricted(param, "getDeviceId") || isRestricted(param, "getSubscriberId"))
                    param.setResult(TelephonyManager.PHONE_TYPE_GSM); // IMEI

Which breaks app code trying to cast to GsmCellLocation or CdmaCellLocation based on its result. (decompiled)

  switch (((TelephonyManager)localObject1).getPhoneType())
  {
  case 0:
    localaV.z = "none";
    break;
  case 1:
    localaV.z = "gsm";
    localObject4 = i1 != 0 ? (GsmCellLocation)((TelephonyManager)localObject1).getCellLocation() : null;
    break;
  case 2:
    localaV.z = "cdma";
    localObject5 = i1 != 0 ? (CdmaCellLocation)((TelephonyManager)localObject1).getCellLocation() : null;
    break;
  default:
    localaV.z = ("unknown (" + ((TelephonyManager)localObject1).getPhoneType() + ")");
  }

Since the allowed getCellLocation call returns a CdmaCellLocation, I am getting the following error:

android.telephony.cdma.CdmaCellLocation cannot be cast to android.telephony.gsm.GsmCellLocation
@M66B
Copy link
Owner

M66B commented Jul 31, 2014

It is not possible to convert one cell location type from one into the other, which means the phone type should not be restricted, which means there need to be different types of device numbers, depending on the phone type. So, different settings needs to be added/used.

This has no high priority for me, because the existing logic existed for about a year without complaints and will affect only specific applications. A tested pull request is however welcome.

@M66B M66B added bug and removed enhancement labels Aug 1, 2014
@M66B M66B closed this as completed in ae44f29 Aug 1, 2014
@M66B
Copy link
Owner

M66B commented Aug 1, 2014

I have allowed entering a MEID and removed getNetworkType and getPhoneType, since these restrictions were only there to force a GSM to fake an IMEI.

This is also in the spirit of FAQ25.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants