@@ -15,7 +15,7 @@ public AndroidAssemblyDirectoryReaderV2(string apkPath, IList<string> supportedA
15
15
logger ? . Invoke ( "Adding {0} to supported architectures for Directory Reader" , abi ) ;
16
16
SupportedArchitectures . Add ( abi . AbiToDeviceArchitecture ( ) ) ;
17
17
}
18
- _archiveAssemblyHelper = new ArchiveAssemblyHelper ( apkPath , logger ) ;
18
+ _archiveAssemblyHelper = new ArchiveAssemblyHelper ( apkPath , logger , supportedAbis ) ;
19
19
}
20
20
21
21
public PEReader ? TryReadAssembly ( string name )
@@ -59,8 +59,9 @@ internal class ArchiveAssemblyHelper
59
59
60
60
private readonly string _archivePath ;
61
61
private readonly DebugLogger ? _logger ;
62
+ private readonly IList < string > _supportedAbis ;
62
63
63
- public ArchiveAssemblyHelper ( string archivePath , DebugLogger ? logger )
64
+ public ArchiveAssemblyHelper ( string archivePath , DebugLogger ? logger , IList < string > supportedAbis )
64
65
{
65
66
if ( string . IsNullOrEmpty ( archivePath ) )
66
67
{
@@ -69,6 +70,7 @@ public ArchiveAssemblyHelper(string archivePath, DebugLogger? logger)
69
70
70
71
_archivePath = archivePath ;
71
72
_logger = logger ;
73
+ _supportedAbis = supportedAbis ;
72
74
}
73
75
74
76
public MemoryStream ? ReadEntry ( string path , AndroidTargetArch arch = AndroidTargetArch . None , bool uncompressIfNecessary = false )
@@ -144,21 +146,48 @@ public ArchiveAssemblyHelper(string archivePath, DebugLogger? logger)
144
146
return null ;
145
147
}
146
148
147
- using var zip = ZipFile . OpenRead ( _archivePath ) ;
148
- foreach ( var assemblyPath in potentialEntries )
149
+ // First we check the base.apk
150
+ if ( ReadEntryFromApk ( _archivePath ) is { } baseEntry )
149
151
{
150
- if ( zip . GetEntry ( assemblyPath ) is not { } entry )
152
+ _logger ? . Invoke ( "Found entry '{0}' in base archive '{1}'" , path , _archivePath ) ;
153
+ return baseEntry ;
154
+ }
155
+
156
+ // Otherwise check in the device specific APKs
157
+ foreach ( var supportedAbi in _supportedAbis )
158
+ {
159
+ var splitFilePath = _archivePath . GetArchivePathForAbi ( supportedAbi , _logger ) ;
160
+ if ( ! File . Exists ( splitFilePath ) )
151
161
{
152
- _logger ? . Invoke ( "No entry found for path '{0}' in archive '{1}'" , assemblyPath , _archivePath ) ;
153
- continue ;
162
+ _logger ? . Invoke ( "No split config detected at: '{0}'" , splitFilePath ) ;
163
+ }
164
+ else if ( ReadEntryFromApk ( splitFilePath ) is { } splitEntry )
165
+ {
166
+ return splitEntry ;
154
167
}
155
-
156
- var ret = entry . Extract ( ) ;
157
- ret . Flush ( ) ;
158
- return ret ;
159
168
}
160
169
170
+ // Finally admit defeat
161
171
return null ;
172
+
173
+ MemoryStream ? ReadEntryFromApk ( string archivePath )
174
+ {
175
+ using var zip = ZipFile . OpenRead ( archivePath ) ;
176
+ foreach ( var assemblyPath in potentialEntries )
177
+ {
178
+ if ( zip . GetEntry ( assemblyPath ) is not { } entry )
179
+ {
180
+ _logger ? . Invoke ( "No entry found for path '{0}' in archive '{1}'" , assemblyPath , archivePath ) ;
181
+ continue ;
182
+ }
183
+
184
+ var ret = entry . Extract ( ) ;
185
+ ret . Flush ( ) ;
186
+ return ret ;
187
+ }
188
+
189
+ return null ;
190
+ }
162
191
}
163
192
164
193
/// <summary>
0 commit comments