/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitMapDownloader.java
ZANavi

Diff of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitMapDownloader.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 46 Revision 47
301 public static String[] OSM_MAP_NAME_ondisk_ORIG_LIST = null; 301 public static String[] OSM_MAP_NAME_ondisk_ORIG_LIST = null;
302 302
303 private static Boolean already_inited = false; 303 private static Boolean already_inited = false;
304 304
305 public Boolean stop_me = false; 305 public Boolean stop_me = false;
306 static final int SOCKET_CONNECT_TIMEOUT = 22000; // 22 secs. 306 static final int SOCKET_CONNECT_TIMEOUT = 6000; // 22000; // 22 secs.
307 static final int SOCKET_READ_TIMEOUT = 18000; // 18 secs. 307 static final int SOCKET_READ_TIMEOUT = 9000; // 18000; // 18 secs.
308 // static final int MAP_WRITE_FILE_BUFFER = 1024 * 8; 308 // static final int MAP_WRITE_FILE_BUFFER = 1024 * 8;
309 static final int MAP_WRITE_MEM_BUFFER = 1024 * 64; 309 static final int MAP_WRITE_MEM_BUFFER = 1024 * 64;
310 static final int MAP_READ_FILE_BUFFER = 1024 * 64; 310 static final int MAP_READ_FILE_BUFFER = 1024 * 64;
311 static final int UPDATE_PROGRESS_EVERY_CYCLE = 256; // 12; // 8 -> is nicer, but maybe to fast for some devices 311 static final int UPDATE_PROGRESS_EVERY_CYCLE = 256; // 12; // 8 -> is nicer, but maybe to fast for some devices
312 static final int RETRIES = 75; // this many retries on map download 312 static final int RETRIES = 9000; // 75; // this many retries on map download
313 static final int MD5_CALC_BUFFER_KB = 128; 313 static final int MD5_CALC_BUFFER_KB = 128;
314 314
315 static final long MAX_SINGLE_BINFILE_SIZE = 3 * 512 * 1024 * 1024; // split map at this size into pieces [1.5GB] [1.610.612.736 Bytes] 315 static final long MAX_SINGLE_BINFILE_SIZE = 3 * 512 * 1024 * 1024; // split map at this size into pieces [1.5GB] [1.610.612.736 Bytes]
316 // static final long MAX_SINGLE_BINFILE_SIZE = 800 * 1024 * 1024; // split map at this size into pieces [~800 MBytes] 316 // static final long MAX_SINGLE_BINFILE_SIZE = 800 * 1024 * 1024; // split map at this size into pieces [~800 MBytes]
317 // --- DEBUG ONLY --- // static final long MAX_SINGLE_BINFILE_SIZE = 80 * 1024 * 1024; // 80 MBytes // --- DEBUG ONLY --- // 317 // --- DEBUG ONLY --- // static final long MAX_SINGLE_BINFILE_SIZE = 80 * 1024 * 1024; // 80 MBytes // --- DEBUG ONLY --- //
333 static final String MAP_FILENAME_BORDERS = "borders.bin"; 333 static final String MAP_FILENAME_BORDERS = "borders.bin";
334 static final String MAP_FILENAME_COASTLINE = "coastline.bin"; 334 static final String MAP_FILENAME_COASTLINE = "coastline.bin";
335 335
336 static long[] mapdownload_already_read = null; 336 static long[] mapdownload_already_read = null;
337 static float[] mapdownload_byte_per_second_overall = null; 337 static float[] mapdownload_byte_per_second_overall = null;
338 static float[] mapdownload_byte_per_second_now = null;
338 static int mapdownload_error_code = 0; 339 static int mapdownload_error_code = 0;
339 static Boolean mapdownload_stop_all_threads = false; 340 static Boolean mapdownload_stop_all_threads = false;
340 341
341 static final int MAX_MAP_COUNT = 500; 342 static final int MAX_MAP_COUNT = 500;
342 343
491 String fileName = null; 492 String fileName = null;
492 String final_fileName = null; 493 String final_fileName = null;
493 String this_server_name = null; 494 String this_server_name = null;
494 String up_map = null; 495 String up_map = null;
495 long start_byte = 0L; 496 long start_byte = 0L;
497 long start_byte_count_now = 0L;
496 long end_byte = 0L; 498 long end_byte = 0L;
497 499
498 MultiStreamDownloaderThread(int num_threads, Handler h, zanavi_osm_map_values map_values, int map_num2, int c, String p, String p2, String fn, String ffn, String sn, String upmap, long start_byte, long end_byte) 500 MultiStreamDownloaderThread(int num_threads, Handler h, zanavi_osm_map_values map_values, int map_num2, int c, String p, String p2, String fn, String ffn, String sn, String upmap, long start_byte, long end_byte)
499 { 501 {
500 running = false; 502 running = false;
529 531
530 public void run() 532 public void run()
531 { 533 {
532 running = true; 534 running = true;
533 535
536 try
537 {
538 // update srv text
539 Message msg_prog88 = new Message();
540 Bundle b_prog88 = new Bundle();
541 b_prog88.putString("srv", this.this_server_name);
542 b_prog88.putInt("threadnum", (this.my_num - 1));
543 msg_prog88.what = 4;
544 msg_prog88.setData(b_prog88);
545 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog88);
546 }
547 catch (Exception e_srv)
548 {
549 }
550
534 // System.out.println("DEBUG_MAP_DOWNLOAD::MultiStreamDownloaderThread " + this.my_num + " run"); 551 // System.out.println("DEBUG_MAP_DOWNLOAD::MultiStreamDownloaderThread " + this.my_num + " run");
535 while (running) 552 while (running)
536 { 553 {
537 if (mapdownload_stop_all_threads == true) 554 if (mapdownload_stop_all_threads == true)
538 { 555 {
595 long alt_progress_update_timestamp = 0L; 612 long alt_progress_update_timestamp = 0L;
596 int progress_update_intervall = 600; // show progress about every xx milliseconds 613 int progress_update_intervall = 600; // show progress about every xx milliseconds
597 614
598 String kbytes_per_second = ""; 615 String kbytes_per_second = "";
599 long start_timestamp = System.currentTimeMillis(); 616 long start_timestamp = System.currentTimeMillis();
617 long start_timestamp_count_now = System.currentTimeMillis();
600 NumberFormat formatter = new DecimalFormat("00000.0"); 618 NumberFormat formatter = new DecimalFormat("00000.0");
601 String eta_string = ""; 619 String eta_string = "";
602 float per_second_overall = 0f; 620 float per_second_overall = 0f;
621 float per_second_now = 0f;
603 long bytes_remaining = 0; 622 long bytes_remaining = 0;
604 int eta_seconds = 0; 623 int eta_seconds = 0;
605 624
606 int current_split = 0; 625 int current_split = 0;
607 int next_split = 0; 626 int next_split = 0;
708 727
709 // System.out.println("DEBUG_MAP_DOWNLOAD::" + this.my_num + "buf avail1=" + bif.available()); 728 // System.out.println("DEBUG_MAP_DOWNLOAD::" + this.my_num + "buf avail1=" + bif.available());
710 729
711 // len1 -> number of bytes actually read 730 // len1 -> number of bytes actually read
712 //while (((len1 = bif.read(buffer)) != -1) && (already_read <= this.end_byte)) 731 //while (((len1 = bif.read(buffer)) != -1) && (already_read <= this.end_byte))
732
733 Message msg_prog = null;
734 Bundle b_prog = null;
735
713 while ((len1 = bif.read(buffer)) != -1) 736 while ((len1 = bif.read(buffer)) != -1)
714 { 737 {
715 // System.out.println("DEBUG_MAP_DOWNLOAD::" + this.my_num + " buf avail2=" + bif.available() + " len1=" + len1); 738 // System.out.println("DEBUG_MAP_DOWNLOAD::" + this.my_num + " buf avail2=" + bif.available() + " len1=" + len1);
716 739
717 if (stop_me) 740 if (stop_me)
735 alt_cur = 0; 758 alt_cur = 0;
736 alt_progress_update_timestamp = System.currentTimeMillis(); 759 alt_progress_update_timestamp = System.currentTimeMillis();
737 760
738 count_read_per_interval++; 761 count_read_per_interval++;
739 762
740 if (count_read_per_interval == 10) 763 if (count_read_per_interval == 15)
741 { 764 {
742 // int rate = (int) ((float) read_per_interval / ((float) progress_update_intervall * 10f / 1000f * 1024f)); 765 // int rate = (int) ((float) read_per_interval / ((float) progress_update_intervall * 10f / 1000f * 1024f));
743 // if (rate < 1) 766 // if (rate < 1)
744 // { 767 // {
745 // System.out.println("DEBUG_MAP_DOWNLOAD::" + this.my_num + " downloadrate: 0 kbytes/s"); 768 // System.out.println("DEBUG_MAP_DOWNLOAD::" + this.my_num + " downloadrate: 0 kbytes/s");
767 b = new Bundle(); 790 b = new Bundle();
768 msg.what = 1; 791 msg.what = 1;
769 792
770 b.putInt("dialog_num", my_dialog_num); 793 b.putInt("dialog_num", my_dialog_num);
771 b.putString("title", Navit.get_text("Mapdownload")); //TRANS 794 b.putString("title", Navit.get_text("Mapdownload")); //TRANS
772 per_second_overall = (float) (already_read - this.start_byte) / (float) ((System.currentTimeMillis() - start_timestamp) / 1000); 795 // per_second_overall = (float) (already_read - this.start_byte) / (float) ((System.currentTimeMillis() - start_timestamp) / 1000);
796 per_second_now = (int) (already_read - this.start_byte_count_now) / (((float) (System.currentTimeMillis() - start_timestamp_count_now)) / 1000.0f);
797 // System.out.println("DL:TH=" + (this.my_num - 1) + " psn=" + per_second_now + " " + already_read + " " + this.start_byte_count_now + " " + System.currentTimeMillis() + " " + start_timestamp_count_now + " :" + ((long) (System.currentTimeMillis() - start_timestamp_count_now)));
798 this.start_byte_count_now = already_read;
799 start_timestamp_count_now = System.currentTimeMillis();
773 800
774 mapdownload_already_read[this.my_num - 1] = already_read - this.start_byte; 801 mapdownload_already_read[this.my_num - 1] = already_read - this.start_byte;
775 mapdownload_byte_per_second_overall[this.my_num - 1] = per_second_overall; 802 // mapdownload_byte_per_second_overall[this.my_num - 1] = per_second_overall;
803
804 if (Math.abs(mapdownload_byte_per_second_now[this.my_num - 1] - per_second_now) > 600000)
805 {
806 mapdownload_byte_per_second_now[this.my_num - 1] = per_second_now;
807 }
808 else
809 {
810 mapdownload_byte_per_second_now[this.my_num - 1] = per_second_now + ((mapdownload_byte_per_second_now[this.my_num - 1] - per_second_now) / 2.0f);
811 }
776 812
777 //b.putInt("max", (int) (this.end_byte / 1024)); 813 //b.putInt("max", (int) (this.end_byte / 1024));
778 //b.putInt("cur", (int) ((already_read - this.start_byte) / 1024)); 814 //b.putInt("cur", (int) ((already_read - this.start_byte) / 1024));
779 float f1 = 0; 815 float f1 = 0;
780 long l1 = 0L; 816 long l1 = 0L;
781 int k; 817 int k;
782 for (k = 0; k < mapdownload_already_read.length; k++) 818 for (k = 0; k < mapdownload_already_read.length; k++)
783 { 819 {
784 l1 = l1 + mapdownload_already_read[k]; 820 l1 = l1 + mapdownload_already_read[k];
821 // *long time* // f1 = f1 + mapdownload_byte_per_second_overall[k];
822 //
823 // *now*
785 f1 = f1 + mapdownload_byte_per_second_overall[k]; 824 f1 = f1 + mapdownload_byte_per_second_now[k];
786 } 825 }
787 b.putInt("max", (int) (map_values.est_size_bytes / 1024)); 826 b.putInt("max", (int) (map_values.est_size_bytes / 1024));
788 b.putInt("cur", (int) (l1 / 1024)); 827 b.putInt("cur", (int) (l1 / 1024));
828
829 // update progressbar
830 msg_prog = new Message();
831 b_prog = new Bundle();
832 b_prog.putInt("pg", (int) (((l1 / 1024.0f) / (map_values.est_size_bytes / 1024.0f)) * 100.0f));
833 msg_prog.what = 2;
834 msg_prog.setData(b_prog);
835 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
836
837 // update speedbar
838 msg_prog = new Message();
839 b_prog = new Bundle();
840 b_prog.putInt("speed_kb_per_sec", (int) (mapdownload_byte_per_second_now[this.my_num - 1] / 1024.0f));
841 b_prog.putInt("threadnum", (this.my_num - 1));
842 msg_prog.what = 3;
843 msg_prog.setData(b_prog);
844 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
789 845
790 kbytes_per_second = formatter.format((f1 / 1024f)); 846 kbytes_per_second = formatter.format((f1 / 1024f));
791 // kbytes_per_second = formatter.format((per_second_overall / 1024f)); 847 // kbytes_per_second = formatter.format((per_second_overall / 1024f));
792 // bytes_remaining = this.end_byte - already_read; 848 // bytes_remaining = this.end_byte - already_read;
793 bytes_remaining = map_values.est_size_bytes - l1; 849 bytes_remaining = map_values.est_size_bytes - l1;
894 } 950 }
895 d_close_file(f_rnd, this.my_num); 951 d_close_file(f_rnd, this.my_num);
896 bif.close(); 952 bif.close();
897 d_url_disconnect(c); 953 d_url_disconnect(c);
898 954
955 mapdownload_byte_per_second_now[this.my_num - 1] = 0;
956 // update speedbar
957 Message msg_prog77 = new Message();
958 Bundle b_prog77 = new Bundle();
959 b_prog77.putInt("speed_kb_per_sec", 0);
960 b_prog77.putInt("threadnum", (this.my_num - 1));
961 msg_prog77.what = 3;
962 msg_prog77.setData(b_prog77);
963 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog77);
964
899 // delete an already final filename, first 965 // delete an already final filename, first
900 //**final_outputFile.delete(); 966 //**final_outputFile.delete();
901 // rename file to final name 967 // rename file to final name
902 //**outputFile.renameTo(final_outputFile); 968 //**outputFile.renameTo(final_outputFile);
903 969
928 this.running = false; 994 this.running = false;
929 } 995 }
930 } 996 }
931 catch (IOException e) 997 catch (IOException e)
932 { 998 {
999 mapdownload_byte_per_second_now[this.my_num - 1] = 0;
1000 // update speedbar
1001 Message msg_prog77 = new Message();
1002 Bundle b_prog77 = new Bundle();
1003 b_prog77.putInt("speed_kb_per_sec", 0);
1004 b_prog77.putInt("threadnum", (this.my_num - 1));
1005 msg_prog77.what = 3;
1006 msg_prog77.setData(b_prog77);
1007 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog77);
1008
933 msg = handler.obtainMessage(); 1009 msg = handler.obtainMessage();
934 b = new Bundle(); 1010 b = new Bundle();
935 msg.what = 2; 1011 msg.what = 2;
936 b.putInt("dialog_num", my_dialog_num); 1012 b.putInt("dialog_num", my_dialog_num);
937 b.putString("text", Navit.get_text("Error downloading map, resuming")); //TRANS 1013 b.putString("text", Navit.get_text("Error downloading map, resuming")); //TRANS
952 } 1028 }
953 d_url_disconnect(c); 1029 d_url_disconnect(c);
954 } 1030 }
955 catch (Exception e) 1031 catch (Exception e)
956 { 1032 {
1033
1034 mapdownload_byte_per_second_now[this.my_num - 1] = 0;
1035 // update speedbar
1036 Message msg_prog77 = new Message();
1037 Bundle b_prog77 = new Bundle();
1038 b_prog77.putInt("speed_kb_per_sec", 0);
1039 b_prog77.putInt("threadnum", (this.my_num - 1));
1040 msg_prog77.what = 3;
1041 msg_prog77.setData(b_prog77);
1042 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog77);
1043
957 try 1044 try
958 { 1045 {
959 bif.close(); 1046 bif.close();
960 } 1047 }
961 catch (IOException e1) 1048 catch (IOException e1)
978 } 1065 }
979 } 1066 }
980 else 1067 else
981 // bif == null 1068 // bif == null
982 { 1069 {
1070 mapdownload_byte_per_second_now[this.my_num - 1] = 0;
1071 // update speedbar
1072 Message msg_prog77 = new Message();
1073 Bundle b_prog77 = new Bundle();
1074 b_prog77.putInt("speed_kb_per_sec", 0);
1075 b_prog77.putInt("threadnum", (this.my_num - 1));
1076 msg_prog77.what = 3;
1077 msg_prog77.setData(b_prog77);
1078 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog77);
1079
983 d_url_disconnect(c); 1080 d_url_disconnect(c);
984 try 1081 try
985 { 1082 {
986 // sleep for 2 second 1083 // sleep for 2 second
987 Thread.sleep(2000); 1084 Thread.sleep(2000);
993 } 1090 }
994 // bif null ------ 1091 // bif null ------
995 1092
996 if (!download_success) 1093 if (!download_success)
997 { 1094 {
1095 mapdownload_byte_per_second_now[this.my_num - 1] = 0;
1096 // update speedbar
1097 Message msg_prog77 = new Message();
1098 Bundle b_prog77 = new Bundle();
1099 b_prog77.putInt("speed_kb_per_sec", 0);
1100 b_prog77.putInt("threadnum", (this.my_num - 1));
1101 msg_prog77.what = 3;
1102 msg_prog77.setData(b_prog77);
1103 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog77);
1104
998 try 1105 try
999 { 1106 {
1000 // sleep for 2 second (also here) 1107 // sleep for 2 second (also here)
1001 Thread.sleep(2000); 1108 Thread.sleep(2000);
1002 } 1109 }
1015 catch (InterruptedException e) 1122 catch (InterruptedException e)
1016 { 1123 {
1017 e.printStackTrace(); 1124 e.printStackTrace();
1018 } 1125 }
1019 } 1126 }
1127
1128 mapdownload_byte_per_second_now[this.my_num - 1] = 0;
1129 // update speedbar
1130 Message msg_prog77 = new Message();
1131 Bundle b_prog77 = new Bundle();
1132 b_prog77.putInt("speed_kb_per_sec", 0);
1133 b_prog77.putInt("threadnum", (this.my_num - 1));
1134 msg_prog77.what = 3;
1135 msg_prog77.setData(b_prog77);
1136 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog77);
1137
1020 System.out.println("MultiStreamDownloaderThread " + this.my_num + " finished"); 1138 System.out.println("MultiStreamDownloaderThread " + this.my_num + " finished");
1021 } 1139 }
1022 } 1140 }
1023 1141
1024 //public Navit navit_jmain = null; 1142 //public Navit navit_jmain = null;
1710 if ((other_server_name == null) || (map_servers_list.contains(other_server_name))) 1828 if ((other_server_name == null) || (map_servers_list.contains(other_server_name)))
1711 { 1829 {
1712 // try again 1830 // try again
1713 try 1831 try
1714 { 1832 {
1715 Thread.sleep(110); 1833 Thread.sleep(90);
1716 } 1834 }
1717 catch (InterruptedException e) 1835 catch (InterruptedException e)
1718 { 1836 {
1719 } 1837 }
1720 other_server_name = d_get_servername(false, map_values); 1838 other_server_name = d_get_servername(false, map_values);
1819 catch (Exception e) 1937 catch (Exception e)
1820 { 1938 {
1821 e.printStackTrace(); 1939 e.printStackTrace();
1822 } 1940 }
1823 1941
1942 String this_server_name = null;
1943 String md5_server = null;
1944
1945 int server_err = 0;
1946 int server_retries = 0;
1947 int server_max_retries = 8;
1948
1949 while (server_retries < server_max_retries)
1950 {
1951 Log.d("NavitMapDownloader", "init:try #" + server_retries);
1952
1824 String this_server_name = d_get_servername(true, map_values); 1953 this_server_name = d_get_servername(true, map_values);
1825 if (this_server_name == null) 1954 if (this_server_name == null)
1826 { 1955 {
1956 Log.d("NavitMapDownloader", "init:try #" + server_retries + " srvname=null");
1957
1958 server_err = 1;
1959 server_retries++;
1960 continue;
1961 }
1962
1963 md5_server = d_get_md5_from_server(map_values, this_server_name, map_num3);
1964 if (md5_server == null)
1965 {
1966 Log.d("NavitMapDownloader", "init:try #" + server_retries + " md5=null" + " srvname=" + this_server_name);
1967
1968 server_err = 1;
1969 server_retries++;
1970 continue;
1971 }
1972 else
1973 {
1974 Log.d("NavitMapDownloader", "init:try #" + server_retries + " md5=" + md5_server + " srvname=" + this_server_name);
1975
1976 server_err = 0;
1977 break;
1978 }
1979
1980 }
1981
1982 if (server_err == 1)
1983 {
1984 //if (this_server_name == null)
1985 //{
1827 msg = handler.obtainMessage(); 1986 msg = handler.obtainMessage();
1828 b = new Bundle(); 1987 b = new Bundle();
1829 msg.what = 2; 1988 msg.what = 2;
1830 b.putInt("dialog_num", my_dialog_num); 1989 b.putInt("dialog_num", my_dialog_num);
1831 b.putString("text", Navit.get_text("Error downloading map!")); //TRANS 1990 b.putString("text", Navit.get_text("Error downloading map!")); //TRANS
1832 msg.setData(b); 1991 msg.setData(b);
1833 handler.sendMessage(msg); 1992 handler.sendMessage(msg);
1834 1993
1835 return 1; 1994 return 1;
1836 } 1995 //}
1837
1838 String md5_server = d_get_md5_from_server(map_values, this_server_name, map_num3);
1839 if (md5_server == null)
1840 {
1841 msg = handler.obtainMessage();
1842 b = new Bundle();
1843 msg.what = 2;
1844 b.putInt("dialog_num", my_dialog_num);
1845 b.putString("text", Navit.get_text("Error downloading map!")); //TRANS
1846 msg.setData(b);
1847 handler.sendMessage(msg);
1848
1849 return 1;
1850 } 1996 }
1851 1997
1852 // on disk md5 can be "null" , when downloading new map 1998 // on disk md5 can be "null" , when downloading new map
1853 String md5_disk = d_get_md5_from_disk(map_values, this_server_name, map_num3); 1999 String md5_disk = d_get_md5_from_disk(map_values, this_server_name, map_num3);
1854 2000
2021 MultiStreamDownloaderThread[] m = new MultiStreamDownloaderThread[num_threads]; 2167 MultiStreamDownloaderThread[] m = new MultiStreamDownloaderThread[num_threads];
2022 int k; 2168 int k;
2023 mapdownload_error_code_clear(); 2169 mapdownload_error_code_clear();
2024 mapdownload_already_read = new long[num_threads]; 2170 mapdownload_already_read = new long[num_threads];
2025 mapdownload_byte_per_second_overall = new float[num_threads]; 2171 mapdownload_byte_per_second_overall = new float[num_threads];
2172 mapdownload_byte_per_second_now = new float[num_threads];
2026 for (k = 0; k < num_threads; k++) 2173 for (k = 0; k < num_threads; k++)
2027 { 2174 {
2028 mapdownload_already_read[k] = 0; 2175 mapdownload_already_read[k] = 0;
2029 mapdownload_byte_per_second_overall[k] = 0; 2176 mapdownload_byte_per_second_overall[k] = 0;
2177 mapdownload_byte_per_second_now[k] = 0;
2178 }
2179
2180 for (k = 0; k < num_threads; k++)
2181 {
2182 // enale speedbar(s)
2183 // System.out.println("SPB:enable:#" + k);
2184
2185 Message msg_prog = new Message();
2186 Bundle b_prog = new Bundle();
2187 b_prog.putInt("speed_kb_per_sec", -2);
2188 b_prog.putInt("threadnum", k);
2189 msg_prog.what = 3;
2190 msg_prog.setData(b_prog);
2191 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
2030 } 2192 }
2031 2193
2032 // start downloader threads here -------------------------- 2194 // start downloader threads here --------------------------
2033 // start downloader threads here -------------------------- 2195 // start downloader threads here --------------------------
2034 String new_map_server = null; 2196 String new_map_server = null;
2075 // 2237 //
2076 // 2238 //
2077 // calc md5sum on device on print it to STDOUT 2239 // calc md5sum on device on print it to STDOUT
2078 //if (!split_mapfile) 2240 //if (!split_mapfile)
2079 //{ 2241 //{
2242
2243 // set progressbar to 100%
2244 Message msg_prog1 = new Message();
2245 Bundle b_prog1 = new Bundle();
2246 b_prog1.putInt("pg", 100);
2247 msg_prog1.what = 2;
2248 msg_prog1.setData(b_prog1);
2249 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog1);
2250
2251 for (k = 0; k < num_threads; k++)
2252 {
2253 // update speedbar
2254 Message msg_prog = new Message();
2255 Bundle b_prog = new Bundle();
2256 b_prog.putInt("speed_kb_per_sec", 0);
2257 b_prog.putInt("threadnum", k);
2258 msg_prog.what = 3;
2259 msg_prog.setData(b_prog);
2260 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
2261 }
2080 2262
2081 try 2263 try
2082 { 2264 {
2083 ZANaviMapDownloaderService.set_noti_text(Navit.get_text("checking map ...")); 2265 ZANaviMapDownloaderService.set_noti_text(Navit.get_text("checking map ..."));
2084 ZANaviMapDownloaderService.set_large_text(Navit.get_text("checking map ...")); 2266 ZANaviMapDownloaderService.set_large_text(Navit.get_text("checking map ..."));
2256 int k_idx; 2438 int k_idx;
2257 2439
2258 mapdownload_error_code_clear(); 2440 mapdownload_error_code_clear();
2259 mapdownload_already_read = new long[num_threads]; 2441 mapdownload_already_read = new long[num_threads];
2260 mapdownload_byte_per_second_overall = new float[num_threads]; 2442 mapdownload_byte_per_second_overall = new float[num_threads];
2443 mapdownload_byte_per_second_now = new float[num_threads];
2261 for (k_idx = 0; k_idx < num_threads; k_idx++) 2444 for (k_idx = 0; k_idx < num_threads; k_idx++)
2262 { 2445 {
2263 mapdownload_already_read[k_idx] = 0; 2446 mapdownload_already_read[k_idx] = 0;
2264 mapdownload_byte_per_second_overall[k_idx] = 0; 2447 mapdownload_byte_per_second_overall[k_idx] = 0;
2448 mapdownload_byte_per_second_now[k_idx] = 0;
2265 } 2449 }
2266 2450
2267 // start downloader threads here -------------------------- 2451 // start downloader threads here --------------------------
2268 // start downloader threads here -------------------------- 2452 // start downloader threads here --------------------------
2269 for (k_idx = 0; k_idx < num_threads; k_idx++) 2453 for (k_idx = 0; k_idx < num_threads; k_idx++)
2301 mapdownload_error_code_clear(); 2485 mapdownload_error_code_clear();
2302 index_file_download = false; 2486 index_file_download = false;
2303 } 2487 }
2304 else 2488 else
2305 { 2489 {
2490 // set progressbar to 100%
2491 Message msg_prog2 = new Message();
2492 Bundle b_prog2 = new Bundle();
2493 b_prog2.putInt("pg", 100);
2494 msg_prog2.what = 2;
2495 msg_prog2.setData(b_prog2);
2496 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog2);
2497
2498 for (k_idx = 0; k_idx < num_threads; k_idx++)
2499 {
2500 // update speedbar
2501 Message msg_prog = new Message();
2502 Bundle b_prog = new Bundle();
2503 b_prog.putInt("speed_kb_per_sec", 0);
2504 b_prog.putInt("threadnum", k_idx);
2505 msg_prog.what = 3;
2506 msg_prog.setData(b_prog);
2507 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg_prog);
2508 }
2509
2306 // delete an already there idx file, first 2510 // delete an already there idx file, first
2307 //System.out.println("idx 001:" + Navit.MAP_FILENAME_PATH + final_fileName + ".idx"); 2511 //System.out.println("idx 001:" + Navit.MAP_FILENAME_PATH + final_fileName + ".idx");
2308 File idx_final_filename = new File(Navit.MAP_FILENAME_PATH + final_fileName + ".idx"); 2512 File idx_final_filename = new File(Navit.MAP_FILENAME_PATH + final_fileName + ".idx");
2309 idx_final_filename.delete(); 2513 idx_final_filename.delete();
2310 // rename file to final name 2514 // rename file to final name

Legend:
Removed from v.46  
changed lines
  Added in v.47

   
Visit the ZANavi Wiki