Commit 5ee6b759fc6523891c8c966e40ec29fdb8e661d4
1 parent
f1cfecc5
手动升级
Showing
8 changed files
with
161 additions
and
78 deletions
C5/app/src/main/AndroidManifest.xml
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | xmlns:tools="http://schemas.android.com/tools" |
4 | 4 | package="com.sunvote.xpadapp" |
5 | 5 | android:versionCode="70" |
6 | - android:versionName="1.4.0.3"> <!-- android:sharedUserId="android.studentUID.system" --> | |
6 | + android:versionName="1.4.0.5"> <!-- android:sharedUserId="android.studentUID.system" --> | |
7 | 7 | |
8 | 8 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"></uses-permission> |
9 | 9 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> | ... | ... |
C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java
... | ... | @@ -1892,7 +1892,6 @@ public class MainActivity extends BaseActivity implements ComListener { |
1892 | 1892 | if(isInVoteState()){ |
1893 | 1893 | return; |
1894 | 1894 | } |
1895 | - | |
1896 | 1895 | if(currBillInfo!=null) { |
1897 | 1896 | if (currBillInfo.billmodel == 1) { //民事选举 |
1898 | 1897 | if ((data[0] & 0xff) == 0xF2 && data[1] == 20) { | ... | ... |
C5/app/src/main/java/com/sunvote/xpadapp/fragments/AdminFragment.java
... | ... | @@ -29,6 +29,7 @@ public class AdminFragment extends BaseFragment { |
29 | 29 | private ImageButton btnBack; |
30 | 30 | private Button btnConfig; |
31 | 31 | private Button btnPowerOff; |
32 | + private Button firmUpdate; | |
32 | 33 | private Button btnComTest; |
33 | 34 | private Button match; |
34 | 35 | |
... | ... | @@ -40,9 +41,14 @@ public class AdminFragment extends BaseFragment { |
40 | 41 | btnBack = view.findViewById(R.id.admin_btnback); |
41 | 42 | btnConfig = view.findViewById(R.id.admin_config_mode); |
42 | 43 | btnPowerOff = view.findViewById(R.id.admin_btnShutdown); |
44 | + firmUpdate = view.findViewById(R.id.firm_update); | |
43 | 45 | match = view.findViewById(R.id.match); |
44 | 46 | |
45 | - tvModalInfo.setText(getString(R.string.app_version) + getVersionName()); | |
47 | + String msg = getString(R.string.app_version) + getVersionName() ; | |
48 | + if(mMainActivity.mModelInfo != null){ | |
49 | + msg += " 固件版本:" + mMainActivity.mModelInfo.sVer; | |
50 | + } | |
51 | + tvModalInfo.setText(msg); | |
46 | 52 | btnBack.setOnClickListener(new OnClickListener() { |
47 | 53 | @Override |
48 | 54 | public void onClick(View v) { |
... | ... | @@ -127,6 +133,17 @@ public class AdminFragment extends BaseFragment { |
127 | 133 | } |
128 | 134 | }); |
129 | 135 | |
136 | + firmUpdate.setOnClickListener(new OnClickListener() { | |
137 | + @Override | |
138 | + public void onClick(View v) { | |
139 | + FragmentManager fm = getFragmentManager(); | |
140 | + FragmentTransaction tx = fm.beginTransaction(); | |
141 | + tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); | |
142 | + tx.replace(R.id.frame_content, new FirmUpdateFragment()); | |
143 | + tx.commit(); | |
144 | + } | |
145 | + }); | |
146 | + | |
130 | 147 | return view; |
131 | 148 | } |
132 | 149 | ... | ... |
C5/app/src/main/java/com/sunvote/xpadapp/fragments/FirmUpdateFragment.java
... | ... | @@ -66,20 +66,21 @@ public class FirmUpdateFragment extends BaseFragment { |
66 | 66 | |
67 | 67 | getActivity().registerReceiver(mBroadcastReceiver, filter); |
68 | 68 | success = false; |
69 | - firmUpdate(); | |
69 | + | |
70 | 70 | |
71 | 71 | btnRetry = (Button)view.findViewById(R.id.firm_update_btn_retry); |
72 | - btnRetry.setVisibility(View.INVISIBLE); | |
73 | 72 | btnRetry.setOnClickListener(new OnClickListener() { |
74 | 73 | @Override |
75 | 74 | public void onClick(View v) { |
76 | 75 | LogUtil.i(TAG, "onClick: retry"); |
77 | - appendLog("重试"); | |
78 | - firmUpdate(); | |
79 | 76 | btnRetry.setVisibility(View.INVISIBLE); |
77 | + appendLog("重试"); | |
78 | + firmUpdate(checkFirmFile2()); | |
79 | + | |
80 | 80 | } |
81 | 81 | }); |
82 | 82 | |
83 | + firmUpdate(checkFirmFile()); | |
83 | 84 | |
84 | 85 | return view; |
85 | 86 | } |
... | ... | @@ -107,15 +108,45 @@ public class FirmUpdateFragment extends BaseFragment { |
107 | 108 | return files[0]; |
108 | 109 | } |
109 | 110 | |
110 | - private void firmUpdate() { | |
111 | + public static File checkFirmFile2() { | |
112 | + String filePath = Environment.getExternalStorageDirectory().getPath() + "/sunvote/system2/"; | |
113 | + File file = new File(filePath); | |
114 | + if (!file.exists()) { | |
115 | + LogUtil.i(TAG, "checkFirmFile: dir not exists"); | |
116 | + return null; | |
117 | + } | |
118 | + File[] files = file.listFiles(); | |
119 | + | |
120 | + if (files == null || files.length == 0) { | |
121 | + LogUtil.i(TAG, "checkFirmFile:bin not exists"); | |
122 | + return null; | |
123 | + } | |
124 | + return files[0]; | |
125 | + } | |
126 | + | |
127 | + private void firmUpdate(File file) { | |
111 | 128 | |
112 | - File file = checkFirmFile(); | |
113 | 129 | if(file==null){ |
130 | + appendLog("升级文件不存在"); | |
131 | + appendLog("升级文件路径:" + Environment.getExternalStorageDirectory().getPath() + "/sunvote/system2/"); | |
114 | 132 | Toast.makeText(mMainActivity, "升级文件不存在", Toast.LENGTH_LONG).show(); |
133 | + getActivity().runOnUiThread(new Runnable() { | |
134 | + @Override | |
135 | + public void run() { | |
136 | + btnRetry.setVisibility(View.VISIBLE); | |
137 | + } | |
138 | + }); | |
139 | + return; | |
115 | 140 | } |
116 | - if(!file.getName().endsWith(".bin")){ | |
141 | + if(file != null && !file.getName().endsWith(".bin")){ | |
117 | 142 | tvInfo.setText("升级文件格式错误"); |
118 | 143 | Toast.makeText(mMainActivity, "升级文件格式错误", Toast.LENGTH_LONG).show(); |
144 | + getActivity().runOnUiThread(new Runnable() { | |
145 | + @Override | |
146 | + public void run() { | |
147 | + btnRetry.setVisibility(View.VISIBLE); | |
148 | + } | |
149 | + }); | |
119 | 150 | return; |
120 | 151 | } |
121 | 152 | |
... | ... | @@ -143,6 +174,7 @@ public class FirmUpdateFragment extends BaseFragment { |
143 | 174 | LogUtil.i(TAG, "handleMessage: 固件更新成功"); |
144 | 175 | tvInfo.setText("固件更新成功"); |
145 | 176 | appendLog("固件更新成功"); |
177 | + btnRetry.setVisibility(View.VISIBLE); | |
146 | 178 | Toast.makeText(mMainActivity, "固件更新成功", Toast.LENGTH_LONG).show(); |
147 | 179 | |
148 | 180 | } else { | ... | ... |
C5/app/src/main/java/com/sunvote/xpadcomm/XPadApi.java
... | ... | @@ -100,15 +100,23 @@ public class XPadApi implements XPadApiInterface { |
100 | 100 | e.printStackTrace(); |
101 | 101 | } |
102 | 102 | mBuffer = new byte[0x1F + 4]; |
103 | - Arrays.fill(mBuffer, (byte) 0x0); | |
104 | - mBuffer[0] = (byte) 0xF5; | |
105 | - mBuffer[1] = (byte) 0xAA; | |
106 | - mBuffer[2] = (byte) 0xAA; | |
107 | - mBuffer[3] = (byte) 0x1F; | |
108 | - | |
109 | - mBuffer[4] = 0x70; | |
110 | - mBuffer[5] = 0x04; | |
111 | - writeToCom(mBuffer); | |
103 | + Arrays.fill(mBuffer, (byte) 0x0); | |
104 | + mBuffer[0] = (byte) 0xF5; | |
105 | + mBuffer[1] = (byte) 0xAA; | |
106 | + mBuffer[2] = (byte) 0xAA; | |
107 | + mBuffer[3] = (byte) 0x1F; | |
108 | + | |
109 | + mBuffer[4] = 0x70; | |
110 | + mBuffer[5] = 0x04; | |
111 | + writeToCom(mBuffer); | |
112 | + | |
113 | + try { | |
114 | + Thread.sleep(100); | |
115 | + } catch (InterruptedException e) { | |
116 | + e.printStackTrace(); | |
117 | + } | |
118 | + getWorkMode(); | |
119 | + | |
112 | 120 | }else{ |
113 | 121 | onLineInfo.onLine = 2 ; |
114 | 122 | m_listener.onOnLineEvent(onLineInfo); |
... | ... | @@ -1799,7 +1807,7 @@ public class XPadApi implements XPadApiInterface { |
1799 | 1807 | byte packL = dt[8];// 数据片编号 |
1800 | 1808 | LogUtil.d(TAG, "下载。。。msgId:" + msgid + " packH:" + packH + " apckL:" + packL); |
1801 | 1809 | |
1802 | - if (downType == 40) {// 文件下载 | |
1810 | + if (downType == 40) { // 文件下载 | |
1803 | 1811 | if (lastPackH != packH) { //新的packH |
1804 | 1812 | LogUtil.i(TAG, "new packH......."); |
1805 | 1813 | okBits = 0; | ... | ... |
C5/app/src/main/java/com/sunvote/xpadcomm/XPadApiInterface.java
... | ... | @@ -193,7 +193,9 @@ public interface XPadApiInterface { |
193 | 193 | lineInfo.rx = rx; |
194 | 194 | lineInfo.baseId = baseId; |
195 | 195 | lineInfo.keyId = keyId; |
196 | - lineInfo.keySn = new String(keySn); | |
196 | + if(keySn != null){ | |
197 | + lineInfo.keySn = new String(keySn); | |
198 | + } | |
197 | 199 | lineInfo.comError = comError; |
198 | 200 | |
199 | 201 | return lineInfo; | ... | ... |
C5/app/src/main/res/layout/fragment_admin.xml
... | ... | @@ -8,62 +8,87 @@ |
8 | 8 | <LinearLayout |
9 | 9 | android:id="@+id/middle_line" |
10 | 10 | android:layout_width="720dp" |
11 | - android:layout_height="60dp" | |
11 | + android:layout_height="140dp" | |
12 | 12 | android:layout_centerInParent="true" |
13 | - android:orientation="horizontal"> | |
13 | + android:orientation="vertical"> | |
14 | 14 | |
15 | - <Button | |
16 | - android:id="@+id/match" | |
17 | - android:layout_width="0dp" | |
18 | - android:layout_height="60dp" | |
19 | - android:layout_marginRight="80dp" | |
20 | - android:layout_weight="1" | |
21 | - android:background="@color/blue" | |
22 | - android:gravity="center" | |
23 | - android:text="配对" | |
24 | - android:textColor="@color/white" | |
25 | - android:textSize="@dimen/big_text_p5" | |
26 | - android:textStyle="bold" /> | |
27 | - | |
28 | - <Button | |
29 | - android:id="@+id/admin_config_mode" | |
30 | - android:layout_width="0dp" | |
15 | + <LinearLayout | |
16 | + android:layout_width="720dp" | |
31 | 17 | android:layout_height="60dp" |
32 | - android:layout_marginRight="80dp" | |
33 | - android:layout_weight="1" | |
34 | - android:background="@color/blue" | |
35 | - android:gravity="center" | |
36 | - android:text="@string/modifi_idsn" | |
37 | - android:textColor="@color/white" | |
38 | - android:textSize="@dimen/big_text_p5" | |
39 | - android:textStyle="bold" /> | |
18 | + android:orientation="horizontal"> | |
40 | 19 | |
20 | + <Button | |
21 | + android:id="@+id/match" | |
22 | + android:layout_width="0dp" | |
23 | + android:layout_height="60dp" | |
24 | + android:layout_marginRight="80dp" | |
25 | + android:layout_weight="1" | |
26 | + android:background="@color/blue" | |
27 | + android:gravity="center" | |
28 | + android:text="配对" | |
29 | + android:textColor="@color/white" | |
30 | + android:textSize="@dimen/big_text_p5" | |
31 | + android:textStyle="bold" /> | |
41 | 32 | |
33 | + <Button | |
34 | + android:id="@+id/admin_config_mode" | |
35 | + android:layout_width="0dp" | |
36 | + android:layout_height="60dp" | |
37 | + android:layout_marginRight="80dp" | |
38 | + android:layout_weight="1" | |
39 | + android:background="@color/blue" | |
40 | + android:gravity="center" | |
41 | + android:text="@string/modifi_idsn" | |
42 | + android:textColor="@color/white" | |
43 | + android:textSize="@dimen/big_text_p5" | |
44 | + android:textStyle="bold" /> | |
42 | 45 | |
43 | - <Button | |
44 | - android:id="@+id/admin_btnComTest" | |
45 | - android:layout_width="0dp" | |
46 | - android:layout_height="60dp" | |
47 | - android:layout_weight="1" | |
48 | - android:background="@color/blue" | |
49 | - android:gravity="center" | |
50 | - android:text="退出应用" | |
51 | - android:textColor="@color/white" | |
52 | - android:textSize="@dimen/big_text_p5" | |
53 | - android:textStyle="bold" /> | |
54 | - | |
55 | - <Button | |
56 | - android:id="@+id/admin_btnShutdown" | |
57 | - android:layout_width="0dp" | |
46 | + </LinearLayout> | |
47 | + | |
48 | + <LinearLayout | |
49 | + android:layout_width="720dp" | |
58 | 50 | android:layout_height="60dp" |
59 | - android:layout_marginLeft="80dp" | |
60 | - android:layout_weight="1" | |
61 | - android:background="@drawable/oppos_selector" | |
62 | - android:gravity="center" | |
63 | - android:text="@string/shutdown" | |
64 | - android:textColor="@color/white" | |
65 | - android:textSize="@dimen/big_text_p5" | |
66 | - android:textStyle="bold"/> | |
51 | + android:layout_marginTop="20dp" | |
52 | + android:orientation="horizontal"> | |
53 | + | |
54 | + <Button | |
55 | + android:id="@+id/admin_btnComTest" | |
56 | + android:layout_width="0dp" | |
57 | + android:layout_height="60dp" | |
58 | + android:layout_marginRight="80dp" | |
59 | + android:layout_weight="1" | |
60 | + android:background="@color/blue" | |
61 | + android:gravity="center" | |
62 | + android:text="退出应用" | |
63 | + android:textColor="@color/white" | |
64 | + android:textSize="@dimen/big_text_p5" | |
65 | + android:textStyle="bold" /> | |
66 | + | |
67 | + <Button | |
68 | + android:id="@+id/admin_btnShutdown" | |
69 | + android:layout_width="0dp" | |
70 | + android:layout_height="60dp" | |
71 | + android:layout_marginLeft="80dp" | |
72 | + android:layout_weight="1" | |
73 | + android:background="@drawable/oppos_selector" | |
74 | + android:gravity="center" | |
75 | + android:text="@string/shutdown" | |
76 | + android:textColor="@color/white" | |
77 | + android:textSize="@dimen/big_text_p5" | |
78 | + android:textStyle="bold" /> | |
79 | + | |
80 | + <Button | |
81 | + android:id="@+id/firm_update" | |
82 | + android:layout_width="0dp" | |
83 | + android:layout_height="60dp" | |
84 | + android:layout_marginLeft="80dp" | |
85 | + android:layout_weight="1" | |
86 | + android:gravity="center" | |
87 | + android:text="固件升级" | |
88 | + android:textColor="@color/white" | |
89 | + android:textSize="@dimen/big_text_p5" | |
90 | + android:textStyle="bold" /> | |
91 | + </LinearLayout> | |
67 | 92 | |
68 | 93 | </LinearLayout> |
69 | 94 | |
... | ... | @@ -71,12 +96,12 @@ |
71 | 96 | android:id="@+id/admin_modal_title" |
72 | 97 | android:layout_width="wrap_content" |
73 | 98 | android:layout_height="wrap_content" |
74 | - android:layout_centerHorizontal="true" | |
75 | 99 | android:layout_above="@id/middle_line" |
100 | + android:layout_centerHorizontal="true" | |
76 | 101 | android:layout_marginBottom="48dp" |
77 | 102 | android:text="@string/admin_setting" |
78 | - android:textSize="@dimen/big_text_p2" | |
79 | 103 | android:textColor="@color/white" |
104 | + android:textSize="@dimen/big_text_p2" | |
80 | 105 | android:textStyle="bold" /> |
81 | 106 | |
82 | 107 | <TextView |
... | ... | @@ -99,5 +124,4 @@ |
99 | 124 | android:background="@drawable/back" /> |
100 | 125 | |
101 | 126 | |
102 | - | |
103 | 127 | </RelativeLayout> | ... | ... |
C5/app/src/main/res/layout/fragment_firm_update.xml
... | ... | @@ -9,8 +9,9 @@ |
9 | 9 | android:layout_width="wrap_content" |
10 | 10 | android:layout_height="wrap_content" |
11 | 11 | android:layout_centerHorizontal="true" |
12 | - android:layout_marginTop="30dp" | |
13 | - android:textSize="48sp" /> | |
12 | + android:layout_marginTop="10dp" | |
13 | + android:textSize="48sp" | |
14 | + /> | |
14 | 15 | |
15 | 16 | <TextView |
16 | 17 | android:id="@+id/firm_update_ver" |
... | ... | @@ -18,7 +19,7 @@ |
18 | 19 | android:layout_height="wrap_content" |
19 | 20 | android:layout_below="@id/firm_update_title" |
20 | 21 | android:layout_centerHorizontal="true" |
21 | - android:layout_marginTop="100dp" | |
22 | + android:layout_marginTop="10dp" | |
22 | 23 | android:textSize="30sp" /> |
23 | 24 | |
24 | 25 | <TextView |
... | ... | @@ -27,7 +28,7 @@ |
27 | 28 | android:layout_height="wrap_content" |
28 | 29 | android:layout_below="@id/firm_update_ver" |
29 | 30 | android:layout_centerHorizontal="true" |
30 | - android:layout_marginTop="40dp" | |
31 | + android:layout_marginTop="10dp" | |
31 | 32 | android:textSize="30sp" /> |
32 | 33 | |
33 | 34 | <TextView |
... | ... | @@ -36,7 +37,7 @@ |
36 | 37 | android:layout_height="wrap_content" |
37 | 38 | android:layout_below="@id/firm_update_info" |
38 | 39 | android:layout_centerHorizontal="true" |
39 | - android:layout_marginTop="30dp" | |
40 | + android:layout_marginTop="10dp" | |
40 | 41 | android:textSize="30sp" /> |
41 | 42 | |
42 | 43 | <Button | ... | ... |