From 02120705f8d6b6888458e535d4a50be47c303c8d Mon Sep 17 00:00:00 2001
From: Stefan Schmidt <stefan.schmidt@huawei.com>
Date: Tue, 19 Jul 2022 14:02:10 +0200
Subject: [PATCH] oniro-image-common.inc: introduce modem/usbmodem
 MACHINE_FEATURES

Enable a modem/usbmodem MACHINE_FEATURE to install the needed packages
for NetworkManager and ModemManager in the image. Also enabling the MM
PACKAGECONFIG for NetworkManager to build the needed package.

Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
---
 .../recipes-core/images/oniro-image-common.inc       | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/meta-oniro-core/recipes-core/images/oniro-image-common.inc b/meta-oniro-core/recipes-core/images/oniro-image-common.inc
index 0ac0ab13..50401f7f 100644
--- a/meta-oniro-core/recipes-core/images/oniro-image-common.inc
+++ b/meta-oniro-core/recipes-core/images/oniro-image-common.inc
@@ -20,3 +20,15 @@ IMAGE_INSTALL:append = "\
 			"
 
 IMAGE_INSTALL:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'optee', 'optee-client', '', d)} "
+
+# If the machine has a cellular modem it can set MACHINE_FEATURES+=modem to
+# enable build-in support in NetworkManager as well as ading needed packages to
+# the image.
+# In the special case of a USB cellular modem there is often the addtionial need
+# for the usb-modeswitch package to switch between mass storage and modem.
+
+PACKAGECONFIG:append:pn-networkmanager = " \
+        ${@bb.utils.contains('MACHINE_FEATURES', 'modem', ' modemmanager ', '', d)} \
+"
+IMAGE_INSTALL:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'modem', 'networkmanager-wwan modemmanager', '', d)} "
+IMAGE_INSTALL:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'usbmodem', 'usb-modeswitch', '', d)} "
-- 
GitLab