#!/usr/bin/env python3 # SPDX-License-Identifier: MPL-2.0 """Qualify Nokia controls in an already running manual Gaia diagnostic session. Injects one volume-up/down pair, dims briefly and vibrates for 500 ms. Restores Gaia settings afterwards. Does not call, send SMS, reboot or flash. """ import argparse,json,subprocess,tempfile,time,uuid from concurrent.futures import ThreadPoolExecutor from pathlib import Path BASE='/data/local/vulpes-beatles/rootfs/work/' def shell(command): return subprocess.check_output(['adb','shell',command],text=True,timeout=10).strip() def publish(name,value): with tempfile.NamedTemporaryFile(mode='w') as f: json.dump(value,f);f.flush() subprocess.run(['adb','push',f.name,BASE+name+'.tmp'],capture_output=True,check=True) shell('mv '+BASE+name+'.tmp '+BASE+name) def probe(script): identifier=uuid.uuid4().hex publish('manual-request.json',{'id':identifier,'app':'system','script':script}) deadline=time.monotonic()+20 while time.monotonic()64:raise RuntimeError('Start a fresh manual session') publish('keypad-request.json',{'sequence':sequence,'key':key}) deadline=time.monotonic()+5 while time.monotonic()__controlProof.events.push(e.detail.type); const hud=()=>setTimeout(()=>__controlProof.hud.push(getComputedStyle(document.getElementById("volume")).display),100); addEventListener("softwareButtonEvent",buttons); for(const event of ["volumeup","volumedown"])addEventListener(event,hud); window.__controlCleanup=()=>{removeEventListener("softwareButtonEvent",buttons); for(const event of ["volumeup","volumedown"])removeEventListener(event,hud);}; return true;') # Establish a middle volume so both buttons can change it. probe('return await navigator.mozSettings.createLock().set({"audio.volume.notification":7});') def settle(expected): deadline=time.monotonic()+15 while time.monotonic()1:break future.result() report['vibration']={'positiveSample':any(n>0 for n in samples),'final':samples[-1]} finally: probe('return await VulpesCompat.call("hardware.vibrate",{pattern:[]});') probe('return await VulpesCompat.call("desktop.screen",{name:"screenBrightness",value:'+str(initial/255)+'});') probe('return await navigator.mozSettings.createLock().set({"audio.volume.notification":'+str(volume)+'});') probe('window.__controlCleanup?.();delete window.__controlCleanup;delete window.__controlProof;return true;') report['restoredBacklight']=int(shell('cat /sys/class/leds/lcd-backlight/brightness')) args.output.parent.mkdir(parents=True,exist_ok=True) args.output.write_text(json.dumps(report,indent=2)+'\n') assert report['volumeUp']==8 and report['volumeDown']==7,report assert '00000008 00000000' in report['nativeUp'] and '00000007 00000000' in report['nativeDown'],report assert 'block' in report['ui']['hud'],report assert report['backlight20percent']==51 and report['restoredBacklight']==initial,report assert report['vibration']['positiveSample'] and report['vibration']['final']==0,report print('Gaia volume HUD, native audio indexes, backlight and bounded vibration: OK') if __name__=='__main__':main()