Fix product name finder
This commit is contained in:
parent
29e47d2a5c
commit
978b2c135d
1 changed files with 15 additions and 7 deletions
|
@ -59,7 +59,18 @@ class AndroidManager:
|
||||||
dev['object'] = device_object
|
dev['object'] = device_object
|
||||||
try:
|
try:
|
||||||
dev['properties'] = device_object.get_properties()
|
dev['properties'] = device_object.get_properties()
|
||||||
dev['name'] = dev['properties']['ro.semc.product.name']
|
if 'ro.semc.product.name' in dev['properties']:
|
||||||
|
dev['name'] = dev['properties']['ro.semc.product.name']
|
||||||
|
elif 'ro.vendor.oplus.market.name' in dev['properties']:
|
||||||
|
dev['name'] = dev['properties']['ro.vendor.oplus.market.name']
|
||||||
|
elif 'ro.product.name' in dev['properties']:
|
||||||
|
dev['name'] = dev['properties']['ro.product.name']
|
||||||
|
else:
|
||||||
|
with open('/tmp/tmp.properties.json', 'w', encoding='utf-8') as debug_file:
|
||||||
|
debug_file.write(json.dumps(dev['properties'], indent=2))
|
||||||
|
self._log.warning(
|
||||||
|
"Device product name not found. Check the /tmp/tmp.properties.json file for the right property to get a product name and notify the developer."
|
||||||
|
)
|
||||||
device_object.shell('dumpsys bluetooth_manager', handler=self._handle_output)
|
device_object.shell('dumpsys bluetooth_manager', handler=self._handle_output)
|
||||||
for line in self.lines:
|
for line in self.lines:
|
||||||
match = re.search(r'^ Name: (.*)$', line)
|
match = re.search(r'^ Name: (.*)$', line)
|
||||||
|
@ -361,8 +372,9 @@ class AndroidManager:
|
||||||
@click_config_file.configuration_option()
|
@click_config_file.configuration_option()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, **kwargs):
|
def cli(ctx, **kwargs):
|
||||||
|
'''CLI function'''
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
ctx.obj['debug_level'] = kwargs['debug_level']
|
ctx.obj['config'] = kwargs
|
||||||
ctx.obj['android_manager'] = AndroidManager(**kwargs)
|
ctx.obj['android_manager'] = AndroidManager(**kwargs)
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
|
@ -387,9 +399,5 @@ def restore_apps(ctx, backup_text_file, device_product_name):
|
||||||
'''Restore Android apps'''
|
'''Restore Android apps'''
|
||||||
ctx.obj['android_manager'].restore_apps(backup_text_file, device_product_name)
|
ctx.obj['android_manager'].restore_apps(backup_text_file, device_product_name)
|
||||||
|
|
||||||
def __main__(**kwargs):
|
|
||||||
obj = AndroidManager(**kwargs)
|
|
||||||
obj.close()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
__main__()
|
cli(obj={})
|
||||||
|
|
Loading…
Reference in a new issue