… | |
… | |
100 | //static final String ZANAVI_MAPS_BASE_URL_PROTO = "https://";
|
100 | //static final String ZANAVI_MAPS_BASE_URL_PROTO = "https://";
|
101 | //static final String ZANAVI_MAPS_BASE_URL_WO_SERVERNAME = "/maps/";
|
101 | //static final String ZANAVI_MAPS_BASE_URL_WO_SERVERNAME = "/maps/";
|
102 | // ------- DEBUG DEBUG SETTINGS --------
|
102 | // ------- DEBUG DEBUG SETTINGS --------
|
103 | // ------- DEBUG DEBUG SETTINGS --------
|
103 | // ------- DEBUG DEBUG SETTINGS --------
|
104 |
|
104 |
|
105 | static int MULTI_NUM_THREADS_MAX = 4;
|
105 | static int MULTI_NUM_THREADS_MAX = 5;
|
106 | static int MULTI_NUM_THREADS = 1; // how many download streams for a file
|
106 | static int MULTI_NUM_THREADS = 2; // how many download streams for a file
|
107 | static int MULTI_NUM_THREADS_LOCAL = 1; // how many download streams for the current file from the current server
|
107 | static int MULTI_NUM_THREADS_LOCAL = 1; // how many download streams for the current file from the current server
|
108 |
|
108 |
|
109 | public static class zanavi_osm_map_values
|
109 | public static class zanavi_osm_map_values
|
110 | {
|
110 | {
|
111 | String map_name = "";
|
111 | String map_name = "";
|
… | |
… | |
1177 | }
|
1177 | }
|
1178 | }
|
1178 | }
|
1179 |
|
1179 |
|
1180 | public static void init_cat_file()
|
1180 | public static void init_cat_file()
|
1181 | {
|
1181 | {
|
|
|
1182 | Log.v("NavitMapDownloader", "init_cat_file");
|
|
|
1183 |
|
1182 | // read the file from sdcard
|
1184 | // read the file from sdcard
|
1183 | read_cat_file();
|
1185 | read_cat_file();
|
1184 | // make a copy
|
1186 | // make a copy
|
1185 | List<String> temp_list = new ArrayList<String>();
|
1187 | List<String> temp_list = new ArrayList<String>();
|
1186 | temp_list.clear();
|
1188 | temp_list.clear();
|
1187 | Iterator<String> k = map_catalogue.listIterator();
|
1189 | Iterator<String> k = map_catalogue.listIterator();
|
|
|
1190 |
|
1188 | while (k.hasNext())
|
1191 | while (k.hasNext())
|
1189 | {
|
1192 | {
|
1190 | temp_list.add(k.next());
|
1193 | temp_list.add(k.next());
|
1191 | }
|
1194 | }
|
|
|
1195 |
|
1192 | int temp_list_prev_size = temp_list.size();
|
1196 | int temp_list_prev_size = temp_list.size();
|
1193 | Boolean[] bits = new Boolean[temp_list_prev_size];
|
1197 | Boolean[] bits = new Boolean[temp_list_prev_size];
|
|
|
1198 |
|
1194 | for (int h = 0; h < temp_list_prev_size; h++)
|
1199 | for (int h = 0; h < temp_list_prev_size; h++)
|
1195 | {
|
1200 | {
|
1196 | bits[h] = false;
|
1201 | bits[h] = false;
|
1197 | }
|
1202 | }
|
|
|
1203 |
|
1198 | // compare it with directory contents
|
1204 | // compare it with directory contents
|
1199 | File map_dir = new File(Navit.MAP_FILENAME_PATH);
|
1205 | File map_dir = new File(Navit.MAP_FILENAME_PATH);
|
1200 | File map_file_absolute_path = null;
|
1206 | File map_file_absolute_path = null;
|
1201 | String dateInUTC = "";
|
1207 | String dateInUTC = "";
|
1202 | SimpleDateFormat lv_formatter = new SimpleDateFormat("yyyyMMddHHmm", Locale.US);
|
1208 | SimpleDateFormat lv_formatter = new SimpleDateFormat("yyyyMMddHHmm", Locale.US);
|
1203 | lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
1209 | lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
|
1210 |
|
1204 | if (map_dir.isDirectory())
|
1211 | if (map_dir.isDirectory())
|
1205 | {
|
1212 | {
|
1206 | String[] files_in_mapdir = map_dir.list();
|
1213 | String[] files_in_mapdir = map_dir.list();
|
1207 | if (files_in_mapdir != null)
|
1214 | if (files_in_mapdir != null)
|
1208 | {
|
1215 | {
|
… | |
… | |
1224 | {
|
1231 | {
|
1225 | System.out.println("checking file in mapdir: " + files_in_mapdir[i]);
|
1232 | System.out.println("checking file in mapdir: " + files_in_mapdir[i]);
|
1226 | Boolean found_in_maplist = false;
|
1233 | Boolean found_in_maplist = false;
|
1227 | Iterator<String> j = temp_list.listIterator();
|
1234 | Iterator<String> j = temp_list.listIterator();
|
1228 | int t = 0;
|
1235 | int t = 0;
|
|
|
1236 |
|
1229 | while (j.hasNext())
|
1237 | while (j.hasNext())
|
1230 | {
|
1238 | {
|
1231 | String st = j.next();
|
1239 | String st = j.next();
|
1232 | if (st.split(":", 2)[0].equals(files_in_mapdir[i]))
|
1240 | if (st.split(":", 2)[0].equals(files_in_mapdir[i]))
|
1233 | {
|
1241 | {
|
… | |
… | |
1255 | if (files_in_mapdir[i].equals("borders.bin"))
|
1263 | if (files_in_mapdir[i].equals("borders.bin"))
|
1256 | {
|
1264 | {
|
1257 | System.out.println("adding to maplist: " + files_in_mapdir[i] + ":" + "borders.bin");
|
1265 | System.out.println("adding to maplist: " + files_in_mapdir[i] + ":" + "borders.bin");
|
1258 | temp_list.add(files_in_mapdir[i] + ":" + "borders.bin");
|
1266 | temp_list.add(files_in_mapdir[i] + ":" + "borders.bin");
|
1259 | }
|
1267 | }
|
|
|
1268 | else if (files_in_mapdir[i].equals("coastline.bin"))
|
|
|
1269 | {
|
|
|
1270 | System.out.println("adding to maplist: " + files_in_mapdir[i] + ":" + "coastline.bin");
|
|
|
1271 | temp_list.add(files_in_mapdir[i] + ":" + "coastline.bin");
|
|
|
1272 | }
|
1260 | else
|
1273 | else
|
1261 | {
|
1274 | {
|
1262 | System.out.println("adding to maplist: " + files_in_mapdir[i] + ":" + MAP_URL_NAME_UNKNOWN);
|
1275 | System.out.println("adding to maplist: " + files_in_mapdir[i] + ":" + MAP_URL_NAME_UNKNOWN);
|
1263 | temp_list.add(files_in_mapdir[i] + ":" + MAP_URL_NAME_UNKNOWN);
|
1276 | temp_list.add(files_in_mapdir[i] + ":" + MAP_URL_NAME_UNKNOWN);
|
1264 | }
|
1277 | }
|
… | |
… | |
1268 | }
|
1281 | }
|
1269 | }
|
1282 | }
|
1270 | }
|
1283 | }
|
1271 | }
|
1284 | }
|
1272 | }
|
1285 | }
|
|
|
1286 |
|
1273 | // check for all maps that are in the maplist, but are missing from sdcard
|
1287 | // check for all maps that are in the maplist, but are missing from sdcard
|
1274 | // use prev size, because values have been added to the end of the list!!
|
1288 | // use prev size, because values have been added to the end of the list!!
|
1275 | for (int h = 0; h < temp_list_prev_size; h++)
|
1289 | for (int h = 0; h < temp_list_prev_size; h++)
|
1276 | {
|
1290 | {
|
1277 | if (bits[h] == false)
|
1291 | if (bits[h] == false)
|
… | |
… | |
1285 | // to avoid download to wrong filename
|
1299 | // to avoid download to wrong filename
|
1286 | temp_list.set(h, "#################");
|
1300 | temp_list.set(h, "#################");
|
1287 | }
|
1301 | }
|
1288 | }
|
1302 | }
|
1289 | }
|
1303 | }
|
|
|
1304 |
|
1290 | // use the corrected copy
|
1305 | // use the corrected copy
|
1291 | map_catalogue.clear();
|
1306 | map_catalogue.clear();
|
1292 | Iterator<String> m = temp_list.listIterator();
|
1307 | Iterator<String> m = temp_list.listIterator();
|
|
|
1308 |
|
1293 | while (m.hasNext())
|
1309 | while (m.hasNext())
|
1294 | {
|
1310 | {
|
1295 | map_catalogue.add(m.next());
|
1311 | map_catalogue.add(m.next());
|
1296 | }
|
1312 | }
|
|
|
1313 |
|
1297 | // write the corrected file back to sdcard
|
1314 | // write the corrected file back to sdcard
|
1298 | write_cat_file();
|
1315 | write_cat_file();
|
1299 | }
|
1316 | }
|
1300 |
|
1317 |
|
1301 | public static int cat_file_maps_have_installed_any()
|
1318 | public static int cat_file_maps_have_installed_any()
|
… | |
… | |
1316 | return ret;
|
1333 | return ret;
|
1317 | }
|
1334 | }
|
1318 |
|
1335 |
|
1319 | public static void init_cat_file_maps_timestamps()
|
1336 | public static void init_cat_file_maps_timestamps()
|
1320 | {
|
1337 | {
|
|
|
1338 | Log.v("NavitMapDownloader", "init_cat_file_maps_timestamps");
|
|
|
1339 |
|
1321 | map_catalogue_date.clear();
|
1340 | map_catalogue_date.clear();
|
1322 | // make a copy of current map_catalogue
|
1341 | // make a copy of current map_catalogue
|
1323 | List<String> temp_list = new ArrayList<String>();
|
1342 | List<String> temp_list = new ArrayList<String>();
|
1324 | temp_list.clear();
|
1343 | temp_list.clear();
|
1325 | Iterator<String> k = map_catalogue.listIterator();
|
1344 | Iterator<String> k = map_catalogue.listIterator();
|
… | |
… | |
1397 | }
|
1416 | }
|
1398 | }
|
1417 | }
|
1399 |
|
1418 |
|
1400 | public static void read_cat_file()
|
1419 | public static void read_cat_file()
|
1401 | {
|
1420 | {
|
|
|
1421 | Log.v("NavitMapDownloader", "read_cat_file");
|
|
|
1422 |
|
1402 | //Get the text file
|
1423 | //Get the text file
|
1403 | File file = new File(Navit.CFG_FILENAME_PATH + CAT_FILE);
|
1424 | File file = new File(Navit.CFG_FILENAME_PATH + CAT_FILE);
|
1404 |
|
1425 |
|
1405 | //Read text from file
|
1426 | //Read text from file
|
1406 | try
|
1427 | try
|
… | |
… | |
1415 | // line=#comment
|
1436 | // line=#comment
|
1416 | if (!line.startsWith("#"))
|
1437 | if (!line.startsWith("#"))
|
1417 | {
|
1438 | {
|
1418 | if (line != null)
|
1439 | if (line != null)
|
1419 | {
|
1440 | {
|
|
|
1441 | if (line.startsWith("coastline.bin:"))
|
|
|
1442 | {
|
|
|
1443 | line="coastline.bin:coastline.bin";
|
|
|
1444 | }
|
|
|
1445 | else if (line.startsWith("borders.bin:"))
|
|
|
1446 | {
|
|
|
1447 | line="borders.bin:borders.bin";
|
|
|
1448 | }
|
1420 | map_catalogue.add(line);
|
1449 | map_catalogue.add(line);
|
1421 | System.out.println("line=" + line);
|
1450 | System.out.println("line=" + line);
|
1422 | }
|
1451 | }
|
1423 | }
|
1452 | }
|
1424 | }
|
1453 | }
|
… | |
… | |
1436 | }
|
1465 | }
|
1437 |
|
1466 |
|
1438 | @SuppressLint("NewApi")
|
1467 | @SuppressLint("NewApi")
|
1439 | public static void write_cat_file()
|
1468 | public static void write_cat_file()
|
1440 | {
|
1469 | {
|
|
|
1470 | Log.v("NavitMapDownloader", "write_cat_file");
|
|
|
1471 |
|
1441 | //Get the text file
|
1472 | //Get the text file
|
1442 | File file = new File(Navit.CFG_FILENAME_PATH + CAT_FILE);
|
1473 | File file = new File(Navit.CFG_FILENAME_PATH + CAT_FILE);
|
1443 | FileOutputStream fOut = null;
|
1474 | FileOutputStream fOut = null;
|
1444 | OutputStreamWriter osw = null;
|
1475 | OutputStreamWriter osw = null;
|
1445 | try
|
1476 | try
|
… | |
… | |
1504 | }
|
1535 | }
|
1505 | }
|
1536 | }
|
1506 |
|
1537 |
|
1507 | public static void add_to_cat_file(String disk_name, String server_name)
|
1538 | public static void add_to_cat_file(String disk_name, String server_name)
|
1508 | {
|
1539 | {
|
|
|
1540 | Log.v("NavitMapDownloader", "add_to_cat_file");
|
|
|
1541 |
|
1509 | System.out.println("adding: " + disk_name + ":" + server_name);
|
1542 | System.out.println("adding: " + disk_name + ":" + server_name);
|
1510 | map_catalogue.add(disk_name + ":" + server_name);
|
1543 | map_catalogue.add(disk_name + ":" + server_name);
|
1511 | write_cat_file();
|
1544 | write_cat_file();
|
1512 | }
|
1545 | }
|
1513 |
|
1546 |
|
… | |
… | |
1571 | return map_catalogue.contains(disk_name + ":" + server_name);
|
1604 | return map_catalogue.contains(disk_name + ":" + server_name);
|
1572 | }
|
1605 | }
|
1573 |
|
1606 |
|
1574 | public static String is_in_cat_file_disk_name(String name)
|
1607 | public static String is_in_cat_file_disk_name(String name)
|
1575 | {
|
1608 | {
|
|
|
1609 | Log.v("NavitMapDownloader", "is_in_cat_file_disk_name");
|
|
|
1610 |
|
1576 | String is_here = null;
|
1611 | String is_here = null;
|
1577 | Iterator<String> i = map_catalogue.listIterator();
|
1612 | Iterator<String> i = map_catalogue.listIterator();
|
1578 | while (i.hasNext())
|
1613 | while (i.hasNext())
|
1579 | {
|
1614 | {
|
1580 | String st = i.next();
|
1615 | String st = i.next();
|
… | |
… | |
1588 | return is_here;
|
1623 | return is_here;
|
1589 | }
|
1624 | }
|
1590 |
|
1625 |
|
1591 | public static String is_in_cat_file_server_name(String name)
|
1626 | public static String is_in_cat_file_server_name(String name)
|
1592 | {
|
1627 | {
|
|
|
1628 | Log.v("NavitMapDownloader", "is_in_cat_file_server_name");
|
|
|
1629 |
|
1593 | String is_here = null;
|
1630 | String is_here = null;
|
1594 | Iterator<String> i = map_catalogue.listIterator();
|
1631 | Iterator<String> i = map_catalogue.listIterator();
|
1595 | while (i.hasNext())
|
1632 | while (i.hasNext())
|
1596 | {
|
1633 | {
|
1597 | String st = i.next();
|
1634 | String st = i.next();
|
… | |
… | |
1801 | {
|
1838 | {
|
1802 | t = st.split(":", 2)[1];
|
1839 | t = st.split(":", 2)[1];
|
1803 |
|
1840 |
|
1804 | for (int j = 0; j < z_OSM_MAPS.length; j++)
|
1841 | for (int j = 0; j < z_OSM_MAPS.length; j++)
|
1805 | {
|
1842 | {
|
|
|
1843 | // Log.v("NavitMapDownloader", "u=" + z_OSM_MAPS[j].url + " m=" + z_OSM_MAPS[j].url + " t=" + t + " st=" + st);
|
1806 | if (z_OSM_MAPS[j].url.equals(t))
|
1844 | if (z_OSM_MAPS[j].url.equals(t))
|
1807 | {
|
1845 | {
|
1808 | OSM_MAP_NAME_LIST_ondisk[c] = z_OSM_MAPS[j].map_name;
|
1846 | OSM_MAP_NAME_LIST_ondisk[c] = z_OSM_MAPS[j].map_name;
|
1809 | }
|
1847 | }
|
1810 | }
|
1848 | }
|
|
|
1849 |
|
1811 | if (OSM_MAP_NAME_LIST_ondisk[c] == null)
|
1850 | if (OSM_MAP_NAME_LIST_ondisk[c] == null)
|
1812 | {
|
1851 | {
|
1813 | // for unkown maps
|
1852 | // for unkown maps
|
1814 | OSM_MAP_NAME_LIST_ondisk[c] = st.split(":", 2)[0] + MAP_DISK_NAME_UNKNOWN;
|
1853 | OSM_MAP_NAME_LIST_ondisk[c] = st.split(":", 2)[0] + MAP_DISK_NAME_UNKNOWN;
|
1815 | }
|
1854 | }
|
… | |
… | |
2398 |
|
2437 |
|
2399 | boolean index_file_download = false;
|
2438 | boolean index_file_download = false;
|
2400 | if ((Navit.Navit_DonateVersion_Installed) || (Navit.Navit_Largemap_DonateVersion_Installed))
|
2439 | if ((Navit.Navit_DonateVersion_Installed) || (Navit.Navit_Largemap_DonateVersion_Installed))
|
2401 | {
|
2440 | {
|
2402 | index_file_download = true;
|
2441 | index_file_download = true;
|
|
|
2442 | Log.d("NavitMapDownloader", "index_file_download(a)=" + index_file_download);
|
2403 | }
|
2443 | }
|
|
|
2444 |
|
|
|
2445 | Log.d("NavitMapDownloader", "index_file_download(2)=" + index_file_download);
|
2404 |
|
2446 |
|
2405 | if (index_file_download == true)
|
2447 | if (index_file_download == true)
|
2406 | {
|
2448 | {
|
2407 | long real_file_size_idx = d_get_real_download_filesize(z_dummy_for_idx, this_server_name, map_num3);
|
2449 | long real_file_size_idx = d_get_real_download_filesize(z_dummy_for_idx, this_server_name, map_num3);
|
2408 | if (real_file_size_idx <= 0)
|
2450 | if (real_file_size_idx <= 0)
|
… | |
… | |
3207 |
|
3249 |
|
3208 | public String calc_md5sum_on_device(Handler handler, int my_dialog_num, long size)
|
3250 | public String calc_md5sum_on_device(Handler handler, int my_dialog_num, long size)
|
3209 | {
|
3251 | {
|
3210 | String md5sum = null;
|
3252 | String md5sum = null;
|
3211 | final int sleep_millis = 0;
|
3253 | final int sleep_millis = 0;
|
3212 | final int sleep_millis_long = 60;
|
3254 | final int sleep_millis_long = 0; // 60;
|
3213 | final int looper_mod = 100;
|
3255 | final int looper_mod = 100;
|
3214 | int looper_count = 0;
|
3256 | int looper_count = 0;
|
|
|
3257 | int old_percent_ = -1;
|
|
|
3258 | int percent_ = -2;
|
3215 |
|
3259 |
|
3216 | if (size > MAX_SINGLE_BINFILE_SIZE)
|
3260 | if (size > MAX_SINGLE_BINFILE_SIZE)
|
3217 | {
|
3261 | {
|
3218 | try
|
3262 | try
|
3219 | {
|
3263 | {
|
… | |
… | |
3270 | no_more_parts = true;
|
3314 | no_more_parts = true;
|
3271 | }
|
3315 | }
|
3272 |
|
3316 |
|
3273 | if (!no_more_parts)
|
3317 | if (!no_more_parts)
|
3274 | {
|
3318 | {
|
|
|
3319 | old_percent_ = -1;
|
|
|
3320 | percent_ = -2;
|
|
|
3321 |
|
3275 | byte[] buffer = new byte[1024 * MD5_CALC_BUFFER_KB];
|
3322 | byte[] buffer = new byte[1024 * MD5_CALC_BUFFER_KB];
|
3276 | int numRead = 0;
|
3323 | int numRead = 0;
|
3277 | do
|
3324 | do
|
3278 | {
|
3325 | {
|
3279 | if (mapdownload_stop_all_threads)
|
3326 | if (mapdownload_stop_all_threads)
|
… | |
… | |
3314 | }
|
3361 | }
|
3315 | digest.update(buffer, 0, numRead);
|
3362 | digest.update(buffer, 0, numRead);
|
3316 | cur_pos = cur_pos + numRead;
|
3363 | cur_pos = cur_pos + numRead;
|
3317 | }
|
3364 | }
|
3318 |
|
3365 |
|
3319 | msg = handler.obtainMessage();
|
3366 | // do not update notification too often
|
3320 | b = new Bundle();
|
3367 | old_percent_ = percent_;
|
3321 | msg.what = 1;
|
3368 | percent_ = calc_percent((int) (cur_pos / 1000), size2);
|
3322 | b.putInt("max", size2);
|
|
|
3323 | b.putInt("cur", (int) (cur_pos / 1000));
|
|
|
3324 | b.putInt("dialog_num", my_dialog_num);
|
|
|
3325 | b.putString("title", Navit.get_text("Mapdownload")); //TRANS
|
|
|
3326 | b.putString("text", Navit.get_text("generating MD5 checksum")); //TRANS
|
|
|
3327 | msg.setData(b);
|
|
|
3328 | handler.sendMessage(msg);
|
|
|
3329 |
|
3369 |
|
3330 | try
|
3370 | if (percent_ != old_percent_)
|
3331 | {
|
3371 | {
|
|
|
3372 | msg = handler.obtainMessage();
|
|
|
3373 | b = new Bundle();
|
|
|
3374 | msg.what = 1;
|
|
|
3375 | b.putInt("max", size2);
|
|
|
3376 | b.putInt("cur", (int) (cur_pos / 1000));
|
|
|
3377 | b.putInt("dialog_num", my_dialog_num);
|
|
|
3378 | b.putString("title", Navit.get_text("Mapdownload")); //TRANS
|
|
|
3379 | b.putString("text", Navit.get_text("generating MD5 checksum")); //TRANS
|
|
|
3380 | msg.setData(b);
|
|
|
3381 | handler.sendMessage(msg);
|
|
|
3382 |
|
|
|
3383 | try
|
|
|
3384 | {
|
3332 | ZANaviMapDownloaderService.set_noti_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3385 | ZANaviMapDownloaderService.set_noti_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3333 | ZANaviMapDownloaderService.set_large_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3386 | ZANaviMapDownloaderService.set_large_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3334 |
|
3387 |
|
3335 | // update progressbar
|
3388 | // update progressbar
|
3336 | Message msg_prog = new Message();
|
3389 | Message msg_prog = new Message();
|
3337 | Bundle b_prog = new Bundle();
|
3390 | Bundle b_prog = new Bundle();
|
3338 | b_prog.putInt("pg", calc_percent((int) (cur_pos / 1000), size2));
|
3391 | b_prog.putInt("pg", calc_percent((int) (cur_pos / 1000), size2));
|
3339 | msg_prog.what = 2;
|
3392 | msg_prog.what = 2;
|
3340 | msg_prog.setData(b_prog);
|
3393 | msg_prog.setData(b_prog);
|
3341 | ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
|
3394 | ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
|
3342 | }
|
3395 | }
|
3343 | catch (Exception e)
|
3396 | catch (Exception e)
|
3344 | {
|
3397 | {
|
3345 | e.printStackTrace();
|
3398 | e.printStackTrace();
|
|
|
3399 | }
|
|
|
3400 |
|
3346 | }
|
3401 | }
|
3347 |
|
3402 |
|
3348 | }
|
3403 | }
|
3349 | while (numRead != -1);
|
3404 | while (numRead != -1);
|
3350 |
|
3405 |
|
… | |
… | |
3485 | catch (FileNotFoundException e)
|
3540 | catch (FileNotFoundException e)
|
3486 | {
|
3541 | {
|
3487 | e.printStackTrace();
|
3542 | e.printStackTrace();
|
3488 | }
|
3543 | }
|
3489 |
|
3544 |
|
|
|
3545 | old_percent_ = -1;
|
|
|
3546 | percent_ = -2;
|
|
|
3547 |
|
3490 | byte[] buffer = new byte[1024 * MD5_CALC_BUFFER_KB];
|
3548 | byte[] buffer = new byte[1024 * MD5_CALC_BUFFER_KB];
|
3491 | int numRead = 0;
|
3549 | int numRead = 0;
|
3492 | do
|
3550 | do
|
3493 | {
|
3551 | {
|
3494 | if (mapdownload_stop_all_threads)
|
3552 | if (mapdownload_stop_all_threads)
|
… | |
… | |
3529 | }
|
3587 | }
|
3530 | digest.update(buffer, 0, numRead);
|
3588 | digest.update(buffer, 0, numRead);
|
3531 | cur_pos = cur_pos + numRead;
|
3589 | cur_pos = cur_pos + numRead;
|
3532 | }
|
3590 | }
|
3533 |
|
3591 |
|
|
|
3592 | // do not update notification too often
|
|
|
3593 | old_percent_ = percent_;
|
|
|
3594 | percent_ = calc_percent((int) (cur_pos / 1000), size2);
|
|
|
3595 |
|
|
|
3596 | if (percent_ != old_percent_)
|
|
|
3597 | {
|
3534 | msg = handler.obtainMessage();
|
3598 | msg = handler.obtainMessage();
|
3535 | b = new Bundle();
|
3599 | b = new Bundle();
|
3536 | msg.what = 1;
|
3600 | msg.what = 1;
|
3537 | b.putInt("max", size2);
|
3601 | b.putInt("max", size2);
|
3538 | b.putInt("cur", (int) (cur_pos / 1000));
|
3602 | b.putInt("cur", (int) (cur_pos / 1000));
|
3539 | b.putInt("dialog_num", my_dialog_num);
|
3603 | b.putInt("dialog_num", my_dialog_num);
|
3540 | b.putString("title", Navit.get_text("Mapdownload")); //TRANS
|
3604 | b.putString("title", Navit.get_text("Mapdownload")); //TRANS
|
3541 | b.putString("text", Navit.get_text("generating MD5 checksum")); //TRANS
|
3605 | b.putString("text", Navit.get_text("generating MD5 checksum")); //TRANS
|
3542 | msg.setData(b);
|
3606 | msg.setData(b);
|
3543 | handler.sendMessage(msg);
|
3607 | handler.sendMessage(msg);
|
3544 |
|
3608 |
|
3545 | try
|
3609 | try
|
3546 | {
|
3610 | {
|
3547 | ZANaviMapDownloaderService.set_noti_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3611 | ZANaviMapDownloaderService.set_noti_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3548 | ZANaviMapDownloaderService.set_large_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3612 | ZANaviMapDownloaderService.set_large_text(Navit.get_text("checking") + ": " + calc_percent((int) (cur_pos / 1000), size2) + "%");
|
3549 |
|
3613 |
|
3550 | // update progressbar
|
3614 | // update progressbar
|
3551 | Message msg_prog = new Message();
|
3615 | Message msg_prog = new Message();
|
3552 | Bundle b_prog = new Bundle();
|
3616 | Bundle b_prog = new Bundle();
|
3553 | b_prog.putInt("pg", calc_percent((int) (cur_pos / 1000), size2));
|
3617 | b_prog.putInt("pg", calc_percent((int) (cur_pos / 1000), size2));
|
3554 | msg_prog.what = 2;
|
3618 | msg_prog.what = 2;
|
3555 | msg_prog.setData(b_prog);
|
3619 | msg_prog.setData(b_prog);
|
3556 | ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
|
3620 | ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
|
3557 |
|
3621 |
|
3558 | }
|
3622 | }
|
3559 | catch (Exception e)
|
3623 | catch (Exception e)
|
3560 | {
|
3624 | {
|
3561 | e.printStackTrace();
|
3625 | e.printStackTrace();
|
|
|
3626 | }
|
3562 | }
|
3627 | }
|
3563 |
|
3628 |
|
3564 | }
|
3629 | }
|
3565 | while (numRead != -1);
|
3630 | while (numRead != -1);
|
3566 |
|
3631 |
|