Repository Public
1#!/bin/bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : KA Maps Engine8# File : sdk/android/scripts/essai-mort-processus.sh9# Module : sdk10# Repository : https://git.spboucher.ai/ka-maps-engine11# Created : 2026-12-0112# Last Modified : 2026-12-0113#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# Mort du processus en plein téléchargement d'une archive de région : le travail reprend-il seul, à quel octet ?41# Application d'exemple en `release` (./gradlew :example:assembleRelease), émulateur ou appareil avec `adb root`.42#43# SERIAL=emulator-5570 scripts/essai-mort-processus.sh44set -u45HERE="$(cd "$(dirname "$0")/.." && pwd)"46ADB="${ADB:-/opt/homebrew/share/android-commandlinetools/platform-tools/adb}"47SERIAL="${SERIAL:-emulator-5570}"48a() { "$ADB" -s "$SERIAL" "$@"; }49P=com.spboucher.kamaps.example50PART=/data/data/$P/files/kamaps/store/_pack_montreal.part51FIN=/data/data/$P/files/kamaps/store/_pack_montreal.pmtiles52size() { a shell "stat -c %s $1 2>/dev/null" | tr -d '\r'; }53pid() { a shell pidof $P | tr -d '\r'; }5455a root >/dev/null; sleep 356a install -r "$HERE/example/build/outputs/apk/release/example-release.apk" | tail -157a shell pm clear $P >/dev/null58a shell pm grant $P android.permission.POST_NOTIFICATIONS59# Réseau bridé (émulateur) pour avoir le temps de tuer le processus en cours de route.60a emu network speed hsdpa >/dev/null 2>&161a shell am start -n $P/.MainActivity --es offline pack:montreal >/dev/null62for i in $(seq 1 120); do s=$(size $PART); [ -n "$s" ] && [ "$s" -gt 6000000 ] && break; sleep 0.5; done63OLD=$(pid)64echo "avant la mort : pid=$OLD, partiel=$(size $PART) octets, services au premier plan=$(a shell dumpsys activity services $P | grep -c 'isForeground=true')"65a shell kill -9 "$OLD"66sleep 167K=$(size $PART)68echo "processus tué ; fichier partiel gardé : $K octets ; pid après 1 s : '$(pid)'"69T0=$(date +%s)70for i in $(seq 1 180); do71 f=$(size $FIN)72 if [ -n "$f" ]; then echo "archive complète sans relancer l'application : $f octets, $(( $(date +%s) - T0 )) s après la mort ; pid=$(pid)"; break; fi73 [ "$i" -eq 5 ] && echo "à 5 s : partiel=$(size $PART) octets (>= $K : reprise, pas de recommencement)"74 sleep 175done76[ -z "$(size $FIN)" ] && echo "PAS de reprise automatique en 180 s (partiel=$(size $PART))"77a emu network speed full >/dev/null 2>&178sleep 679echo "archives installées : $(a shell "cat /data/data/$P/files/kamaps/store/_packs.json" | tr -d '\r')"80a shell am force-stop $P81