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.
for path in perm_list:
chmod(path, mode)
- def set_aidl_version():
- 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)
-
def signal_handler(sig, frame):
services.hardware_manager.stop(args)
stop(args)
# Mount rootfs
helpers.images.mount_rootfs(args, cfg["waydroid"]["images_path"])
- set_aidl_version()
+ helpers.protocol.set_aidl_version(args)
# Mount data
helpers.mount.bind(args, session_cfg["session"]["waydroid_data"],
if status != "STOPPED":
logging.info("Starting container")
helpers.images.mount_rootfs(args, args.images_path)
+ helpers.protocol.set_aidl_version(args)
helpers.lxc.start(args)
import tools.helpers.http
import tools.helpers.ipc
import tools.helpers.gpu
+import tools.helpers.protocol
--- /dev/null
+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)
logging.debug(str(e))
canClip = False
+stopping = False
+
def start(args):
def sendClipboardData(value):
try:
logging.debug(str(e))
def service_thread():
- IClipboard.add_service(args, sendClipboardData, getClipboardData)
+ while not stopping:
+ IClipboard.add_service(args, sendClipboardData, getClipboardData)
if canClip:
+ global stopping
+ stopping = False
args.clipboard_manager = threading.Thread(target=service_thread)
args.clipboard_manager.start()
else:
logging.warning("Failed to start Clipboard manager service, check logs")
def stop(args):
+ global stopping
+ stopping = True
try:
if args.clipboardLoop:
args.clipboardLoop.quit()
from tools import helpers
from tools.interfaces import IHardware
+stopping = False
def start(args):
def enableNFC(enable):
helpers.images.replace(args, system_zip, system_time,
vendor_zip, vendor_time)
helpers.images.mount_rootfs(args, args.images_path)
+ helpers.protocol.set_aidl_version(args)
helpers.lxc.start(args)
def service_thread():
- IHardware.add_service(
- args, enableNFC, enableBluetooth, suspend, reboot, upgrade)
+ while not stopping:
+ IHardware.add_service(
+ args, enableNFC, enableBluetooth, suspend, reboot, upgrade)
+ global stopping
+ stopping = False
args.hardware_manager = threading.Thread(target=service_thread)
args.hardware_manager.start()
def stop(args):
+ global stopping
+ stopping = True
try:
if args.hardwareLoop:
args.hardwareLoop.quit()
from tools.interfaces import IUserMonitor
from tools.interfaces import IPlatform
+stopping = False
def start(args, unlocked_cb=None):
os.remove(desktop_file_path)
def service_thread():
- IUserMonitor.add_service(args, userUnlocked, packageStateChanged)
+ while not stopping:
+ IUserMonitor.add_service(args, userUnlocked, packageStateChanged)
+ global stopping
+ stopping = False
args.user_manager = threading.Thread(target=service_thread)
args.user_manager.start()
def stop(args):
+ global stopping
+ stopping = True
try:
if args.userMonitorLoop:
args.userMonitorLoop.quit()