SmartDeviceLink WEB_VIEW by javascript suites を試す

## まず結果。こんな感じで動きます。

![Generic-HMI.gif](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/57516/3bb0683a-e933-7b91-893e-8f0201b2325a.gif)

## Docker はてきとうに用意してね

```bash
$ docker run -d -p 12345:12345 -p 8080:8080 -p 8087:8087 -p 3001:3001 --name core smartdevicelink/core:latest
```

これで、http://localhost:8080 でひらくのは、sdl_hmi で、なんとなくカーナビっぽいHMIなんだけど、実験つかいにくいというか古いUI.

というか、docker hub で build されたイメージが、2017年とかでふるかった。orz

てことで

```bash
$ git clone https://github.com/smartdevicelink/sdl_core_docker.git --depth=1
$ cd sdl_core_docker
$ cd master
$ docker build .
```
エラー出た。めんどうだ。

## Generic HMI をためす

手抜きでごめん。ぼくは、Windows 10 の WSL な Ubuntu でためした。
Mac でも、普通に node 環境があれば、動くんじゃないかなと思う。

ほんとうは、上記 docker といっしょに環境作って一撃で動かすとかしたいけど、今は時間がなくてごめん。

sdl_hmi が Ford っぽいやつ
generic_hmi が manticore っぽいやつ

```bash
$ git clone https://github.com/smartdevicelink/generic_hmi.git --depth=1

$ git submodule init # deploy_server.sh ないでもやってくれてそう
$ git submodule update # deploy_server.sh ないでもやってくれてそう

$ nvm use 12
$ npm install
$ npm run build

$ ./deploy_server.sh
```

ブラウザで build/index.html をひらく

WEBSOCKET_PORT = 8081
FILESERVER_PORT = 8082
がうごくよ


3rd_party の make install がとまっている感じ

127.0.0.1 と localhost の関係であれする


smartdevlicelink.ini の 127.0.0.1 が、docker だと外からバインドできない。0.0.0.0 がいいかな
sdl_core port 2020 が、websocket for webengine ぽい

```Dockerfile
FROM ubuntu:18.04

ENV CORE_BRANCH=master \
    CORE_CWD=/usr/sdl_core \
    BUILD_CWD=/usr/sdl_build

RUN apt-get update && apt-get install -y --no-install-recommends \
        git \
        ca-certificates \
        sudo

RUN git clone --depth 1 -b $CORE_BRANCH https://github.com/smartdevicelink/sdl_core.git $CORE_CWD   
    
ENV DEBCONF_NOWARNINGS yes

RUN apt-get install -y --no-install-recommends \
    cmake build-essential sqlite3 libsqlite3-dev libssl1.0-dev libssl1.0.0 libusb-1.0-0-dev libudev-dev libgtest-dev libbluetooth3 libbluetooth-dev bluez-tools libpulse-dev python3-pip python3-setuptools

WORKDIR $CORE_CWD

RUN git submodule init \
    && git submodule update

RUN mkdir $BUILD_CWD
WORKDIR  $BUILD_CWD

RUN cmake -DENABLE_HMI_PTU_DECRYPTION=OFF $CORE_CWD \
    && make install-3rd_party \
    && make -j `nproc` install


# Starting SmartDeviceLink Core
# /usr/sdl_build/bin/smartDeviceLinkCore: error while loading shared libraries: libexpat.so: cannot open shared object file: No such file or directory
#
# why ?
#
WORKDIR ${BUILD_CWD}/src/3rd_party/expat-2.1.0/
RUN make install

RUN ldconfig

WORKDIR ${BUILD_CWD}/bin


# TODO: change 127.0.0.1 to 0.0.0.0 in smartdevicelink.ini
RUN sed -i -e 's/ServerAddress = 127.0.0.1/ServerAddress = 0.0.0.0/' smartDeviceLink.ini

# Expose the following ports
#   2020: Expose WebEngine Web Socket port
#   3001: Exposes Core's file system
#   8087:  Expose SDL Core's Web Socket port. Used to comunicate with the HMI
#   12345: Expose SDL Core's primary port. Used to communicate with the SDL Core instance over TCP
EXPOSE 2020 3001 8087 12345

# Run the start script that will launch SDL Core!
ENTRYPOINT $PWD/start.sh

```

docker build -t sdlcore .
docker run -d -p 12345:12345 -p 8087:8087 -p 3001:3001 -p 2020:2020 --name sdlcore sdlcore 

apt install vim less iproute2

docker exec -it sdlcore bash
apt install vim
vi smartdevicelink.ini

ip address show



3285 DEBUG [07:15:17,404][RPCServiceImpl] Conversion result: {	"info" : "WEB_VIEW AppHmiType is absent in application policies, because they are empty",
	"resultCode" : "DISALLOWED",
	"success" : false
}


https://github.com/smartdevicelink/sdl_core/blob/master/src/appMain/sdl_preloaded_pt.json#L2273

Change the contents of that array to include this instead: [“Base-4”, “Location-1", “Notifications”, “DrivingCharacteristics-3", “VehicleInfo-3”, “PropriataryData-1", “PropriataryData-2”, “ProprietaryData-3", “Emergency-1”, “Navigation-1", “Base-6”, “OnKeyboardInputOnlyGroup”, “OnTouchEventOnlyGroup”, “DiagnosticMessageOnly”, “DataConsent-2”, “BaseBeforeDataConsent”, “SendLocation”, “WayPoints”, “BackgroundAPT”]

also
"appHMIType: [" WEB_VIEW "] to the app_policies.

https://smartdevicelink.com/en/guides/core/migrating-to-newer-sdl-versions/migrating-sdl-core-61-to-70/


At the time of this proposal being in review, 
a set of driver distraction rules are being created and proposed to have 
the possibility to enable 3rd party using the projection mode in the future. 
The following bullet points are items that will be described further in the ruleset:

- minimum font size
- minimum contrast between font and background
- min/max brightness (for day and night mode)
- number of buttons
- minimum size of a button
- no customized keyboard
- no video playback (exceptions in standstill per countries)
- NHTSA related guidelines
    - Amount of text (button and text fields)
    - number of lines of text
    - Complexity of use cases (number of steps to fulfill a use case)

More items may be included in the ruleset as they become Driver Distraction affected.



/generic_hmi/src/js/Flags.js
https://sdl-webengine-app-store-example.s3.amazonaws.com/app-directory.json

![Something went wrong]()