This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
150 changed files
with
28,090 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using AndroidXml; | ||
using System.Data; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Xml; | ||
using SharpCompress.Archives; | ||
|
||
|
||
namespace ApkInfo | ||
{ | ||
public static class PackageReader | ||
{ | ||
|
||
/// <summary> | ||
/// 获取Apk包名 | ||
/// </summary> | ||
/// <param name="stream">文件流</param> | ||
/// <returns></returns> | ||
public static string GetPackageNameFromApk(Stream stream) | ||
{ | ||
using (IArchive zipReader = ArchiveFactory.Open(stream)) | ||
{ | ||
IArchiveEntry adf = zipReader.Entries.FirstOrDefault(w => w.Key == "AndroidManifest.xml"); | ||
|
||
if (adf == null) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
using (MemoryStream memoryStream = new MemoryStream()) | ||
{ | ||
adf.OpenEntryStream().CopyTo(memoryStream); | ||
memoryStream.Seek(0, SeekOrigin.Begin); | ||
AndroidXmlReader reader = new AndroidXmlReader(memoryStream); | ||
while (reader.Read()) | ||
{ | ||
switch (reader.NodeType) | ||
{ | ||
case XmlNodeType.Element: | ||
for (int i = 0; i < reader.AttributeCount; i++) | ||
{ | ||
reader.MoveToAttribute(i); | ||
if (reader.Name != "package")//只读取包名的过滤条件 | ||
{ | ||
continue; | ||
} | ||
return reader.Value; | ||
} | ||
reader.MoveToElement(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
||
return string.Empty; | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
|
||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.