jikjoo / Bangul_webOS

"차량용 스마트 펫케어 서비스 : 방울이가타고있어요"의 차량용 소프트웨어입니다
MIT License
2 stars 1 forks source link

webOS createToast 알림에 아이콘 적용 안됨. #36

Open jikjoo opened 4 years ago

jikjoo commented 4 years ago
  1. import Icon from '../../../resources/icon.png'
    iconUrl : Icon
  2. iconUrl : 'file:///media/developer/apps/usr/palm/applications/com.bangul.app.webos/icon.png'
  3. NotificationService.cpp networkplugin.cpp iconUrl : '/media/developer/apps/usr/palm/applications/com.bangul.app.webos/icon.png'
  4. ambulanceApp iconUrl : icon.png

시도해봤는데, 모두 안됐음.

jikjoo commented 4 years ago

luna-send -n 1 -f -a com.webos.test.app luna://com.webos.notification/createToast '{"sourceId":"com.webos.test.app","message":"hello world", "iconUrl":"/usr/palm/applications/com.palm.app.settings/icon.png"}' 를 해봤는데, 아이콘이 바뀌었음. 이번에도 requiredPermissions 문제인거 같음.

jikjoo commented 4 years ago

ls-monitor로 확인해봤는데


2408.792 TX  call       4               com.webos.lunasend-1058 (QVeQDfjE)      com.webos.notification (nO0VDDG6)
com.banugl.app.webos            //createToast   «{"sourceId":"com.banugl.app.webos","message":"hello world","iconUrl":"/media/developer/apps/usr/palm/applications/com.bangul.app.webos/icon.png"}»
2408.792 RX call        4               com.webos.notification (nO0VDDG6)       com.webos.lunasend-1058 (QVeQDfjE)
com.banugl.app.webos            //createToast   «{"sourceId":"com.banugl.app.webos","message":"hello world","iconUrl":"/media/developer/apps/usr/palm/applications/com.bangul.app.webos/icon.png"}»
2408.792 TX  return     36              com.webos.notification (nO0VDDG6)               com.webos.surfacemanager (4U7ietXj)                                 «{"returnValue":true,"message":"hello world","iconPath":"/usr/palm/notificationmgr/images/toast-notification-icon.png","type":"standard","title":"","isCradleReq":false,"sourceId":"com.banugl.app.webos","timesource":"ntp","timestamp":"1598538666539","onlyToast":true,"isSysReq":false,"schedule":{"expire":1601130666},"iconUrl":"file:///usr/palm/notificationmgr/images/toast-notification-icon.png","action":{}}»
2408.792 TX  return     4               com.webos.notification (nO0VDDG6)               com.webos.lunasend-1058 (QVeQDfjE)                                  «{"toastId":"com.banugl.app.webos-1598538666539","returnValue":true}»
2408.792 RX return      36              com.webos.surfacemanager (4U7ietXj)             com.webos.notification (nO0VDDG6)                                   «{"returnValue":true,"message":"hello world","iconPath":"/usr/palm/notificationmgr/images/toast-notification-icon.png","type":"standard","title":"","isCradleReq":false,"sourceId":"com.banugl.app.webos","timesource":"ntp","timestamp":"1598538666539","onlyToast":true,"isSysReq":false,"schedule":{"expire":1601130666},"iconUrl":"file:///usr/palm/notificationmgr/images/toast-notification-icon.png","action":{}}»
2408.792 RX return      4               com.webos.lunasend-1058 (QVeQDfjE)              com.webos.notification (nO0VDDG6)                                   «{"toastId":"com.banugl.app.webos-1598538666539","returnValue":true}»
2408.793 TX  call       6               com.webos.lunasend-1058 (QVeQDfjE)              com.webos.notification (nO0VDDG6)
/com/palm/luna/private/cancel   «{"token":4}»
2408.793 RX call        6               com.webos.notification (nO0VDDG6)               com.webos.lunasend-1058 (QVeQDfjE)
/com/palm/luna/private/cancel   «{"token":4}»

어떤 권한이 필요한지 몰라서, 일단 "requiredPermissions" : ["all"] 로 바꿈

jikjoo commented 4 years ago

어떤 권한이 필요한지 몰라서, 일단 "requiredPermissions" : ["all"] 로 바꿈

그래도 안되네

jikjoo commented 4 years ago

com.webos 혹은 com.palm으로 시작되어야 아이콘이 바뀜. luna-send -n 1 -f -a com.webos.abcdef luna://com.webos.notification/createToast '{"sourceId":"com.webos.app.abcdef","message":"hello world", "iconUrl":"/usr/palm/applications/com.webos.app.test.youtube/icon.png"}'

https://github.com/webosose/notificationmgr/blob/0936da1e9a529ccb0780d9b20f8152d7191f76c1/src/Settings.cpp#L377

jikjoo commented 4 years ago

https://github.com/webosose/notificationmgr/blob/master/src/NotificationService.cpp

        // 위에서 언급한 com.webos / com.palm / com.lge 으로 시작하는것만 iconUrl 작동함.
    if(Settings::instance()->isPrivilegedSource(caller))
    {
        iconPath = request["iconUrl"].asString();
    }
    else
    {
        iconPath = AppList::instance()->getIcon(sourceId); 
//getIcon은 sourceId가 palm://com.webos.applicationManager/listApps에 존재하는지 보고 folderPath+"/icon.png"
    }

    if(iconPath.length() != 0 && Utils::verifyFileExist(iconPath.c_str()))
    {
        postCreateToast.put("iconUrl", "file://"+iconPath);
        postCreateToast.put("iconPath", iconPath);
    }
    else
    {    //iconPath가 존재하지 않으면, defaultIcon으로 감
        postCreateToast.put("iconUrl", "file://"+ Settings::instance()->getDefaultIcon("toast"));
        postCreateToast.put("iconPath", Settings::instance()->getDefaultIcon("toast"));
    }
jikjoo commented 4 years ago

webOS 커뮤니티에 질문 남김 https://forum.webosose.org/t/cannot-change-icon-in-toast-notification-except-privileged-app/1181