Skip to content

Commit

Permalink
Fix openjdk not detected.
Browse files Browse the repository at this point in the history
Update version.
  • Loading branch information
cdytoby committed Mar 2, 2019
1 parent db79a15 commit 0d35c83
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions APKViewer.WPFApp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@
Angle="0" />
</Image.RenderTransform>
<Image.Triggers>
<EventTrigger
RoutedEvent="Loaded">
<EventTrigger>
<EventTrigger.RoutedEvent>Loaded</EventTrigger.RoutedEvent>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Expand Down
5 changes: 3 additions & 2 deletions APKViewer.WPFApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -38,15 +39,15 @@ private void OpenFileArgProcess()
string[] envArgs = Environment.GetCommandLineArgs();
foreach (string arg in envArgs)
{
Console.WriteLine("MainWindow.OpenFileArgProcess(), Get arg= " + arg);
Debug.WriteLine("MainWindow.OpenFileArgProcess(), Get arg= " + arg);
}
if (envArgs.Length > 1)
bindedViewModel.SetNewFile(new Uri(envArgs[1]));
}

private void FileDrop(object sender, DragEventArgs e)
{
Console.WriteLine("MainWindow.FileDrop(), something dropped.");
Debug.WriteLine("MainWindow.FileDrop(), something dropped.");
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
Expand Down
4 changes: 2 additions & 2 deletions APKViewer.WPFApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.01.0.0")]
[assembly: AssemblyFileVersion("1.01.0.0")]
31 changes: 12 additions & 19 deletions APKViewer.WPFApp/WindowsAPKDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace APKViewer.WPFApp
{
public class WindowsAPKDecoder : IApkDecoder
public class WindowsAPKDecoder: IApkDecoder
{
public static bool javaTested;
public static bool javaExist;
Expand All @@ -40,7 +40,7 @@ public async Task Decode()
//C:\CLIProgram\Android\AndroidSDK\build-tools\27.0.0\aapt.exe
//./aapt d badging "D:\Android\YahooWeatherProvider.apk"

Console.WriteLine("WindowsAPKDecoder.Decode() decode start.");
Debug.WriteLine("WindowsAPKDecoder.Decode() decode start.");
statusReportEvent?.Invoke("WindowsAPKDecoder.Decode() decode start.");
dataModel = new APKDataModel();

Expand All @@ -53,7 +53,7 @@ public async Task Decode()
statusReportEvent?.Invoke("WindowsAPKDecoder.Decode() Decode_Hash start.");
Decode_Hash();

Console.WriteLine("WindowsAPKDecoder.Decode() decode finish.");
Debug.WriteLine("WindowsAPKDecoder.Decode() decode finish.");
statusReportEvent?.Invoke("WindowsAPKDecoder.Decode() decode finish.");
decodeFinishedEvent?.Invoke();
}
Expand All @@ -79,7 +79,7 @@ private async Task Decode_Icon()
using (ZipArchive za = ZipFile.Open(targetFilePath.OriginalString, ZipArchiveMode.Read))
{
ZipArchiveEntry iconEntry = za.GetEntry(dataModel.MaxIconZipEntry);
Console.WriteLine("WindowsAPKDecoder.Decode_Icon() zip entry get." + iconEntry.FullName);
Debug.WriteLine("WindowsAPKDecoder.Decode_Icon() zip entry get. " + iconEntry.FullName);

using (Stream s = iconEntry.Open())
using (MemoryStream ms = new MemoryStream())
Expand All @@ -106,15 +106,8 @@ private async Task Decode_Signature()
Arguments = "/c java -version"
};
processResult = await ExecuteProcess(psiJavaVersion, true);
if (!processResult.StartsWith("java version"))
{
javaTested = true;
javaExist = false;
}
else
{
javaExist = true;
}
javaExist = DesktopCMDAPKSignerUtil.JavaExist(processResult);
javaTested = true;
}

if (!javaExist)
Expand All @@ -123,7 +116,7 @@ private async Task Decode_Signature()
return;
}

ProcessStartInfo psiAPKSigner = new ProcessStartInfo()
ProcessStartInfo psiAPKSigner = new ProcessStartInfo
{
FileName = "java.exe",
Arguments = "-jar " + ExternalToolBinPath.GETAPKSignerPath() +
Expand All @@ -143,7 +136,7 @@ private void Decode_Hash()

private async Task<string> ExecuteProcess(ProcessStartInfo startInfo, bool useError = false)
{
string result = string.Empty;
// string result = string.Empty;

using (Process process = new Process())
{
Expand All @@ -160,7 +153,7 @@ private async Task<string> ExecuteProcess(ProcessStartInfo startInfo, bool useEr
statusReportEvent?.Invoke("WindowsAPKDecoder.ExecuteProcess() setup: \r\n" +
process.StartInfo.FileName + " " + process.StartInfo.Arguments);

Console.WriteLine("WindowsAPKDecoder.ExecuteProcess() setup: \r\n" +
Debug.WriteLine("WindowsAPKDecoder.ExecuteProcess() setup: \r\n" +
process.StartInfo.FileName + " " + process.StartInfo.Arguments);

StringBuilder output = new StringBuilder();
Expand Down Expand Up @@ -204,8 +197,8 @@ private async Task<string> ExecuteProcess(ProcessStartInfo startInfo, bool useEr
await tcs.Task;
await Task.Delay(50);

//Console.WriteLine("WindowsAPKDecoder.ExecuteProcess() Final result=\r\n" + output.ToString());
Console.WriteLine("WindowsAPKDecoder.ExecuteProcess() finish.");
Debug.WriteLine("WindowsAPKDecoder.ExecuteProcess() Final result=\r\n" + output.ToString());
Debug.WriteLine("WindowsAPKDecoder.ExecuteProcess() finish.");

return output.ToString();
}
Expand All @@ -217,4 +210,4 @@ public APKDataModel GetDataModel()
}

}
}
}
5 changes: 5 additions & 0 deletions APKViewer/Utility/DesktopCMDAPKSignerUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public static class DesktopCMDAPKSignerUtil
private const char SPLITTER_MAINKEYVALUE = ':';
private const string SIGNATURE_HEAD = "Verifies";

public static bool JavaExist(string javaVersionResult)
{
return javaVersionResult.Contains("java version") || javaVersionResult.Contains("jdk version");
}

public static void ReadAPKSignature(APKDataModel targetModel, string signResult)
{
StringBuilder finalResult=new StringBuilder();
Expand Down

0 comments on commit 0d35c83

Please sign in to comment.