protected void installPackage(String packageLocation) throws Exception {
    PackageInstaller.SessionParams params =
        new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL);
    int sessionId = mPackageInstaller.createSession(params);
    mSession = mPackageInstaller.openSession(sessionId);

    File file = new File(packageLocation);
    InputStream in = new FileInputStream(file);
    OutputStream out = mSession.openWrite("SilentPackageInstallerTest", 0, file.length());
    byte[] buffer = new byte[65536];
    int c;
    while ((c = in.read(buffer)) != -1) {
      out.write(buffer, 0, c);
    }
    mSession.fsync(out);
    out.close();
    mSession.commit(getCommitCallback(sessionId));
    mSession.close();
  }
 @Override
 protected void tearDown() throws Exception {
   if (mDevicePolicyManager.isDeviceOwnerApp(PACKAGE_NAME)
       || mDevicePolicyManager.isProfileOwnerApp(PACKAGE_NAME)) {
     mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, false);
   }
   try {
     mContext.unregisterReceiver(mBroadcastReceiver);
   } catch (IllegalArgumentException e) {
     // ignore
   }
   if (mSession != null) {
     mSession.abandon();
   }
   super.tearDown();
 }