Exemple #1
0
 /*
  * //not use it to read operator any more public void testReadOperatorName()
  * { try { String opName = mAgent.readOperatorName(); Log.d(TAG,
  * "operator name = " + opName); Assert.assertNotNull(opName); } catch
  * (RemoteException e) { e.printStackTrace();
  * Assert.fail("DmAgent readOperatorName failed"); }
  *
  * }
  */
 public void testReadImsi() {
   String imsi = null;
   try {
     byte[] imsiByte = mAgent.readImsi();
     if (imsiByte != null) {
       imsi = new String(imsiByte);
       Log.d(TAG, "registered Imsi = " + imsi);
     } else {
       return; // the device may be has not imei, like debug phone.
     }
   } catch (RemoteException e) {
     e.printStackTrace();
     Assert.fail("DmAgent testReadImsi failed");
   }
   Assert.assertNotNull("imsi read from Nvram is null", imsi);
 }
Exemple #2
0
  public void testReadWriteImsi() {
    TelephonyManager telMgr =
        (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    String imsi = telMgr.getSubscriberId();
    Log.d(TAG, "phone's imsi = " + imsi);
    Assert.assertNotNull("imsi read from telephonyManager is null", imsi);

    try {
      boolean ok = mAgent.writeImsi(imsi.getBytes());
      Assert.assertTrue("write IMSI failed!", ok);

      String written = null;
      byte[] writtenByte = mAgent.readImsi();
      if (writtenByte != null) {
        written = new String(writtenByte);
      }
      Log.d(TAG, "registed IMSI = " + written);
      Assert.assertEquals("read IMSI failed!", written, imsi);
    } catch (RemoteException e) {
      e.printStackTrace();
      Assert.fail("DmAgent testReadWriteIMSI failed");
    }
  }