Files
waydroid/tools/helpers/protocol.py
Alessandro Astone ef1f12c89c Support upgrading major android versions
When restarting the lxc container our binder services will receive a
binder_presence event and will try to re-register on the service manager.
If the service manager was created with aidl2 and the new android version
uses aidl3 this will fail with:
  Failed to add service waydroidusermonitor: -2147483647

When that happens, try to restart the service by getting a new service
manager that can handle the new aidl protocol version.
2022-07-23 09:53:07 +02:00

32 lines
950 B
Python

from tools import helpers
import tools.config
import logging
# Call me with rootfs mounted!
def set_aidl_version(args):
cfg = tools.config.load(args)
android_api = 0
try:
android_api = int(helpers.props.file_get(args,
tools.config.defaults["rootfs"] + "/system/build.prop",
"ro.build.version.sdk"))
except:
logging.error("Failed to parse android version from system.img")
if android_api < 28:
binder_protocol = "aidl"
sm_protocol = "aidl"
elif android_api < 30:
binder_protocol = "aidl2"
sm_protocol = "aidl2"
elif android_api < 31:
binder_protocol = "aidl3"
sm_protocol = "aidl3"
else:
binder_protocol = "aidl3"
sm_protocol = "aidl4"
cfg["waydroid"]["binder_protocol"] = binder_protocol
cfg["waydroid"]["service_manager_protocol"] = sm_protocol
tools.config.save(args, cfg)