project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadAsyncTask.java
changeset 6446 a49d01b96185
parent 6437 4ed58839b13b
child 6700 e04da46ee43c
equal deleted inserted replaced
6445:fd151457fae6 6446:a49d01b96185
   161 			}//end while(entry != null)
   161 			}//end while(entry != null)
   162 			if( input != null)
   162 			if( input != null)
   163 				try {
   163 				try {
   164 					input.close();
   164 					input.close();
   165 				} catch (IOException e) {}
   165 				} catch (IOException e) {}
   166 		}//end if contentType == "zip"
   166 		}else{//end if contentType == "zip"
   167 
   167 			return EXIT_URLFAIL;
       
   168 		}
   168 		if(conn != null) conn.disconnect();
   169 		if(conn != null) conn.disconnect();
   169 
   170 
   170 		if(checkMD5(digester, pack))return EXIT_SUCCESS;
   171 		if(checkMD5(digester, pack))return EXIT_SUCCESS;
   171 		else return EXIT_MD5;
   172 		else return EXIT_MD5;
   172 	}
   173 	}
   193 				HttpURLConnection conn = (HttpURLConnection)url.openConnection();
   194 				HttpURLConnection conn = (HttpURLConnection)url.openConnection();
   194 
   195 
   195 				byte[] buffer = new byte[1024];//size is large enough to hold the entire hash
   196 				byte[] buffer = new byte[1024];//size is large enough to hold the entire hash
   196 				BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
   197 				BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
   197 				int bytesRead = bis.read(buffer);
   198 				int bytesRead = bis.read(buffer);
       
   199 				String hash = null;
   198 				if(bytesRead > -1){
   200 				if(bytesRead > -1){
   199 					String hash = new String(buffer, 0, bytesRead);
   201 					hash = new String(buffer, 0, bytesRead);
   200 					StringBuffer sb = new StringBuffer();
       
   201 					Integer tmp = 0;
       
   202 					for(int i = 0; i < messageDigest.length; i++){
       
   203 						tmp = 0xFF & messageDigest[i];
       
   204 						if(tmp < 0xF) sb.append('0');
       
   205 						sb.append(Integer.toHexString(tmp));
       
   206 					}
       
   207 					sb.append('\n');//add newline to become identical with the hash file
       
   208 
       
   209 					return hash.equals(sb.toString());
       
   210 				}
   202 				}
   211 				return false;
   203 				StringBuffer sb = new StringBuffer();
       
   204 				Integer tmp = 0;
       
   205 				for(int i = 0; i < messageDigest.length; i++){
       
   206 					tmp = 0xFF & messageDigest[i];
       
   207 					if(tmp < 0xF) sb.append('0');
       
   208 					sb.append(Integer.toHexString(tmp));
       
   209 				}
       
   210 				sb.append('\n');//add newline to become identical with the hash file
       
   211 
       
   212 				return hash.equals(sb.toString());
   212 			} catch (IOException e) {
   213 			} catch (IOException e) {
   213 				e.printStackTrace();
   214 				e.printStackTrace();
   214 				return true;
   215 				return true;
   215 			}
   216 			}
   216 		}else{
   217 		}else{