├── .editorconfig
├── .gitignore
├── .gitmodules
├── AAPTForNet
├── AAPTForNet.csproj
├── AAPTool.cs
├── ApkExtractor.cs
├── ApkParser.cs
├── Filters
│ ├── ABIFilter.cs
│ ├── ApplicationFilter.cs
│ ├── BaseFilter.cs
│ ├── PackageFilter.cs
│ ├── PermissionFilter.cs
│ ├── SDKFilter.cs
│ └── SupportScrFilter.cs
├── Models
│ ├── ApkInfo.cs
│ ├── Configs.cs
│ ├── DumpModel.cs
│ ├── Icon.cs
│ └── SDKInfo.cs
├── Properties
│ └── AssemblyInfo.cs
├── ResourceDetector.cs
└── tool
│ └── aapt.exe
├── LICENSE
├── Plugin.cs
├── Properties
└── AssemblyInfo.cs
├── QuickLook.Plugin.ApkViewer.csproj
├── QuickLook.Plugin.ApkViewer.sln
├── QuickLook.Plugin.Metadata.Base.config
├── README.md
├── Scripts
├── pack-zip.ps1
└── update-version.ps1
├── StartupDebuging
├── .gitignore
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── StartupDebuging.csproj
└── apks
│ └── README.md
├── ViewerPane.xaml
├── ViewerPane.xaml.cs
└── images
├── black_btn.png
├── default_icon.png
└── white_btn.png
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Users\AD\Source\Repos\canheo136\QuickLook.Plugin.ApkViewer codebase based on best match to current usage at 16/01/2022
2 | # You can modify the rules from these initially generated values to suit your own policies
3 | # You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
4 | [*.cs]
5 |
6 |
7 | #Core editorconfig formatting - indentation
8 |
9 | #use soft tabs (spaces) for indentation
10 | indent_style = space
11 |
12 | #Formatting - indentation options
13 |
14 | #indent switch case contents.
15 | csharp_indent_case_contents = true
16 | #indent switch labels
17 | csharp_indent_switch_labels = true
18 |
19 | #Formatting - new line options
20 |
21 | #place catch statements on a new line
22 | csharp_new_line_before_catch = true
23 | #place else statements on a new line
24 | csharp_new_line_before_else = true
25 | #require finally statements to be on a new line after the closing brace
26 | csharp_new_line_before_finally = true
27 | #require members of object initializers to be on the same line
28 | csharp_new_line_before_members_in_object_initializers = false
29 |
30 | csharp_new_line_before_open_brace = none
31 | csharp_new_line_between_query_expression_clauses = true
32 | csharp_new_line_before_members_in_anonymous_types = true
33 |
34 | #Formatting - organize using options
35 |
36 | #sort System.* using directives alphabetically, and place them before other usings
37 | dotnet_sort_system_directives_first = true
38 |
39 | #Formatting - spacing options
40 |
41 | #require a space between a cast and the value
42 | csharp_space_after_cast = true
43 | #require a space before the colon for bases or interfaces in a type declaration
44 | csharp_space_after_colon_in_inheritance_clause = true
45 | #require a space after a keyword in a control flow statement such as a for loop
46 | csharp_space_after_keywords_in_control_flow_statements = true
47 | #require a space before the colon for bases or interfaces in a type declaration
48 | csharp_space_before_colon_in_inheritance_clause = true
49 | #remove space within empty argument list parentheses
50 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
51 | #remove space between method call name and opening parenthesis
52 | csharp_space_between_method_call_name_and_opening_parenthesis = false
53 | #do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
54 | csharp_space_between_method_call_parameter_list_parentheses = false
55 | #remove space within empty parameter list parentheses for a method declaration
56 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
57 | #place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
58 | csharp_space_between_method_declaration_parameter_list_parentheses = false
59 |
60 | #Formatting - wrapping options
61 |
62 | #leave code block on single line
63 | csharp_preserve_single_line_blocks = true
64 | #leave statements and member declarations on the same line
65 | csharp_preserve_single_line_statements = true
66 |
67 | #Style - Code block preferences
68 |
69 | #prefer no curly braces if allowed
70 | csharp_prefer_braces = false:suggestion
71 |
72 | #Style - expression bodied member options
73 |
74 | #prefer expression-bodied members for accessors
75 | csharp_style_expression_bodied_accessors = true:suggestion
76 | #prefer expression-bodied members for constructors
77 | csharp_style_expression_bodied_constructors = true:suggestion
78 | #prefer block bodies for methods
79 | csharp_style_expression_bodied_methods = false:suggestion
80 | #prefer expression-bodied members for properties
81 | csharp_style_expression_bodied_properties = true:suggestion
82 |
83 | #Style - expression level options
84 |
85 | #prefer out variables to be declared inline in the argument list of a method call when possible
86 | csharp_style_inlined_variable_declaration = true:suggestion
87 | #prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
88 | dotnet_style_predefined_type_for_member_access = true:suggestion
89 |
90 | #Style - Expression-level preferences
91 |
92 | #prefer default over default(T)
93 | csharp_prefer_simple_default_expression = true:suggestion
94 | #prefer objects to be initialized using object initializers when possible
95 | dotnet_style_object_initializer = true:suggestion
96 |
97 | #Style - implicit and explicit types
98 |
99 | #prefer var over explicit type in all cases, unless overridden by another code style rule
100 | csharp_style_var_elsewhere = true:suggestion
101 | #prefer var is used to declare variables with built-in system types such as int
102 | csharp_style_var_for_built_in_types = true:suggestion
103 | #prefer var when the type is already mentioned on the right-hand side of a declaration expression
104 | csharp_style_var_when_type_is_apparent = true:suggestion
105 |
106 | #Style - language keyword and framework type options
107 |
108 | #prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
109 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
110 |
111 | #Style - Miscellaneous preferences
112 |
113 | #prefer anonymous functions over local functions
114 | csharp_style_pattern_local_over_anonymous_function = false:suggestion
115 |
116 | #Style - modifier options
117 |
118 | #prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
119 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
120 |
121 | #Style - Modifier preferences
122 |
123 | #when this rule is set to a list of modifiers, prefer the specified ordering.
124 | csharp_preferred_modifier_order = public,private,internal,protected,static,extern,readonly,override,new:suggestion
125 |
126 | #Style - Pattern matching
127 |
128 | #prefer pattern matching instead of is expression with type casts
129 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
130 |
131 | #Style - qualification options
132 |
133 | #prefer events not to be prefaced with this. or Me. in Visual Basic
134 | dotnet_style_qualification_for_event = false:suggestion
135 | #prefer fields not to be prefaced with this. or Me. in Visual Basic
136 | dotnet_style_qualification_for_field = false:suggestion
137 | #prefer methods not to be prefaced with this. or Me. in Visual Basic
138 | dotnet_style_qualification_for_method = false:suggestion
139 | #prefer properties not to be prefaced with this. or Me. in Visual Basic
140 | dotnet_style_qualification_for_property = false:suggestion
141 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /[Bb]uild
2 | /Scripts
3 | /QuickLook.Common
4 | *.qlplugin
5 | GitVersion.cs
6 | QuickLook.Plugin.Metadata.config
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.userosscache
15 | *.sln.docstates
16 |
17 | # User-specific files (MonoDevelop/Xamarin Studio)
18 | *.userprefs
19 |
20 | # Build results
21 | [Dd]ebug/
22 | [Dd]ebugPublic/
23 | [Rr]elease/
24 | [Rr]eleases/
25 | x64/
26 | x86/
27 | bld/
28 | [Bb]in/
29 | [Oo]bj/
30 | [Ll]og/
31 |
32 | # Visual Studio 2015 cache/options directory
33 | .vs/
34 | # Uncomment if you have tasks that create the project's static files in wwwroot
35 | #wwwroot/
36 |
37 | # MSTest test Results
38 | [Tt]est[Rr]esult*/
39 | [Bb]uild[Ll]og.*
40 |
41 | # NUNIT
42 | *.VisualState.xml
43 | TestResult.xml
44 |
45 | # Build Results of an ATL Project
46 | [Dd]ebugPS/
47 | [Rr]eleasePS/
48 | dlldata.c
49 |
50 | # DNX
51 | project.lock.json
52 | project.fragment.lock.json
53 | artifacts/
54 |
55 | *_i.c
56 | *_p.c
57 | *_i.h
58 | *.ilk
59 | *.meta
60 | *.obj
61 | *.pch
62 | *.pdb
63 | *.pgc
64 | *.pgd
65 | *.rsp
66 | *.sbr
67 | *.tlb
68 | *.tli
69 | *.tlh
70 | *.tmp
71 | *.tmp_proj
72 | *.log
73 | *.vspscc
74 | *.vssscc
75 | .builds
76 | *.pidb
77 | *.svclog
78 | *.scc
79 |
80 | # Chutzpah Test files
81 | _Chutzpah*
82 |
83 | # Visual C++ cache files
84 | ipch/
85 | *.aps
86 | *.ncb
87 | *.opendb
88 | *.opensdf
89 | *.sdf
90 | *.cachefile
91 | *.VC.db
92 | *.VC.VC.opendb
93 |
94 | # Visual Studio profiler
95 | *.psess
96 | *.vsp
97 | *.vspx
98 | *.sap
99 |
100 | # TFS 2012 Local Workspace
101 | $tf/
102 |
103 | # Guidance Automation Toolkit
104 | *.gpState
105 |
106 | # ReSharper is a .NET coding add-in
107 | _ReSharper*/
108 | *.[Rr]e[Ss]harper
109 | *.DotSettings.user
110 |
111 | # JustCode is a .NET coding add-in
112 | .JustCode
113 |
114 | # TeamCity is a build add-in
115 | _TeamCity*
116 |
117 | # DotCover is a Code Coverage Tool
118 | *.dotCover
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | #*.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignoreable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | node_modules/
203 | orleans.codegen.cs
204 |
205 | # Since there are multiple workflows, uncomment next line to ignore bower_components
206 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
207 | #bower_components/
208 |
209 | # RIA/Silverlight projects
210 | Generated_Code/
211 |
212 | # Backup & report files from converting an old project file
213 | # to a newer Visual Studio version. Backup files are not needed,
214 | # because we have git ;-)
215 | _UpgradeReport_Files/
216 | Backup*/
217 | UpgradeLog*.XML
218 | UpgradeLog*.htm
219 |
220 | # SQL Server files
221 | *.mdf
222 | *.ldf
223 |
224 | # Business Intelligence projects
225 | *.rdl.data
226 | *.bim.layout
227 | *.bim_*.settings
228 |
229 | # Microsoft Fakes
230 | FakesAssemblies/
231 |
232 | # GhostDoc plugin setting file
233 | *.GhostDoc.xml
234 |
235 | # Node.js Tools for Visual Studio
236 | .ntvs_analysis.dat
237 |
238 | # Visual Studio 6 build log
239 | *.plg
240 |
241 | # Visual Studio 6 workspace options file
242 | *.opt
243 |
244 | # Visual Studio LightSwitch build output
245 | **/*.HTMLClient/GeneratedArtifacts
246 | **/*.DesktopClient/GeneratedArtifacts
247 | **/*.DesktopClient/ModelManifest.xml
248 | **/*.Server/GeneratedArtifacts
249 | **/*.Server/ModelManifest.xml
250 | _Pvt_Extensions
251 |
252 | # Paket dependency manager
253 | .paket/paket.exe
254 | paket-files/
255 |
256 | # FAKE - F# Make
257 | .fake/
258 |
259 | # JetBrains Rider
260 | .idea/
261 | *.sln.iml
262 |
263 | # CodeRush
264 | .cr/
265 |
266 | # Python Tools for Visual Studio (PTVS)
267 | __pycache__/
268 | *.pyc
269 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "QuickLook.Common"]
2 | path = QuickLook.Common
3 | url = https://github.com/canheo136/QuickLook.Common
4 |
--------------------------------------------------------------------------------
/AAPTForNet/AAPTForNet.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {22AA131D-DBA0-445C-B790-FDFD951A1655}
8 | Library
9 | Properties
10 | AAPTForNet
11 | AAPTForNet
12 | v4.6.2
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | ..\build\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | Component
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | Always
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/AAPTForNet/AAPTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using AAPTForNet.Models;
5 |
6 | namespace AAPTForNet {
7 | ///
8 | /// Android Assert Packing Tool for NET
9 | ///
10 | public class AAPTool : System.Diagnostics.Process {
11 | private enum DumpTypes {
12 | Manifest = 0,
13 | Resources = 1,
14 | XmlTree = 2,
15 | }
16 |
17 | private static readonly string AppPath = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);
18 |
19 | protected AAPTool() {
20 | StartInfo.FileName = AppPath + @"\tool\aapt.exe";
21 | StartInfo.CreateNoWindow = true;
22 | StartInfo.UseShellExecute = false; // For read output data
23 | StartInfo.RedirectStandardError = true;
24 | StartInfo.RedirectStandardOutput = true;
25 | StartInfo.StandardOutputEncoding = System.Text.Encoding.GetEncoding("utf-8");
26 | }
27 |
28 | protected new bool Start(string args) {
29 | StartInfo.Arguments = args;
30 | return base.Start();
31 | }
32 |
33 | private static DumpModel Dump(
34 | string path,
35 | string args,
36 | DumpTypes type,
37 | Func callback) {
38 |
39 | int index = 0;
40 | var terminated = false;
41 | var msg = string.Empty;
42 | var aapt = new AAPTool();
43 | var output = new List(); // Messages from output stream
44 |
45 | switch (type) {
46 | case DumpTypes.Manifest:
47 | aapt.Start($"dump badging \"{path}\"");
48 | break;
49 | case DumpTypes.Resources:
50 | aapt.Start($"dump --values resources \"{path}\"");
51 | break;
52 | case DumpTypes.XmlTree:
53 | aapt.Start($"dump xmltree \"{path}\" {args}");
54 | break;
55 | default:
56 | return new DumpModel(path, false, output);
57 | }
58 |
59 | while (!aapt.StandardOutput.EndOfStream && !terminated) {
60 | msg = aapt.StandardOutput.ReadLine();
61 |
62 | if (callback(msg, index)) {
63 | terminated = true;
64 | try {
65 | aapt.Kill();
66 | }
67 | catch { }
68 | }
69 | if (!terminated)
70 | index++;
71 | output.Add(msg);
72 | }
73 |
74 | while (!aapt.StandardError.EndOfStream) {
75 | output.Add(aapt.StandardError.ReadLine());
76 | }
77 |
78 | try {
79 | aapt.WaitForExit();
80 | aapt.Close();
81 | }
82 | catch { }
83 |
84 | // Dump xml tree get only 1 message when failed, the others are 2.
85 | bool isSuccess = type != DumpTypes.XmlTree ?
86 | output.Count > 2 : output.Count > 0;
87 | return new DumpModel(path, isSuccess, output);
88 | }
89 |
90 | internal static DumpModel DumpManifest(string path) {
91 | return Dump(path, string.Empty, DumpTypes.Manifest, (msg, i) => false);
92 | }
93 |
94 | internal static DumpModel DumpResources(string path, Func callback) {
95 | return Dump(path, string.Empty, DumpTypes.Resources, callback);
96 | }
97 |
98 | internal static DumpModel DumpXmlTree(string path, string asset, Func callback = null) {
99 | callback = callback ?? ((_, __) => false);
100 | return Dump(path, asset, DumpTypes.XmlTree, callback);
101 | }
102 |
103 | internal static DumpModel DumpManifestTree(string path, Func callback = null) {
104 | return DumpXmlTree(path, "AndroidManifest.xml", callback);
105 | }
106 |
107 | ///
108 | /// Start point. Begin decompile apk to extract resources
109 | ///
110 | /// Absolute path to .apk file
111 | /// Filled apk if dump process is not failed
112 | public static ApkInfo Decompile(string path) {
113 | var manifest = ApkExtractor.ExtractManifest(path);
114 | if (!manifest.IsSuccess)
115 | return new ApkInfo();
116 |
117 | var apk = ApkParser.Parse(manifest);
118 | apk.FullPath = path;
119 |
120 | if (apk.Icon.IsImage) {
121 | // Included icon in manifest, extract it from apk
122 | apk.Icon.RealPath = ApkExtractor.ExtractIconImage(path, apk.Icon);
123 | if (apk.Icon.IsHighDensity)
124 | return apk;
125 | }
126 |
127 | apk.Icon = ApkExtractor.ExtractLargestIcon(path);
128 | return apk;
129 | }
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/AAPTForNet/ApkExtractor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.IO.Compression;
5 | using System.Linq;
6 | using AAPTForNet.Models;
7 | using Detector = AAPTForNet.ResourceDetector;
8 |
9 | namespace AAPTForNet {
10 | internal class ApkExtractor {
11 |
12 | public static DumpModel ExtractManifest(string path) {
13 | return AAPTool.DumpManifest(path);
14 | }
15 |
16 | ///
17 | /// Find the icon with maximum config (largest), then extract to file
18 | ///
19 | ///
20 | public static Icon ExtractLargestIcon(string path) {
21 | var iconTable = ExtractIconTable(path);
22 |
23 | if (iconTable.Count == 0)
24 | return Icon.Default;
25 |
26 | if (iconTable.Values.All(i => i.IsRefernce)) {
27 | var refID = iconTable.Values.FirstOrDefault().IconName;
28 | iconTable = ExtractIconTable(path, refID);
29 | }
30 |
31 | if (iconTable.Values.All(i => i.IsMarkup)) {
32 | // Try dumping markup asset and get icon
33 | var asset = iconTable.Values.FirstOrDefault().IconName;
34 | iconTable = DumpMarkupIcon(path, asset);
35 | }
36 |
37 | var largestIcon = ExtractLargestIcon(iconTable);
38 | largestIcon.RealPath = ExtractIconImage(path, largestIcon);
39 |
40 | return largestIcon;
41 | }
42 |
43 | private static Dictionary DumpMarkupIcon(string path, string asset, int startIndex = -1) {
44 | var output = DumpMarkupIcon(path, asset, out startIndex);
45 |
46 | return output.Count == 0 && startIndex < 5
47 | ? DumpMarkupIcon(path, asset, startIndex + 1)
48 | : output;
49 | }
50 |
51 | private static Dictionary DumpMarkupIcon(
52 | string path, string asset, out int lastTryIndex, int start = -1) {
53 | // Not found any icon image in package?,
54 | // it maybe a markup file
55 | // try getting some images from markup.
56 | lastTryIndex = -1;
57 |
58 | var tree = AAPTool.DumpXmlTree(path, asset);
59 | if (!tree.IsSuccess)
60 | return new Dictionary();
61 |
62 | var msg = string.Empty;
63 | start = start >= 0 && start < tree.Messages.Count ? start : 0;
64 | for (int i = start; i < tree.Messages.Count; i++) {
65 | lastTryIndex = i;
66 | msg = tree.Messages[i];
67 |
68 | if (Detector.IsBitmapElement(msg)) {
69 | var iconID = tree.Messages[i + 1].Split('@')[1];
70 | return ExtractIconTable(path, iconID);
71 | }
72 | }
73 |
74 | return new Dictionary();
75 | }
76 |
77 | private static Dictionary ExtractIconTable(string path) {
78 | var iconID = ExtractIconID(path);
79 | return ExtractIconTable(path, iconID);
80 | }
81 |
82 | ///
83 | /// Extract resource id of launch icon from manifest tree
84 | ///
85 | ///
86 | /// icon id
87 | private static string ExtractIconID(string path) {
88 | int iconIndex = 0;
89 | var manifestTree = AAPTool.DumpManifestTree(
90 | path,
91 | (m, i) => {
92 | if (m.Contains("android:icon")) {
93 | iconIndex = i;
94 | return true;
95 | }
96 | return false;
97 | }
98 | );
99 |
100 | if (iconIndex == 0) // Package without launcher icon
101 | return string.Empty;
102 |
103 | if (manifestTree.IsSuccess) {
104 | string msg = manifestTree.Messages[iconIndex];
105 | return msg.Split('@')[1];
106 | }
107 |
108 | return string.Empty;
109 | }
110 |
111 | private static Dictionary ExtractIconTable(string path, string iconID) {
112 | if (string.IsNullOrEmpty(iconID))
113 | return new Dictionary();
114 |
115 | var matchedEntry = false;
116 | var indexes = new List(); // Get position of icon in resource list
117 | var resTable = AAPTool.DumpResources(path, (m, i) => {
118 | // Dump resources and get icons,
119 | // terminate when meet the end of mipmap entry,
120 | // icons are in 'drawable' or 'mipmap' resource
121 | if (Detector.IsResource(m, iconID))
122 | indexes.Add(i);
123 |
124 | if (!matchedEntry) {
125 | if (m.Contains("mipmap/"))
126 | matchedEntry = true; // Begin mipmap entry
127 | }
128 | else {
129 | if (Detector.IsEntryType(m)) { // Next entry, terminate
130 | matchedEntry = false;
131 | return true;
132 | }
133 | }
134 | return false;
135 | });
136 |
137 | return CreateIconTable(indexes, resTable.Messages);
138 | }
139 |
140 | // Create table like below
141 | // configs | mdpi hdpi ... anydpi
142 | // icon | icon1 icon2 ... icon4
143 | private static Dictionary CreateIconTable(List positions, List messages) {
144 | if (positions.Count == 0 || messages.Count <= 2) // If dump failed
145 | return new Dictionary();
146 |
147 | const char seperator = '\"';
148 | // Prevent duplicate key when add to Dictionary,
149 | // because comparison statement with 'hdpi' in config's values,
150 | // reverse list and get first elem with LINQ
151 | var configNames = Enum.GetNames(typeof(Configs)).Reverse();
152 | var iconTable = new Dictionary();
153 | Action addIcon2Table = (cfg, iconName) => {
154 | if (!iconTable.ContainsKey(cfg)) {
155 | iconTable.Add(cfg, new Icon(iconName));
156 | }
157 | };
158 | string msg, resValue, config;
159 |
160 | foreach (int index in positions) {
161 | for (int i = index; ; i--) {
162 | // Go prev to find config
163 | msg = messages[i];
164 |
165 | if (Detector.IsEntryType(msg)) // Out of entry and not found
166 | break;
167 | if (Detector.IsConfig(msg)) {
168 | // Match with predefined configs,
169 | // go next to get icon name
170 | resValue = messages[index + 1];
171 |
172 | config = configNames.FirstOrDefault(c => msg.Contains(c));
173 |
174 | if (Detector.IsResourceValue(resValue)) {
175 | // Resource value is icon url
176 | var iconName = resValue.Split(seperator)
177 | .FirstOrDefault(n => n.Contains("/"));
178 | addIcon2Table(config, iconName);
179 | break;
180 | }
181 | if (Detector.IsReference(resValue)) {
182 | var iconID = resValue.Trim().Split(' ')[1];
183 | addIcon2Table(config, iconID);
184 | break;
185 | }
186 |
187 | break;
188 | }
189 | }
190 | }
191 | return iconTable;
192 | }
193 |
194 | ///
195 | /// Extract icon image from apk file
196 | ///
197 | /// path to apk file
198 | ///
199 | /// Absolute path to extracted image
200 | public static string ExtractIconImage(string path, Icon icon) {
201 | if (Icon.Default.Equals(icon))
202 | return Icon.DefaultName;
203 |
204 | string tempPath = Path.Combine(Path.GetTempPath(), "AAPToolTempImage.png");
205 | TryExtractIconImage(path, icon.IconName, tempPath);
206 | return tempPath;
207 | }
208 |
209 | private static void TryExtractIconImage(string path, string iconName, string desFile) {
210 | try {
211 | ExtractIconImage(path, iconName, desFile);
212 | }
213 | catch (ArgumentException) { }
214 | }
215 |
216 | ///
217 | /// Extract icon with name @iconName from @path to @desFile
218 | ///
219 | ///
220 | ///
221 | ///
222 | private static void ExtractIconImage(string path, string iconName, string desFile) {
223 | if (iconName.EndsWith(".xml") || !File.Exists(path))
224 | throw new ArgumentException("Invalid params");
225 |
226 | using (var archive = ZipFile.OpenRead(path)) {
227 | ZipArchiveEntry entry;
228 |
229 | for (int i = archive.Entries.Count - 1; i > 0; i--) {
230 | entry = archive.Entries[i];
231 |
232 | if (entry.Name.Equals(iconName) ||
233 | entry.FullName.Equals(iconName)) {
234 |
235 | entry.ExtractToFile(desFile, true);
236 | break;
237 | }
238 | }
239 | }
240 | }
241 |
242 | private static Icon ExtractLargestIcon(Dictionary iconTable) {
243 | if (iconTable.Count == 0)
244 | return Icon.Default;
245 |
246 | var icon = Icon.Default;
247 | var configNames = Enum.GetNames(typeof(Configs)).ToList();
248 | configNames.Sort(new ConfigComparer());
249 |
250 | foreach (string cfg in configNames) {
251 | // Get the largest icon image, skip markup file (xml)
252 | if (iconTable.TryGetValue(cfg, out icon)) {
253 | if (icon.IconName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
254 | continue;
255 | break; // Largest icon here :)
256 | }
257 | }
258 |
259 | return icon ?? Icon.Default;
260 | }
261 |
262 | ///
263 | /// DPI config comparer, ordered by desc (largest first)
264 | ///
265 | private class ConfigComparer : IComparer {
266 | public int Compare(string x, string y) {
267 | Enum.TryParse(x, out Configs ex);
268 | Enum.TryParse(y, out Configs ey);
269 | return ex > ey ? -1 : 1;
270 | }
271 | }
272 | }
273 | }
274 |
--------------------------------------------------------------------------------
/AAPTForNet/ApkParser.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using AAPTForNet.Filters;
4 | using AAPTForNet.Models;
5 |
6 | namespace AAPTForNet {
7 | ///
8 | /// Parse output messages from AAPTool
9 | ///
10 | internal class ApkParser {
11 | public static ApkInfo Parse(DumpModel model) {
12 | if (!model.IsSuccess)
13 | return new ApkInfo();
14 |
15 | var filters = new List() {
16 | new ABIFilter(),
17 | new SDKFilter(),
18 | new PackageFilter(),
19 | new PermissionFilter(),
20 | new SupportScrFilter(),
21 | new ApplicationFilter()
22 | };
23 |
24 | foreach (string msg in model.Messages) {
25 | foreach (var f in filters) {
26 | if (f.CanHandle(msg)) {
27 | f.AddMessage(msg);
28 | break;
29 | }
30 | }
31 | }
32 |
33 | return ApkInfo.Merge(filters.Select(f => f.GetAPK()));
34 | }
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/AAPTForNet/Filters/ABIFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using AAPTForNet.Models;
4 |
5 | namespace AAPTForNet.Filters {
6 | ///
7 | /// Application Binary Interface Filter
8 | ///
9 | /// https://developer.android.com/ndk/guides/abis
10 | internal class ABIFilter : BaseFilter {
11 |
12 | private string[] segments = new string[] { };
13 |
14 | public override bool CanHandle(string msg)
15 | => msg.StartsWith("native-code:");
16 |
17 | public override void AddMessage(string msg) {
18 | segments = msg.Split(new char[2] { ' ', '\'' }, StringSplitOptions.RemoveEmptyEntries);
19 | }
20 |
21 | public override ApkInfo GetAPK() {
22 | return new ApkInfo() {
23 | SupportedABIs = segments.Skip(1).ToList() // Skip "native-code"
24 | };
25 | }
26 |
27 | public override void Clear() => throw new NotImplementedException();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AAPTForNet/Filters/ApplicationFilter.cs:
--------------------------------------------------------------------------------
1 | using AAPTForNet.Models;
2 |
3 | namespace AAPTForNet.Filters {
4 | internal class ApplicationFilter : BaseFilter {
5 |
6 | private string[] segments = new string[] { };
7 |
8 | public override bool CanHandle(string msg) {
9 | return msg.StartsWith("application:");
10 | }
11 |
12 | public override void AddMessage(string msg = "") {
13 | segments = msg.Split(seperator);
14 | }
15 |
16 | public override ApkInfo GetAPK() {
17 | // Try getting icon name from manifest, may be an image
18 | string iconName = GetValue("icon=");
19 |
20 | return new ApkInfo() {
21 | AppName = GetValue("label="),
22 | Icon = iconName == defaultEmptyValue ?
23 | Icon.Default : new Icon(iconName)
24 | };
25 | }
26 |
27 | public override void Clear() {
28 | segments = new string[] { };
29 | }
30 |
31 | private string GetValue(string key) {
32 | string output = string.Empty;
33 | for (int i = 0; i < segments.Length; i++) {
34 | if (segments[i].Contains(key)) {
35 | output = segments[++i];
36 | break;
37 | }
38 | }
39 | return string.IsNullOrEmpty(output) ? defaultEmptyValue : output;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/AAPTForNet/Filters/BaseFilter.cs:
--------------------------------------------------------------------------------
1 | using AAPTForNet.Models;
2 |
3 | namespace AAPTForNet.Filters {
4 | internal abstract class BaseFilter {
5 | protected const char seperator = '\'';
6 | protected const string defaultEmptyValue = "Unknown";
7 |
8 | public abstract bool CanHandle(string msg);
9 | public abstract void AddMessage(string msg);
10 | public abstract ApkInfo GetAPK();
11 | ///
12 | /// Test in loop
13 | ///
14 | public abstract void Clear();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/AAPTForNet/Filters/PackageFilter.cs:
--------------------------------------------------------------------------------
1 | using AAPTForNet.Models;
2 |
3 | namespace AAPTForNet.Filters {
4 | internal class PackageFilter : BaseFilter {
5 |
6 | private string[] segments = new string[] { };
7 |
8 | public override bool CanHandle(string msg) {
9 | return msg.StartsWith("package:");
10 | }
11 |
12 | public override void AddMessage(string msg) {
13 | segments = msg.Split(seperator);
14 | }
15 |
16 | public override ApkInfo GetAPK() {
17 | return new ApkInfo() {
18 | PackageName = getValueOrDefault("package"),
19 | VersionName = getValueOrDefault("versionName"),
20 | VersionCode = getValueOrDefault("versionCode"),
21 | };
22 | }
23 |
24 | public override void Clear() => segments = new string[] { };
25 |
26 | private string getValueOrDefault(string key) {
27 | string output = string.Empty;
28 | for (int i = 0; i < segments.Length; i++) {
29 | if (segments[i].Contains(key)) { // Find key
30 | output = segments[++i]; // Get value
31 | break;
32 | }
33 | }
34 | return string.IsNullOrEmpty(output) ? defaultEmptyValue : output;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/AAPTForNet/Filters/PermissionFilter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using AAPTForNet.Models;
3 |
4 | namespace AAPTForNet.Filters {
5 | internal class PermissionFilter : BaseFilter {
6 | private List permissions = new List();
7 |
8 | public override bool CanHandle(string msg) {
9 | return msg.StartsWith("uses-permission:");
10 | }
11 |
12 | public override void AddMessage(string msg) {
13 | // uses-permission: name=''
14 | // -> ["uses-permission: name=", "", ""]
15 | permissions.Add(msg.Split(seperator)[1]);
16 | }
17 |
18 | public override ApkInfo GetAPK() {
19 | return new ApkInfo() {
20 | Permissions = permissions
21 | };
22 | }
23 |
24 | public override void Clear() {
25 | permissions.Clear();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/AAPTForNet/Filters/SDKFilter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using AAPTForNet.Models;
3 |
4 | namespace AAPTForNet.Filters {
5 | internal class SDKFilter : BaseFilter {
6 |
7 | private List msgs = new List();
8 | private string[] segments => string.Join(" ", msgs).Split(seperator);
9 |
10 | public override bool CanHandle(string msg) {
11 | return msg.StartsWith("sdkVersion:") || msg.StartsWith("targetSdkVersion:");
12 | }
13 |
14 | public override void AddMessage(string msg) {
15 | if (!msgs.Contains(msg)) {
16 | msgs.Add(msg);
17 | }
18 | }
19 |
20 | public override ApkInfo GetAPK() {
21 | return new ApkInfo() {
22 | MinSDK = SDKInfo.GetInfo(GetMinSDKVersion()),
23 | TargetSDK = SDKInfo.GetInfo(GetTargetSDKVersion())
24 | };
25 | }
26 |
27 | public override void Clear() {
28 | msgs.Clear();
29 | }
30 |
31 | private string GetMinSDKVersion() {
32 | for (int i = 0; i < segments.Length; i++) {
33 | if (segments[i].Contains("sdkVersion"))
34 | return segments[++i];
35 | }
36 | return string.Empty;
37 | }
38 |
39 | private string GetTargetSDKVersion() {
40 | for (var i = 0; i < segments.Length; i++) {
41 | if (segments[i].Contains("targetSdkVersion"))
42 | return segments[++i];
43 | }
44 | return string.Empty;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AAPTForNet/Filters/SupportScrFilter.cs:
--------------------------------------------------------------------------------
1 | using AAPTForNet.Models;
2 |
3 | namespace AAPTForNet.Filters {
4 | internal class SupportScrFilter : BaseFilter {
5 |
6 | public const string SmallScreen = "small";
7 | public const string NormalScreen = "normal";
8 | public const string LargeScreen = "large";
9 | public const string xLargeScreen = "xlarge";
10 |
11 | private string msg = string.Empty;
12 |
13 | public override bool CanHandle(string msg) {
14 | return msg.StartsWith("supports-screens:");
15 | }
16 |
17 | public override void AddMessage(string msg) {
18 | this.msg = msg;
19 | }
20 |
21 | public override ApkInfo GetAPK() {
22 | var apk = new ApkInfo();
23 |
24 | if (msg.Contains(SmallScreen))
25 | apk.SupportScreens.Add(SmallScreen);
26 | if (msg.Contains(NormalScreen))
27 | apk.SupportScreens.Add(NormalScreen);
28 | if (msg.Contains(LargeScreen))
29 | apk.SupportScreens.Add(LargeScreen);
30 | if (msg.Contains(xLargeScreen))
31 | apk.SupportScreens.Add(xLargeScreen);
32 |
33 | return apk;
34 | }
35 |
36 | public override void Clear() {
37 | msg = string.Empty;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/AAPTForNet/Models/ApkInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 |
6 | namespace AAPTForNet.Models {
7 | public class ApkInfo {
8 | public string AppName { get; set; }
9 | public string PackageName { get; set; }
10 | public string VersionName { get; set; }
11 | public string VersionCode { get; set; }
12 | ///
13 | /// Absolute path to apk file
14 | ///
15 | public string FullPath { get; set; }
16 | public Icon Icon { get; set; }
17 | public SDKInfo MinSDK { get; set; }
18 | public SDKInfo TargetSDK { get; set; }
19 | public List Permissions { get; set; }
20 | ///
21 | /// Supported application binary interfaces
22 | ///
23 | public List SupportedABIs { get; set; }
24 | public List SupportScreens { get; set; }
25 | ///
26 | /// Size of package, in bytes
27 | ///
28 | public long PackageSize {
29 | get {
30 | try {
31 | return new FileInfo(FullPath).Length;
32 | }
33 | catch {
34 | return 0;
35 | }
36 | }
37 | }
38 | ///
39 | /// Determines whether this package is filled or not
40 | ///
41 | public bool IsEmpty => AppName == string.Empty && PackageName == string.Empty;
42 |
43 | internal ApkInfo() {
44 | AppName = string.Empty;
45 | PackageName = string.Empty;
46 | VersionName = string.Empty;
47 | VersionCode = string.Empty;
48 | FullPath = string.Empty;
49 | Icon = Icon.Default;
50 | MinSDK = SDKInfo.Unknown;
51 | TargetSDK = SDKInfo.Unknown;
52 | Permissions = new List();
53 | SupportedABIs = new List();
54 | SupportScreens = new List();
55 | }
56 |
57 | internal ApkInfo Megre(params ApkInfo[] apks) {
58 | if (apks.Any(a => a == null))
59 | throw new ArgumentNullException();
60 |
61 | return ApkInfo.Merge(this, apks);
62 | }
63 |
64 | internal static ApkInfo Merge(IEnumerable apks) {
65 | return ApkInfo.Merge(null, apks);
66 | }
67 |
68 | internal static ApkInfo Merge(ApkInfo init, IEnumerable apks) {
69 | if (init == null)
70 | init = new ApkInfo();
71 |
72 | var appApk = apks.FirstOrDefault(a => a.AppName.Length > 0);
73 | if (appApk != null)
74 | init.AppName = appApk.AppName;
75 |
76 | var pckApk = apks.FirstOrDefault(a => a.PackageName.Length > 0);
77 | if (pckApk != null) {
78 | init.VersionName = pckApk.VersionName;
79 | init.VersionCode = pckApk.VersionCode;
80 | init.PackageName = pckApk.PackageName;
81 | }
82 |
83 | var sdkApk = apks.FirstOrDefault(a => !SDKInfo.Unknown.Equals(a.MinSDK));
84 | if (sdkApk != null) {
85 | init.MinSDK = sdkApk.MinSDK;
86 | init.TargetSDK = sdkApk.TargetSDK;
87 | }
88 |
89 | var perApk = apks.FirstOrDefault(a => a.Permissions.Count > 0);
90 | if (perApk != null)
91 | init.Permissions = perApk.Permissions;
92 |
93 | var abiApk = apks.FirstOrDefault(a => a.SupportedABIs.Count > 0);
94 | if (abiApk != null)
95 | init.SupportedABIs = abiApk.SupportedABIs;
96 |
97 | var scrApk = apks.FirstOrDefault(a => a.SupportScreens.Count > 0);
98 | if (scrApk != null)
99 | init.SupportScreens = scrApk.SupportScreens;
100 |
101 | var iconApk = apks.FirstOrDefault(a => !Icon.Default.Equals(a.Icon));
102 | if (iconApk != null)
103 | init.Icon = iconApk.Icon;
104 |
105 | var pathApk = apks.FirstOrDefault(a => a.FullPath.Length > 0);
106 | if (pathApk != null)
107 | init.FullPath = pathApk.FullPath;
108 |
109 | return init;
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/AAPTForNet/Models/Configs.cs:
--------------------------------------------------------------------------------
1 | namespace AAPTForNet.Models {
2 | internal enum Configs {
3 | anydpi = 0,
4 | mdpi = 1,
5 | @default = 2,
6 | hdpi = 4,
7 | xhdpi = 8,
8 | xxhdpi = 16,
9 | xxxhdpi = 32,
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/AAPTForNet/Models/DumpModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AAPTForNet.Models {
4 | internal class DumpModel {
5 | public string FilePath { get; }
6 | public bool IsSuccess { get; }
7 | public List Messages { get; }
8 |
9 | internal DumpModel(string path, bool success, List msg) {
10 | FilePath = path;
11 | IsSuccess = success;
12 | Messages = msg;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/AAPTForNet/Models/Icon.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.IO;
5 |
6 | namespace AAPTForNet.Models {
7 | public class Icon {
8 |
9 | private const int hdpiWidth = 72;
10 | public const string DefaultName = "ic_launcher.png";
11 |
12 | internal static readonly Icon Default = new Icon(DefaultName);
13 |
14 | ///
15 | /// Return absolute path to package icon if @isImage is true,
16 | /// otherwise return empty string
17 | ///
18 | public string RealPath { get; set; }
19 |
20 | ///
21 | /// Determines whether icon of package is an image
22 | ///
23 | public bool IsImage => !DefaultName.Equals(IconName) && !IsMarkup;
24 |
25 | internal bool IsMarkup => IconName
26 | .EndsWith(".xml", StringComparison.OrdinalIgnoreCase);
27 |
28 | // Not real icon, it refer to another
29 | internal bool IsRefernce => IconName.StartsWith("0x");
30 |
31 | internal bool IsHighDensity {
32 | get {
33 | if (!IsImage || !File.Exists(RealPath))
34 | return false;
35 |
36 | try {
37 | // Load from unsupported format will throw an exception.
38 | // But icon can be packed without extension
39 | using (var image = new Bitmap(RealPath)) {
40 | return image.Width > hdpiWidth;
41 | }
42 | }
43 | catch {
44 | return false;
45 | }
46 | }
47 | }
48 |
49 | ///
50 | /// Icon name can be an asset image (real icon image),
51 | /// markup file (actually it's image, but packed to xml)
52 | /// or reference to another
53 | ///
54 | internal string IconName { get; set; }
55 |
56 | internal Icon() => throw new NotImplementedException();
57 |
58 | internal Icon(string iconName) {
59 | IconName = iconName;
60 | RealPath = string.Empty;
61 | }
62 |
63 | public override string ToString() {
64 | return IconName;
65 | }
66 |
67 | public override bool Equals(object obj) {
68 | if (obj is Icon ic) {
69 | return IconName == ic.IconName;
70 | }
71 | return false;
72 | }
73 |
74 | public override int GetHashCode() {
75 | return -489061483 + EqualityComparer.Default.GetHashCode(IconName);
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/AAPTForNet/Models/SDKInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AAPTForNet.Models {
4 | public class SDKInfo {
5 | internal static readonly SDKInfo Unknown = new SDKInfo("0", "0", "0");
6 |
7 | // https://source.android.com/setup/start/build-numbers
8 | private static readonly string[] AndroidCodeNames = {
9 | "Unknown",
10 | "Unnamed", // API level 1
11 | "Unnamed",
12 | "Cupcake",
13 | "Donut",
14 | "Eclair",
15 | "Eclair",
16 | "Eclair",
17 | "Froyo",
18 | "Gingerbread",
19 | "Gingerbread",
20 | "Honeycomb",
21 | "Honeycomb",
22 | "Honeycomb",
23 | "Ice Cream Sandwich",
24 | "Ice Cream Sandwich",
25 | "Jelly Bean",
26 | "Jelly Bean",
27 | "Jelly Bean",
28 | "KitKat",
29 | "Unknown", // API level 20
30 | "Lollipop",
31 | "Lollipop",
32 | "Marshmallow",
33 | "Nougat",
34 | "Nougat",
35 | "Oreo",
36 | "Oreo",
37 | "Pie",
38 | "Android10",
39 | "Android11", // API level 30
40 | "Android12",
41 | "Android12L",
42 | "Android13"
43 | };
44 |
45 | private static readonly string[] AndroidVersionCodes = {
46 | "Unknown",
47 | "1.0", // API level 1
48 | "1.1",
49 | "1.5",
50 | "1.6",
51 | "2.0",
52 | "2.0",
53 | "2.1",
54 | "2.2",
55 | "2.3",
56 | "2.3",
57 | "3.0",
58 | "3.1",
59 | "3.2",
60 | "4.0",
61 | "4.0",
62 | "4.1",
63 | "4.2",
64 | "4.3",
65 | "4.4",
66 | "Unknown", // API level 20
67 | "5.0",
68 | "5.1",
69 | "6.0",
70 | "7.0",
71 | "7.1",
72 | "8.0",
73 | "8.1",
74 | "9",
75 | "10",
76 | "11", // API level 30
77 | "12",
78 | "12",
79 | "13"
80 | };
81 |
82 | public string APILever { get; }
83 | public string Version { get; }
84 | public string CodeName { get; }
85 |
86 | protected SDKInfo(string level, string ver, string code) {
87 | APILever = level;
88 | Version = ver;
89 | CodeName = code;
90 | }
91 |
92 | public static SDKInfo GetInfo(int sdkVer) {
93 | var index = (sdkVer < 1 || sdkVer > AndroidCodeNames.Length - 1) ? 0 : sdkVer;
94 |
95 | return new SDKInfo(sdkVer.ToString(),
96 | AndroidVersionCodes[index], AndroidCodeNames[index]);
97 | }
98 |
99 | public static SDKInfo GetInfo(string sdkVer) {
100 | int.TryParse(sdkVer, out var ver);
101 | return GetInfo(ver);
102 | }
103 |
104 | public override int GetHashCode() {
105 | return 1008763889 + EqualityComparer.Default.GetHashCode(APILever);
106 | }
107 |
108 | public override bool Equals(object obj) {
109 | if (obj is SDKInfo another) {
110 | return APILever == another.APILever;
111 | }
112 | return false;
113 | }
114 |
115 | public override string ToString() {
116 | if (APILever.Equals("0") && Version.Equals("0") && CodeName.Equals("0"))
117 | return AndroidCodeNames[0];
118 |
119 | return $"API Level {APILever} " +
120 | $"{(Version == AndroidCodeNames[0] ? $"({AndroidCodeNames[0]} - " : $"(Android {Version} - ")}" +
121 | $"{CodeName})";
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/AAPTForNet/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AAPTForNet")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("CaNheo")]
12 | [assembly: AssemblyProduct("AAPTForNet")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("22aa131d-dba0-445c-b790-fdfd951a1655")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.3.2.0")]
36 | [assembly: AssemblyFileVersion("1.3.2.0")]
37 |
--------------------------------------------------------------------------------
/AAPTForNet/ResourceDetector.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace AAPTForNet {
4 | internal class ResourceDetector {
5 | private static readonly string config =
6 | string.Join("|", System.Enum.GetNames(typeof(Models.Configs)));
7 |
8 | ///
9 | ///
10 | /// resource id
11 | public static bool IsResource(string input, string id = "") {
12 | // id is a word (\w)
13 | id = string.Empty.Equals(id) ? @"\w*" : id;
14 | return Regex.IsMatch(input, $"^\\s*resource\\s{id}");
15 | }
16 | ///
17 | /// Is resource value
18 | ///
19 | public static bool IsResourceValue(string input) {
20 | // Start with space, then (string?)
21 | return Regex.IsMatch(input, @"^\s*\((string\d*)\)*");
22 | }
23 | ///
24 | /// Determines resource is reference (to another)
25 | ///
26 | public static bool IsReference(string input) {
27 | // Start with space, then (reference)
28 | return Regex.IsMatch(input, @"^\s*\((reference)\)*");
29 | }
30 | ///
31 | /// Determines resource is a bitmap resource
32 | ///
33 | public static bool IsBitmapElement(string input) {
34 | return Regex.IsMatch(input, @"^\s*E:\sbitmap");
35 | }
36 |
37 | public static bool IsConfig(string input) {
38 | // config (default) | (hdpi|mdpi|...)[-vxx]
39 | return Regex.IsMatch(input, $"^\\s*config\\s\\(?({config})(-v\\d*)?\\)?:");
40 | }
41 |
42 | public static bool IsEntryType(string input) {
43 | // type x configCount=xx entryCount=xxx
44 | return Regex.IsMatch(input, $"^\\s*type\\s\\d*\\sconfigCount=\\d*\\sentryCount=\\d*$");
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AAPTForNet/tool/aapt.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canheo136/QuickLook.Plugin.ApkViewer/1581962ae76a001c4fe9178e4101a2936f9f10e4/AAPTForNet/tool/aapt.exe
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Plugin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Windows;
4 | using AAPTForNet;
5 | using QuickLook.Common.Helpers;
6 | using QuickLook.Common.Plugin;
7 |
8 | namespace QuickLook.Plugin.ApkViewer {
9 | public class Plugin : IViewer {
10 |
11 | private string tempApk = string.Empty;
12 |
13 | public int Priority => 0;
14 |
15 | public void Init() { }
16 |
17 | public bool CanHandle(string path) => path.ToLower().EndsWith(".apk");
18 |
19 | public void Prepare(string path, ContextObject context) {
20 | context.Title = Path.GetFileName(path);
21 | context.PreferredSize = new Size { Width = 750, Height = 450 };
22 |
23 | tempApk = createTempApk(path);
24 | }
25 |
26 | public void View(string path, ContextObject context) {
27 | try {
28 | var apk = AAPTool.Decompile(tempApk);
29 | if (apk.IsEmpty)
30 | context.ViewerContent = new ErrorContent();
31 | else
32 | context.ViewerContent = new ViewerPane(context) { ApkInfo = apk };
33 | }
34 | catch (Exception e) {
35 | ProcessHelper.WriteLog($"{path}\r\n{e}");
36 | context.ViewerContent = new ErrorContent();
37 | }
38 |
39 | context.IsBusy = false;
40 | }
41 |
42 | public void Cleanup() {
43 | if (!tempApk.ToLower().EndsWith(".tmp"))
44 | return;
45 |
46 | try {
47 | File.Delete(tempApk);
48 | }
49 | catch (Exception e) {
50 | ProcessHelper.WriteLog(e.ToString());
51 | }
52 | }
53 |
54 | private string createTempApk(string sourceFile) {
55 | string tempFile = string.Empty;
56 | try {
57 | tempFile = Path.GetTempFileName();
58 | }
59 | catch (IOException) {
60 | tempFile = Path.Combine(Path.GetTempPath(), $"{nameof(ApkViewer)}.tmp");
61 | }
62 |
63 | try {
64 | File.Copy(sourceFile, tempFile, true);
65 | return tempFile;
66 | }
67 | catch {
68 | return sourceFile;
69 | }
70 | }
71 |
72 | private class ErrorContent : System.Windows.Controls.Label {
73 | public ErrorContent() {
74 | FontSize = 16;
75 | Content = "Can not load package.";
76 | Foreground = System.Windows.Media.Brushes.White;
77 | VerticalAlignment = VerticalAlignment.Center;
78 | HorizontalAlignment = HorizontalAlignment.Center;
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("QuickLook.Plugin.ApkViewer")]
9 | [assembly: AssemblyDescription("Android package plugin for QuickLook")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("CaNheo")]
12 | [assembly: AssemblyProduct("QuickLook.Plugin.ApkViewer")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | //In order to begin building localizable applications, set
23 | //CultureYouAreCodingWith in your .csproj file
24 | //inside a . For example, if you are using US english
25 | //in your source files, set the to en-US. Then uncomment
26 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
27 | //the line below to match the UICulture setting in the project file.
28 |
29 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
30 |
31 |
32 | [assembly: ThemeInfo(
33 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
34 | //(used if a resource is not found in the page,
35 | // or application resource dictionaries)
36 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
37 | //(used if a resource is not found in the page,
38 | // app, or any theme specific resource dictionaries)
39 | )]
40 | [assembly: AssemblyVersion("1.3.3.0")]
41 | [assembly: AssemblyFileVersion("1.3.3.0")]
42 |
43 |
--------------------------------------------------------------------------------
/QuickLook.Plugin.ApkViewer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {863ECAAC-18D9-4256-A27D-0F308089FB47}
8 | library
9 | QuickLook.Plugin.ApkViewer
10 | QuickLook.Plugin.ApkViewer
11 | v4.6.2
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 | true
35 | Debug\
36 | DEBUG;TRACE
37 | full
38 | x86
39 | prompt
40 | MinimumRecommendedRules.ruleset
41 |
42 |
43 | Release\
44 | TRACE
45 | true
46 | pdbonly
47 | x86
48 | prompt
49 | MinimumRecommendedRules.ruleset
50 |
51 |
52 | false
53 |
54 |
55 |
56 |
57 |
58 |
59 | OnBuildSuccess
60 |
61 |
62 |
63 |
64 |
65 |
66 | 4.0
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | ViewerPane.xaml
77 |
78 |
79 |
80 |
81 | {22aa131d-dba0-445c-b790-fdfd951a1655}
82 | AAPTForNet
83 |
84 |
85 | {85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95}
86 | QuickLook.Common
87 | False
88 |
89 |
90 |
91 |
92 | Always
93 | Designer
94 |
95 |
96 |
97 |
98 | Designer
99 | MSBuild:Compile
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | if $(ConfigurationName) == Release (
114 | powershell -file "$(SolutionDir)Scripts\pack-zip.ps1"
115 | )
116 |
117 |
--------------------------------------------------------------------------------
/QuickLook.Plugin.ApkViewer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32002.261
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.ApkViewer", "QuickLook.Plugin.ApkViewer.csproj", "{863ECAAC-18D9-4256-A27D-0F308089FB47}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Common", "QuickLook.Common\QuickLook.Common.csproj", "{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AAPTForNet", "AAPTForNet\AAPTForNet.csproj", "{22AA131D-DBA0-445C-B790-FDFD951A1655}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7B37254B-321D-41E6-A619-62BD36B319FB}"
13 | ProjectSection(SolutionItems) = preProject
14 | .editorconfig = .editorconfig
15 | .gitignore = .gitignore
16 | EndProjectSection
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartupDebuging", "StartupDebuging\StartupDebuging.csproj", "{D0E511A2-926A-41A6-A148-4CADB5223A89}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Debug|x86 = Debug|x86
24 | Release|Any CPU = Release|Any CPU
25 | Release|x86 = Release|x86
26 | EndGlobalSection
27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
28 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Debug|x86.ActiveCfg = Debug|x86
31 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Debug|x86.Build.0 = Debug|x86
32 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Release|x86.ActiveCfg = Release|x86
35 | {863ECAAC-18D9-4256-A27D-0F308089FB47}.Release|x86.Build.0 = Release|x86
36 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Debug|x86.ActiveCfg = Debug|Any CPU
39 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Debug|x86.Build.0 = Debug|Any CPU
40 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|x86.ActiveCfg = Release|Any CPU
43 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|x86.Build.0 = Release|Any CPU
44 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Debug|x86.ActiveCfg = Debug|Any CPU
47 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Debug|x86.Build.0 = Debug|Any CPU
48 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Release|x86.ActiveCfg = Release|Any CPU
51 | {22AA131D-DBA0-445C-B790-FDFD951A1655}.Release|x86.Build.0 = Release|Any CPU
52 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Debug|x86.ActiveCfg = Debug|Any CPU
55 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Debug|x86.Build.0 = Debug|Any CPU
56 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Release|x86.ActiveCfg = Release|Any CPU
59 | {D0E511A2-926A-41A6-A148-4CADB5223A89}.Release|x86.Build.0 = Release|Any CPU
60 | EndGlobalSection
61 | GlobalSection(SolutionProperties) = preSolution
62 | HideSolutionNode = FALSE
63 | EndGlobalSection
64 | GlobalSection(ExtensibilityGlobals) = postSolution
65 | SolutionGuid = {D545EDE6-0533-4E3F-BB67-308B17E4EDAC}
66 | EndGlobalSection
67 | EndGlobal
68 |
--------------------------------------------------------------------------------
/QuickLook.Plugin.Metadata.Base.config:
--------------------------------------------------------------------------------
1 |
2 |
3 | QuickLook.Plugin.ApkViewer
4 | 1.0.0.0
5 | Preview Android package (.apk) file
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QuickLook.Plugin.ApkViewer [](https://github.com/canheo136/QuickLook.Plugin.ApkViewer/releases)
2 | Android package plugin for [QuickLook](https://github.com/QL-Win/QuickLook), allowing to preview `.apk` file
3 |
4 |
5 |
6 |
7 | ## Download and Installation
8 | 1. Go to [Release page](https://github.com/canheo136/QuickLook.Plugin.ApkViewer/releases) and download the latest version.
9 | 2. Make sure that you have QuickLook running in the background. Press `Spacebar` on the downloaded `.qlplugin` file.
10 | 3. Click the `Install` button in the popup window.
11 | 4. Restart QuickLook.
12 |
13 | ## Development
14 | 1. Clone repo and sub-modules
15 | 2. Build project with Release profile.
16 | 3. Run `Scripts\pack-zip.ps1`
17 | 4. Find plugin `QuickLook.Plugin.ApkViewer.qlplugin` in the project directory.
18 |
19 | ## License
20 | **GPL-3.0**
21 |
--------------------------------------------------------------------------------
/Scripts/pack-zip.ps1:
--------------------------------------------------------------------------------
1 | Remove-Item ..\QuickLook.Plugin.ApkViewer.qlplugin -ErrorAction SilentlyContinue
2 |
3 | $files = Get-ChildItem -Path ..\release\ -Exclude *.pdb,*.xml
4 | $outputPlugin = '..\..\QuickLook.Plugin.ApkViewer.qlplugin'
5 |
6 | Compress-Archive $files ..\QuickLook.Plugin.ApkViewer.zip -Force
7 | Move-Item ..\QuickLook.Plugin.ApkViewer.zip $outputPlugin -Force
8 |
9 | [string]::Concat("Packed plugin -> ", [System.IO.Path]::GetFullPath($outputPlugin))
--------------------------------------------------------------------------------
/Scripts/update-version.ps1:
--------------------------------------------------------------------------------
1 | $tag = git describe --always --tags "--abbrev=0"
2 | $revision = git describe --always --tags
3 |
4 | $text = @"
5 | // This file is generated by update-version.ps1
6 |
7 | using System.Reflection;
8 |
9 | [assembly: AssemblyVersion("$tag")]
10 | [assembly: AssemblyInformationalVersion("$revision")]
11 | "@
12 |
13 | $text | Out-File $PSScriptRoot\..\GitVersion.cs -Encoding utf8
14 |
15 |
16 | $xml = [xml](Get-Content $PSScriptRoot\..\QuickLook.Plugin.Metadata.Base.config)
17 | $xml.Metadata.Version="$revision"
18 | $xml.Save("$PSScriptRoot\..\QuickLook.Plugin.Metadata.config")
--------------------------------------------------------------------------------
/StartupDebuging/.gitignore:
--------------------------------------------------------------------------------
1 | apks/*.apk
--------------------------------------------------------------------------------
/StartupDebuging/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/StartupDebuging/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using AAPTForNet;
5 |
6 | namespace StartupDebuging {
7 | class Program {
8 |
9 | static readonly string[] APK_FILES = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "apks"), "*.apk");
10 |
11 | public static void Main(string[] args) {
12 |
13 | if (APK_FILES == null || APK_FILES.Length == 0)
14 | throw new Exception("There are no apk files to run AAPT");
15 |
16 | var apks = APK_FILES.Take(20).Select(f => {
17 |
18 | try {
19 | var apk = AAPTool.Decompile(f);
20 | return apk;
21 | }
22 | catch (Exception ex) {
23 | Console.WriteLine(ex);
24 | Console.WriteLine("===========================================");
25 | return null;
26 | }
27 |
28 | }).ToList();
29 |
30 | #pragma warning disable CS0219
31 | var breakPoint = "Break me";
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/StartupDebuging/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("StartupDebuging")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("StartupDebuging")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d0e511a2-926a-41a6-a148-4cadb5223a89")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/StartupDebuging/StartupDebuging.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D0E511A2-926A-41A6-A148-4CADB5223A89}
8 | Exe
9 | StartupDebuging
10 | StartupDebuging
11 | v4.6.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 | {22aa131d-dba0-445c-b790-fdfd951a1655}
156 | AAPTForNet
157 |
158 |
159 | {85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95}
160 | QuickLook.Common
161 |
162 |
163 |
164 |
165 | mkdir $(ProjectDir)$(OutDir)\apks
166 | copy $(ProjectDir)apks\* $(ProjectDir)$(OutDir)\apks\
167 |
168 |
--------------------------------------------------------------------------------
/StartupDebuging/apks/README.md:
--------------------------------------------------------------------------------
1 | ### Testing apk files here!
--------------------------------------------------------------------------------
/ViewerPane.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
22 |
28 |
29 |
41 |
42 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
72 |
73 |
74 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
102 |
103 |
122 |
123 |
124 |
125 |
130 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/ViewerPane.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Diagnostics;
4 | using System.Runtime.CompilerServices;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Input;
8 | using System.Windows.Media.Imaging;
9 | using AAPTForNet.Models;
10 | using QuickLook.Common.Annotations;
11 | using QuickLook.Common.ExtensionMethods;
12 | using QuickLook.Common.Helpers;
13 | using QuickLook.Common.Plugin;
14 |
15 | namespace QuickLook.Plugin.ApkViewer {
16 |
17 | public partial class ViewerPane : UserControl, INotifyPropertyChanged {
18 | private const string SETTING_THEME_ID = "Theme";
19 |
20 | private ApkInfo _apkInfo = null;
21 | private ContextObject _quickLook = null;
22 |
23 | public event PropertyChangedEventHandler PropertyChanged;
24 |
25 | public ApkInfo ApkInfo {
26 | get => _apkInfo;
27 | set {
28 | _apkInfo = value;
29 | InitGUI();
30 | }
31 | }
32 |
33 | public Themes Theme {
34 | get => _quickLook?.Theme ?? Themes.Dark;
35 | set {
36 | _quickLook.Theme = value;
37 | OnPropertyChanged();
38 | }
39 | }
40 |
41 | public bool IsDark => Theme == Themes.Dark;
42 |
43 | public ViewerPane() {
44 | InitializeComponent();
45 | btnSwTheme.MouseLeftButtonDown += SwitchTheme;
46 | }
47 |
48 | public ViewerPane(ContextObject ql) : this() {
49 | _quickLook = ql;
50 | _quickLook.PropertyChanged += AfterThemeChanged;
51 |
52 | Theme = (Themes) SettingHelper.Get(SETTING_THEME_ID, 1, GetType().Namespace);
53 | }
54 |
55 | private void SwitchTheme(object sender, MouseButtonEventArgs e) {
56 | Theme = IsDark ? Themes.Light : Themes.Dark;
57 | SettingHelper.Set(SETTING_THEME_ID, (int) Theme, GetType().Namespace);
58 | }
59 |
60 | private void AfterThemeChanged(object sender, PropertyChangedEventArgs e) {
61 | if (e.PropertyName != nameof(Theme))
62 | return;
63 |
64 | var resourceUri = "/QuickLook.Common;component/Styles" +
65 | $"/MainWindowStyles{(IsDark ? ".Dark" : "")}.xaml";
66 |
67 | Resources.MergedDictionaries.Clear();
68 | Resources.MergedDictionaries.Add(new ResourceDictionary {
69 | Source = new Uri(resourceUri, UriKind.Relative)
70 | });
71 | }
72 |
73 | private void InitGUI() {
74 | tbAppName.Text = ApkInfo.AppName;
75 | tbPckName.Text = ApkInfo.PackageName;
76 | tbVerName.Text = ApkInfo.VersionName;
77 | tbVerCode.Text = ApkInfo.VersionCode;
78 | tbMinSDK.Text = ApkInfo.MinSDK.ToString();
79 | tbTargetSDK.Text = ApkInfo.TargetSDK.ToString();
80 | tbPckSize.Text = ApkInfo.PackageSize.ToPrettySize(2);
81 | tbSupportScr.Text = string.Join(", ", ApkInfo.SupportScreens);
82 |
83 | if (ApkInfo.SupportedABIs.Count == 0) {
84 | labels.Children.Remove(lbAbis);
85 | textboxs.Children.Remove(tbAbis);
86 | }
87 | else {
88 | tbAbis.Text = string.Join(", ", ApkInfo.SupportedABIs);
89 | }
90 |
91 | if (ApkInfo.Permissions.Count != 0) {
92 | var hoverableStyle = Resources["HoverableLabel"] as Style;
93 |
94 | foreach (string per in ApkInfo.Permissions) {
95 | permissionStack.Children.Add(
96 | new HoverableLabel(per, hoverableStyle, SelectableLabel_MouseDoubleClick)
97 | );
98 | }
99 | }
100 | else {
101 | panelPermission.Content = new Label() {
102 | Content = "This package does not require any permission",
103 | VerticalAlignment = VerticalAlignment.Center,
104 | HorizontalAlignment = HorizontalAlignment.Center,
105 | Style = Resources["CommonStyle"] as Style
106 | };
107 | }
108 |
109 | if (ApkInfo.Icon.IsImage) {
110 | var uri = new Uri(ApkInfo.Icon.RealPath);
111 |
112 | image.ToolTip = "Open image";
113 | image.Source = LoadBitmapImage(uri);
114 | image.MouseLeftButtonDown += (sender, e) => {
115 | Process.Start("explorer.exe", ApkInfo.Icon.RealPath);
116 | };
117 | }
118 | else {
119 | image.Source = Resources["DefaultIcon"] as BitmapImage;
120 | }
121 | }
122 |
123 | private BitmapImage LoadBitmapImage(Uri source) {
124 | var bitmap = new BitmapImage();
125 | bitmap.BeginInit();
126 | // Ignore previous image in cache
127 | bitmap.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
128 | // Cached image, prevent file in use exception
129 | bitmap.CacheOption = BitmapCacheOption.OnLoad;
130 | bitmap.UriSource = source;
131 | bitmap.EndInit();
132 | return bitmap;
133 | }
134 |
135 | [NotifyPropertyChangedInvocator]
136 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
137 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
138 | }
139 |
140 | private void SelectableLabel_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
141 | var ctrl = sender as TextBox;
142 | ctrl?.SelectAll();
143 | }
144 |
145 | private class HoverableLabel : TextBox {
146 | public HoverableLabel(string text, Style style,
147 | MouseButtonEventHandler dbClickHandler) {
148 | Text = text;
149 | Style = style;
150 | MouseDoubleClick += dbClickHandler;
151 | }
152 | }
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/images/black_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canheo136/QuickLook.Plugin.ApkViewer/1581962ae76a001c4fe9178e4101a2936f9f10e4/images/black_btn.png
--------------------------------------------------------------------------------
/images/default_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canheo136/QuickLook.Plugin.ApkViewer/1581962ae76a001c4fe9178e4101a2936f9f10e4/images/default_icon.png
--------------------------------------------------------------------------------
/images/white_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canheo136/QuickLook.Plugin.ApkViewer/1581962ae76a001c4fe9178e4101a2936f9f10e4/images/white_btn.png
--------------------------------------------------------------------------------