示例#1
0
  public void testLockFlag() {
    try {
      boolean isLocked = mAgent.isLockFlagSet();
      Assert.assertFalse(isLocked);

      boolean setOK = mAgent.setLockFlag("partially".getBytes());
      Assert.assertTrue(setOK);

      boolean isLockedNow = mAgent.isLockFlagSet();
      Assert.assertTrue(isLockedNow);

      boolean clearOK = mAgent.clearLockFlag();
      Assert.assertTrue(clearOK);

      boolean isLockedLast = mAgent.isLockFlagSet();
      Assert.assertFalse(isLockedLast);
    } catch (RemoteException e) {
      e.printStackTrace();
      Assert.fail("DmAgent testLockFlag failed");
    }
  }
示例#2
0
  public void testSetRebootFlag() {
    try {
      boolean ok = mAgent.setRebootFlag();
    } catch (Exception e) {
      Assert.fail("DmAgent test SetRebootFlag failed");
    }

    File file = new File("/cache/recovery/command");
    assertTrue("/cache/recovery/command exists", file.exists());

    byte[] command = "--fota_delta_path=/data/delta".getBytes();
    int result = 0;
    final int length = command.length;
    byte[] buffer = new byte[length];
    try {
      FileInputStream inputStream = new FileInputStream(file);
      try {
        result = inputStream.read(buffer);
      } catch (Exception e) {
        fail("read /cache/recovery/command failed");
      } finally {
        inputStream.close();
      }
    } catch (FileNotFoundException e) {
      Assert.fail("DmAgent testSetRebootFlag failed for /cache/recovery/command not found");
    } catch (IOException e) {
      Log.e("DmAgentTests", "IOException " + e.toString());
    }

    assertEquals(length, result);
    for (int i = 0; i < length; ++i) {
      assertEquals(command[i], buffer[i]);
    }

    try {
      mAgent.clearRebootFlag();
    } catch (Exception e) {
      Assert.fail("DmAgent test clearRebootFlag failed");
    }
  }
示例#3
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");
    }
  }
示例#4
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);
 }