public void verifyFileDownloadSucceeded() throws Exception {
  String filename=DOWNLOAD_5MB_FILENAME;
  long filesize=DOWNLOAD_5MB_FILESIZE;
  long dlRequest=-1;
  boolean rebootMarkerValid=false;
  DataInputStream dataInputFile=null;
  setWiFiStateOn(true);
  setAirplaneModeOn(false);
  try {
    FileInputStream inFile=mContext.openFileInput(DOWNLOAD_STARTED_FLAG);
    dataInputFile=new DataInputStream(inFile);
    dlRequest=dataInputFile.readLong();
  }
 catch (  Exception e) {
    Log.i(LOG_TAG,"Unable to determine initial download id.");
    throw e;
  }
 finally {
    if (dataInputFile != null) {
      dataInputFile.close();
    }
    mContext.deleteFile(DOWNLOAD_STARTED_FLAG);
  }
  assertTrue(dlRequest != -1);
  Cursor cursor=getCursor(dlRequest);
  ParcelFileDescriptor pfd=null;
  try {
    assertTrue("Unable to query last initiated download!",cursor.moveToFirst());
    int columnIndex=cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
    int status=cursor.getInt(columnIndex);
    int currentWaitTime=0;
    waitForDownloadOrTimeout_skipNotification(dlRequest);
    Log.i(LOG_TAG,"Verifying download information...");
    pfd=mDownloadManager.openDownloadedFile(dlRequest);
    verifyFileSize(pfd,filesize);
  }
 catch (  Exception e) {
    Log.i(LOG_TAG,"error: " + e.toString());
    throw e;
  }
 finally {
    cursor.close();
    mDownloadManager.remove(dlRequest);
    if (pfd != null) {
      pfd.close();
    }
  }
}

public void verifyFileDownloadSucceeded ( ) throws Exception { String filename = DOWNLOAD_5MB_FILENAME ; long filesize = DOWNLOAD_5MB_FILESIZE ; long dlRequest = - 1 ; boolean rebootMarkerValid = false ; DataInputStream dataInputFile = null ; setWiFiStateOn ( true ) ; setAirplaneModeOn ( false ) ; try { FileInputStream inFile = mContext . openFileInput ( DOWNLOAD_STARTED_FLAG ) ; dataInputFile = new DataInputStream ( inFile ) ; dlRequest = dataInputFile . readLong ( ) ; } catch ( Exception e ) { Log . i ( LOG_TAG , "Unable to determine initial download id." ) ; throw e ; } finally { if ( dataInputFile != null ) { dataInputFile . close ( ) ; } mContext . deleteFile ( DOWNLOAD_STARTED_FLAG ) ; } assertTrue ( dlRequest != - 1 ) ; Cursor cursor = getCursor ( dlRequest ) ; ParcelFileDescriptor pfd = null ; try { assertTrue ( "Unable to query last initiated download!" , cursor . moveToFirst ( ) ) ; int columnIndex = cursor . getColumnIndex ( DownloadManager . COLUMN_STATUS ) ; int status = cursor . getInt ( columnIndex ) ; int currentWaitTime = 0 ; waitForDownloadOrTimeout_skipNotification ( dlRequest ) ; Log . i ( LOG_TAG , "Verifying download information..." ) ; pfd = mDownloadManager . openDownloadedFile ( dlRequest ) ; verifyFileSize ( pfd , filesize ) ; } catch ( Exception e ) { Log . i ( LOG_TAG , "error: " + e . toString ( ) ) ; throw e ; } finally { cursor . close ( ) ; mDownloadManager . remove ( dlRequest ) ; if ( pfd != null ) { pfd . close ( ) ; } } }
waits for a previously - initiated download and verifies it has completed successfully .
