mirror of
https://github.com/AndnixSH/APKToolGUI.git
synced 2026-05-04 11:02:27 +00:00
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace APKToolGUI.Utils
|
|
{
|
|
internal static class CommonUtils
|
|
{
|
|
public static string GetApplicationNameFromManifest(string decompileFolder)
|
|
{
|
|
string[] Manifest = File.ReadAllLines(Path.Combine(decompileFolder, "AndroidManifest.xml"));
|
|
foreach (string mf in Manifest)
|
|
{
|
|
if (mf.Contains("<application"))
|
|
{
|
|
return StringExt.RegexExtract(@"(?<=android:name=\"")(.*?)(?=\"")", mf);
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public static string GetActivityFromManifest(string decompileFolder)
|
|
{
|
|
string[] Manifest = File.ReadAllLines(Path.Combine(decompileFolder, "AndroidManifest.xml"));
|
|
string packageName = "";
|
|
string mainActivity = "";
|
|
foreach (string mf in Manifest)
|
|
{
|
|
if (String.IsNullOrEmpty(packageName))
|
|
packageName = StringExt.RegexExtract(@"(?<=package=\"")(.*?)(?=\"")", mf);
|
|
|
|
if (mf.Contains("<activity"))
|
|
{
|
|
mainActivity = StringExt.RegexExtract(@"(?<=android:name=\"")(.*?)(?=\"")", mf);
|
|
}
|
|
if (mf.Contains("android.intent.action.MAIN"))
|
|
{
|
|
if (mainActivity.StartsWith("."))
|
|
return packageName + mainActivity;
|
|
}
|
|
}
|
|
return mainActivity;
|
|
}
|
|
|
|
public static bool OnCreateExists(string file)
|
|
{
|
|
if (File.Exists(file))
|
|
{
|
|
string text = File.ReadAllText(file);
|
|
Match MyMatch = Regex.Match(text, ".*(method).*( onCreate).*");
|
|
if (MyMatch.Success)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|