Skip to content

Commit b0a46c1

Browse files
extract-utils: Apply relative path for apps with deep folder structures
While most apps follow the standard structure of <partition>/app/<app_name>/<app_name>.apk or <partition>/priv-app/<app_name>/<app_name>.apk, some apps require deeper directory structures, such as Android Platform Services which belongs in product/priv-app/GmsCore/m/independent/AndroidPlatformServices.apk. Without this change, such apps would be incorrectly copied to product/priv-app/AndroidPlatformServices/AndroidPlatformServices.apk, losing their proper directory structure. Bash implementation: AOSPA/android_tools_extract-utils@d6a5704 Change-Id: Ia44df744841b2a83f9c02733cb0bb7d0898a5b94 Signed-off-by: Jyotiraditya Panda <jyotiraditya@aospa.co>
1 parent 2093aa1 commit b0a46c1

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

extract_utils/bp_builder.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,20 @@ def __init__(
162162

163163
self.set_partition(file.partition)
164164

165-
def __file_dir_without_prefix(self) -> Optional[str]:
165+
def __file_dir_without_prefix(self, is_app=False) -> Optional[str]:
166166
# Remove the length of the file tree prefix from the dirname,
167167
# including the final slash
168168
remaining = self.__file.dirname[self.__prefix_len :]
169169
if not remaining:
170170
return None
171171

172+
if is_app and '/' not in remaining:
173+
return None
174+
172175
return remaining
173176

174-
def relative_install_path(self):
175-
p = self.__file_dir_without_prefix()
177+
def relative_install_path(self, is_app=False):
178+
p = self.__file_dir_without_prefix(is_app)
176179
return self.set('relative_install_path', p, optional=True)
177180

178181
def sub_dir(self):

extract_utils/makefiles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def write_app_package(file: File, builder: FileBpBuilder):
343343
.set('dex_preopt', {'enabled': False})
344344
.set('privileged', file.privileged, optional=True)
345345
.skip_preprocessed_apk_checks()
346+
.relative_install_path(is_app=True)
346347
.specific()
347348
)
348349
return package_name

0 commit comments

Comments
 (0)