Эх сурвалжийг харах

修复小米抄写时,出现DSN Contrast faild时,第二次抄写工具崩溃的问题。

Jeff Wang 3 жил өмнө
parent
commit
0ab9f3c95c

+ 32 - 30
FactoryTool_CShare/Views/OperationPanel.cs

@@ -941,8 +941,9 @@ namespace MOKA_Factory_Tools
                         WriteDAK.Checked = (keyInfo.DAK.Length > 0 && m_writeDAK.Text != LResource.Skip);
                         if (WriteDAK.Checked)
                             Log.WriteGetKeyLog("\r\nLocal DB DAK=" + keyInfo.DAK.data);
-                        WriteFVP.Checked = midListNow.keytype == null ? false : midListNow.keytype.ContainsKey("FVP") && m_writeDSN.Text != LResource.Skip;
+                        WriteFVP.Checked = midListNow.keytype == null ? false : midListNow.keytype.ContainsKey("FVP") && m_writeFVP.Text != LResource.Skip;
                         WriteDSN.Checked = midListNow.keytype == null ? false : midListNow.keytype.ContainsKey("DSN") && m_writeDSN.Text != LResource.Skip;
+                        //WriteDolby.Checked = midListNow.keytype == null ? false : midListNow.keytype.ContainsKey("Dolby") && m_writeDolby.Text != LResource.Skip;
                         WritePSN.Checked = FunctionSettingNow.BarcodeWrite;
 
                         timer1.Start();
@@ -2175,7 +2176,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteMac.Checked)
+                if (WriteMac.Checked && midListNow.keytype.ContainsKey("MAC"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "MAC", SN, midListNow.keytype["MAC"], errorDBNow, out string mac, out error, orderNow, out string md5))
                     {
@@ -2189,7 +2190,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteHDCP.Checked)
+                if (WriteHDCP.Checked && midListNow.keytype.ContainsKey("HDCP_KEY"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "HDCP_KEY", SN, midListNow.keytype["HDCP_KEY"], errorDBNow, out string hdcp, out error, orderNow, out string md5))
                     {
@@ -2203,7 +2204,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteHDCP22.Checked)
+                if (WriteHDCP22.Checked && midListNow.keytype.ContainsKey("HDCP2.2_KEY"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "HDCP2.2_KEY", SN, midListNow.keytype["HDCP2.2_KEY"], errorDBNow, out string hdcp22, out error, orderNow, out string md5))
                     {
@@ -2217,7 +2218,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteESN.Checked)
+                if (WriteESN.Checked  && midListNow.keytype.ContainsKey("NETFILX_ESN"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "NETFILX_ESN", SN, midListNow.keytype["NETFILX_ESN"], errorDBNow, out string esn, out error, orderNow, out string md5))
                     {
@@ -2231,7 +2232,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteWiDi.Checked)
+                if (WriteWiDi.Checked && midListNow.keytype.ContainsKey("WiDi"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "WiDi", SN, midListNow.keytype["WiDi"], errorDBNow, out string widi, out error, orderNow, out string md5))
                     {
@@ -2245,7 +2246,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteCiplus.Checked)
+                if (WriteCiplus.Checked && midListNow.keytype.ContainsKey("CI_PLUS_KEY"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "CI_PLUS_KEY", SN, midListNow.keytype["CI_PLUS_KEY"], errorDBNow, out string ci, out error, orderNow, out string md5))
                     {
@@ -2259,7 +2260,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteWidevine.Checked)
+                if (WriteWidevine.Checked && midListNow.keytype.ContainsKey("Widevine_KEY"))
                 {
                     if (CommonMethod.GetWidevineAnAttestationKey(
                         midListNow.host,
@@ -2290,7 +2291,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteMGK.Checked)
+                if (WriteMGK.Checked && midListNow.keytype.ContainsKey("MGK_KEY"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "MGK_KEY", SN, midListNow.keytype["MGK_KEY"], errorDBNow, out string mgk, out error, orderNow, out string md5))
                     {
@@ -2304,7 +2305,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteFairplay.Checked)
+                if (WriteFairplay.Checked && midListNow.keytype.ContainsKey("Fairplay_KEY"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "Fairplay_KEY", SN, midListNow.keytype["Fairplay_KEY"], errorDBNow, out string fairplay, out error, orderNow, out string md5))
                     {
@@ -2318,7 +2319,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteWifiMac.Checked)
+                if (WriteWifiMac.Checked && midListNow.keytype.ContainsKey("MAC"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "MAC", "WiFi_MAC" + SN, midListNow.keytype["MAC"], errorDBNow, out string mac, out error, orderNow, out string md5))
                     {
@@ -2332,7 +2333,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteBTMac.Checked)
+                if (WriteBTMac.Checked && midListNow.keytype.ContainsKey("MAC"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "MAC", "BT_MAC" + SN, midListNow.keytype["MAC"], errorDBNow, out string mac, out error, orderNow, out string md5))
                     {
@@ -2346,7 +2347,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteECP.Checked)
+                if (WriteECP.Checked && midListNow.keytype.ContainsKey("ECP_KEY"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "ECP_KEY", SN, midListNow.keytype["ECP_KEY"], errorDBNow, out string ecp, out error, orderNow, out string md5))
                     {
@@ -2360,7 +2361,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteLEK.Checked)
+                if (WriteLEK.Checked && midListNow.keytype.ContainsKey("LEK"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "LEK", SN, midListNow.keytype["LEK"], errorDBNow, out string lek, out error, orderNow, out string md5))
                     {
@@ -2374,7 +2375,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WritePEK.Checked)
+                if (WritePEK.Checked && midListNow.keytype.ContainsKey("PEK"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "PEK", SN, midListNow.keytype["PEK"], errorDBNow, out string pek, out error, orderNow, out string md5))
                     {
@@ -2388,7 +2389,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WritePlayready.Checked)
+                if (WritePlayready.Checked && midListNow.keytype.ContainsKey("PlayReady_key"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "PlayReady_key", SN, midListNow.keytype["PlayReady_key"], errorDBNow, out string playready, out error, orderNow, out string md5))
                     {
@@ -2402,7 +2403,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteHash.Checked)
+                if (WriteHash.Checked && midListNow.keytype.ContainsKey("Hashkey"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "Hashkey", SN, midListNow.keytype["Hashkey"], errorDBNow, out string hash, out error, orderNow, out string md5))
                     {
@@ -2416,7 +2417,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteYouTube.Checked)
+                if (WriteYouTube.Checked && midListNow.keytype.ContainsKey("YouTube_KEY"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "YouTube_KEY", SN, midListNow.keytype["YouTube_KEY"], errorDBNow, out string youtube, out error, orderNow, out string md5))
                     {
@@ -2430,15 +2431,15 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteEDIDPID.Checked)
+                if (WriteEDIDPID.Checked && midListNow.keytype.ContainsKey("edid_pid"))
                 {
                     keyInfo.EDIDPid.data = midListNow.keytype["edid_pid"];
                 }
-                if (WriteEDIDName.Checked)
+                if (WriteEDIDName.Checked && midListNow.keytype.ContainsKey("edid_model_name"))
                 {
                     keyInfo.EDIDModelName.data = midListNow.keytype["edid_model_name"];
                 }
-                if (WriteACASKey.Checked)
+                if (WriteACASKey.Checked && midListNow.keytype.ContainsKey("ACAS_KEY"))
                 {
                     if (CommonMethod.GetAcasKey(midListNow.host, "ACAS_KEY", SN, midListNow.keytype["ACAS_KEY"], errorDBNow, orderNow, out string acaskey_data, out string acaskey_datamd5, out string acaskey_tool, out string acaskey_toolmd5, out error))
                     {
@@ -2458,7 +2459,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                if (WriteDAK.Checked)
+                if (WriteDAK.Checked && midListNow.keytype.ContainsKey("DAK"))
                 {
                     if (CommonMethod.GetKeys(midListNow.host, "DAK", SN, midListNow.keytype["DAK"], errorDBNow, out string hash, out error, orderNow, out string md5))
                     {
@@ -2494,7 +2495,7 @@ namespace MOKA_Factory_Tools
                     keyInfo.Mac.data = _MiKey.EthernetMac;
                     keyInfo.Mac.enable = true;
                 }
-                else
+                else if ( !midListNow.keytype.ContainsKey("MAC") )
                 {
                     SetCheckboxStatus(WriteMac, false);
                 }
@@ -2505,7 +2506,7 @@ namespace MOKA_Factory_Tools
                     keyInfo.BT_MAC.data = _MiKey.BTMac;
                     keyInfo.BT_MAC.enable = true;
                 }
-                else
+                else if (!midListNow.keytype.ContainsKey("BT_MAC"))
                 {
                     SetCheckboxStatus(WriteBTMac, false);
                 }
@@ -2516,7 +2517,7 @@ namespace MOKA_Factory_Tools
                     keyInfo.DSN.data = _MiKey.DSN;
                     keyInfo.DSN.enable = true;
                 }
-                else
+                else if (!midListNow.keytype.ContainsKey("DSN"))
                 {
                     SetCheckboxStatus(WriteDSN, false);
                 }
@@ -2527,7 +2528,7 @@ namespace MOKA_Factory_Tools
                     keyInfo.WiFi_MAC.data = _MiKey.WIFIMAC;
                     keyInfo.WiFi_MAC.enable = true;
                 }
-                else
+                else if (!midListNow.keytype.ContainsKey("WiFi_MAC"))
                 {
                     SetCheckboxStatus(WriteWifiMac, false);
                 }
@@ -2714,7 +2715,7 @@ namespace MOKA_Factory_Tools
             {
                 string wifimac = keyInfo.WiFi_MAC.data.Replace("-", "");
                 if (FunctionSettingNow.MITVEnable == true)
-                    wifimac = keyInfo.WiFi_MAC.data.Replace(":", "");
+                    wifimac = wifimac.Replace(":", "");
                 if (!CommonMethod.IsNumberAndWord(wifimac))
                 {
                     ErrMsg = string.Format("Wifi Mac format error!\r\n{0}", wifimac);
@@ -2780,7 +2781,7 @@ namespace MOKA_Factory_Tools
             {
                 string btmac = keyInfo.BT_MAC.data.Replace("-", "");
                 if (FunctionSettingNow.MITVEnable == true)
-                    btmac = keyInfo.BT_MAC.data.Replace(":", "");
+                    btmac = btmac.Replace(":", "");
                 if (!CommonMethod.IsNumberAndWord(btmac))
                 {
                     ErrMsg = string.Format("BTMac format error!\r\n{0}", btmac);
@@ -6409,8 +6410,9 @@ namespace MOKA_Factory_Tools
             keyInfo.EDIDPid.enable = WriteEDIDPID.Checked = (WriteEDIDPID.Checked && m_writeEDIDPID.Text != LResource.Skip);
             keyInfo.EDIDModelName.enable = WriteEDIDName.Checked = (WriteEDIDName.Checked && m_writeEDIDName.Text != LResource.Skip);
             keyInfo.ACASKey_Data.enable = WriteACASKey.Checked = (WriteACASKey.Checked && m_writeACASKey.Text != LResource.Skip);
-            keyInfo.DAK.enable = WriteDAK.Checked = (WriteDAK.Checked && WriteDAK.Text != LResource.Skip);
-            keyInfo.FVP.enable = WriteFVP.Checked = (WriteFVP.Checked && WriteFVP.Text != LResource.Skip);
+            keyInfo.DAK.enable = WriteDAK.Checked = (WriteDAK.Checked && m_writeDAK.Text != LResource.Skip);
+            keyInfo.FVP.enable = WriteFVP.Checked = (WriteFVP.Checked && m_writeFVP.Text != LResource.Skip);
+            keyInfo.DSN.enable = WriteDSN.Checked = (WriteDSN.Checked && m_writeDSN.Text != LResource.Skip);
             bool preloadresult = false;
 
             preloadresult = true;