For almost a week now I have been looking for ways to break into com.android.internal.telephony.IccCard and master the supplyDepersonalization() method. Those who will also dig in this direction will not work . Even with the help of reflection - this is impossible. The only way (I don’t know if I am the first):
Find on the device (as
root) the modem frameworksystem/framework/telephony-common.jarAny archiver to get from it compiled
classes.dex"Turn" it into a
jarutilitydex2jarAnd add the resulting archive to your development environment.
Personally, I have AIDE and I just unzipped android.jar and added the previously received archive to its contents.
Eventually
Now we can write in the import section, for example, so
import com.android.internal.telephony.RIL; And do whatever you want. The point is that all the code associated with the added classes will be successfully compiled and will be executed . I checked this by calling methods in different classes and getting return values.
Now to the point
Actually, the question itself, I'm trying to get an IccCard interface and doing so
PhoneFactory.makeDefaultPhone(this); Phone p = PhoneFactory.getDefaultPhone(); IccCard i = p.getIccCard(); boolean x = i.getIccLockEnabled(); As a result, the application hangs (and does not even show a simple markup) when executing the method makeDefaultPhone() . I wondered why and I went to look for him:
public static void makeDefaultPhone(Context context synchronized(Phone.class) { if (!sMadeDefaults) { sLooper = Looper.myLooper(); sContext = context; if (sLooper == null) { throw new RuntimeException("PhoneFactory.makeDefaultPhone must be called from Looper thread"); } int retryCount = 0; for(;;) { boolean hasException = false; retryCount ++; try { // use UNIX domain socket to // prevent subsequent initialization new LocalServerSocket("com.android.internal.telephony"); } catch (java.io.IOException ex) { hasException = true; } if ( !hasException ) { break; } else if (retryCount > SOCKET_OPEN_MAX_RETRY) { throw new RuntimeException("PhoneFactory probably already running"); } else { try { Thread.sleep(SOCKET_OPEN_RETRY_MILLIS); } catch (InterruptedException er) { } } } sPhoneNotifier = new DefaultPhoneNotifier(); // Get preferred network mode int preferredNetworkMode = RILConstants.PREFERRED_NETWORK_MODE; if (TelephonyManager.getLteOnCdmaModeStatic() == PhoneConstants.LTE_ON_CDMA_TRUE) { preferredNetworkMode = Phone.NT_MODE_GLOBAL; } int networkMode = Settings.Global.getInt(context.getContentResolver(), Settings.Global.PREFERRED_NETWORK_MODE, preferredNetworkMode); Rlog.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkMode)); int cdmaSubscription = CdmaSubscriptionSourceManager.getDefault(context); Rlog.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription); //reads the system properties and makes commandsinterface sCommandsInterface = new RIL(context, networkMode, cdmaSubscription); // Instantiate UiccController so that all other classes can just call getInstance() UiccController.make(context, sCommandsInterface); int phoneType = TelephonyManager.getPhoneType(networkMode); if (phoneType == PhoneConstants.PHONE_TYPE_GSM) { Rlog.i(LOG_TAG, "Creating GSMPhone"); sProxyPhone = new PhoneProxy(new GSMPhone(context, sCommandsInterface, sPhoneNotifier)); } else if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) { switch (TelephonyManager.getLteOnCdmaModeStatic()) { case PhoneConstants.LTE_ON_CDMA_TRUE: Rlog.i(LOG_TAG, "Creating CDMALTEPhone"); sProxyPhone = new PhoneProxy(new CDMALTEPhone(context, sCommandsInterface, sPhoneNotifier)); break; case PhoneConstants.LTE_ON_CDMA_FALSE: default: Rlog.i(LOG_TAG, "Creating CDMAPhone"); sProxyPhone = new PhoneProxy(new CDMAPhone(context, sCommandsInterface, sPhoneNotifier)); break; } } // Ensure that we have a default SMS app. Requesting the app with // updateIfNeeded set to true is enough to configure a default SMS app. ComponentName componentName = SmsApplication.getDefaultSmsApplication(context, true /* updateIfNeeded */); String packageName = "NONE"; if (componentName != null) { packageName = componentName.getPackageName(); } Rlog.i(LOG_TAG, "defaultSmsApplication: " + packageName); // Set up monitor to watch for changes to SMS packages SmsApplication.initSmsPackageMonitor(context); sMadeDefaults = true; } } } Well, well, carefully reading the code and disassembling each line, I realized that I did not need to contact PhoneFactory . Enough to create a Phone yourself. I'm trying this:
int cdmaSubscription = CdmaSubscriptionSourceManager.getDefault(this); PhoneNotifier sPhoneNotifier = new DefaultPhoneNotifier(); RIL sRIL = new RIL(this, 9, cdmaSubscription); CommandsInterface sCommandsInterface = sRIL; GSMPhone gsmPhone = new GSMPhone(this, sCommandsInterface, sPhoneNotifier); Phone sProxyPhone = new PhoneProxy(gsmPhone); DefaultPhoneNotifier has a constructor with a protected access modifier. Moreover, in the official document it is not at all (public). My framework has been modified by the manufacturer. What can be done in this case? Is it possible to create PhoneNotifier somehow differently? How to send unlock code differently?
UPDATE
The framework on the device under test is not modified at all. I noticed that in different versions of android somewhere protected is, and where it is not.