Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified host/bins/cfc-0.1.0-x64.deb
Binary file not shown.
13 changes: 13 additions & 0 deletions host/src/pack/dpkg/etc/rc.civ
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ then
sed -i "s%/home/kylin/civ/.userdata/username.img%${HOME}/.userdata/${USER}.img%g" $HOME/.intel/.civ/penguin-peak.ini
sed -i "s%/home/kylin/Android/Pictures%${HOME}/Android/Pictures%g" $HOME/.intel/.civ/penguin-peak.ini
sed -i "s%/home/kylin/Android/Download%${HOME}/Android/Download%g" $HOME/.intel/.civ/penguin-peak.ini

SYS_MEM_SIZE=`cat /proc/meminfo | grep MemTotal | grep -v grep | awk '{print $2}'`
SYS_MEM_SIZE_G=$((SYS_MEM_SIZE/1024/1024))
# It may smaller than the real memory size since some reserved
# memory not exposed to OS.
if [ "$SYS_MEM_SIZE_G" -le "8" ];
then
echo "Macine with ~ 8G memory loaded, allocate 3G system memory to AVM."
sed -i "s%^size=4G$%size=3G%g" $HOME/.intel/.civ/penguin-peak.ini
else
# the size=4G is the default configuration in penguin-peak.ini, do nothing.
echo "Machine with large than 8G memory loaded, do nothing."
fi
fi

if [ ! -d $HOME/.userdata ]
Expand Down
73 changes: 53 additions & 20 deletions host/src/pack/dpkg/etc/rc.civ.post
Original file line number Diff line number Diff line change
@@ -1,32 +1,65 @@
#!/bin/sh -e
#!/bin/bash -e

sleep 10
CIV_PATH=/opt/civ/data/Release_Deb

${CIV_PATH}/scripts/stream &
function is_civ_ready() {
for i in {0..9}; do
timeout 1 adb connect vsock:3:5555 && break
done

for i in {0..9}; do
if [ "$(adb -s vsock:3:5555 shell getprop sys.boot_completed)" == "1" ] ; then
return 0
break
fi
sleep 1
done

return -1
}

function launch_lg_input_client()
{
# needs to set DISPLAY env for LG_B1_Client_input be able to
# start at boot.
export DISPLAY=:0
/opt/lg/bin/LG_B1_Client_input &
}

function balloon_civ()
{
#Balloon guest memory to 2048M on boot
if [ ! -z ${ENABLE_CIV_BALLOON} ]; then
/opt/cfc/mwc/bin/balloon_guest.sh 2048
fi
}

# needs to set DISPLAY env for LG_B1_Client_input be able to
# start at boot.
export DISPLAY=:0
/opt/lg/bin/LG_B1_Client_input &
function pause_civ()
{
if [ -z "$(pidof mwc_launcher)" ] && [ -z "$(pgrep -ax adb | grep -v "fork-server")" ] && [ -z "$(pidof startapp)" ]; then
# Pause CiV
/opt/cfc/mwc/bin/pause_civ.sh
# Kill adb server for power saving
adb kill-server
fi
}

# monitor share folder
/bin/bash /etc/sharefolder_monitor.sh &
#----------------- Main Process started from here --------------------

sleep 10

is_civ_ready || exit -1

${CIV_PATH}/scripts/stream &

launch_lg_input_client

/etc/sharefolder_monitor.sh &

balloon_civ

/opt/lg/bin/LG_B1_Client_clipboard guestClipboard:enable=true &

#Balloon guest memory to 2048M on boot
if [ ! -z ${ENABLE_CIV_BALLOON} ]; then
/opt/cfc/mwc/bin/balloon_guest.sh 2048
fi

#wait for android ready
sleep 20
# Pause CiV
if [ -z "$(pidof mwc_launcher)" ] && [ -z "$(pgrep -ax adb | grep -v "fork-server")" ]; then
/opt/cfc/mwc/bin/pause_civ.sh
fi
pause_civ

exit 0
4 changes: 2 additions & 2 deletions host/src/pack/dpkg/etc/sharefolder_monitor.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
MONITOR_FOLDER_1=$HOME"/Android/Download"
MONITOR_FOLDER_2=$HOME"/Android/Pictures"

FOLDER_1_UPDATE='adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/Download'
FOLDER_2_UPDATE='adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/Pictures'
FOLDER_1_UPDATE='adb -s vsock:3:5555 shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/Download'
FOLDER_2_UPDATE='adb -s vsock:3:5555 shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/Pictures'


function folder_notify() {
Expand Down
Binary file modified host/src/pack/dpkg/opt/cfc/mwc/bin/api_test
Binary file not shown.
12 changes: 7 additions & 5 deletions host/src/pack/dpkg/opt/cfc/mwc/bin/lg_launcher.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/bin/bash

NUM_PARAMS=$#
FOLDER_1_UPDATE='adb -s vsock:3:5555 shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/Download'
FOLDER_2_UPDATE='adb -s vsock:3:5555 shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/Pictures'

if [ "$NUM_PARAMS" -lt "2" ];
then
echo "Usage: lg_launcher.sh <appname> <activity> [app icon label]"
exit 1
fi

# Resume CiV
/opt/cfc/mwc/bin/resume_civ.sh

num_start_app=`ps aux | grep startapp | grep -v grep | wc -l`

if [ "$num_start_app" -lt "1" ];
then
/opt/cfc/mwc/bin/resume_civ.sh
if [ "$(adb get-state | grep "device" | awk '{print $1}')" != "device" ];
if ! systemctl --user is-active civ ;
then
/opt/lg/bin/startapp
fi
# Resume CiV
/opt/cfc/mwc/bin/resume_civ.sh
else
exit 1
fi
Expand All @@ -37,6 +37,8 @@ then
previous_app=`/opt/cfc/mwc/bin/msg_agent localhost 3000 GET_APP_LASTOPENED | grep "appname" | grep -v grep | sed 's/^appname: *\(.*\),.*$/\1/g'`
fi

$FOLDER_1_UPDATE
$FOLDER_2_UPDATE
/opt/cfc/mwc/bin/mwc_launcher localhost 3000 $@

echo "appname:$1, previous_app:$previous_app"
Expand Down
Binary file modified host/src/pack/dpkg/opt/cfc/mwc/bin/msg_agent
Binary file not shown.
Binary file modified host/src/pack/dpkg/opt/cfc/mwc/bin/mwc
Binary file not shown.
Binary file modified host/src/pack/dpkg/opt/cfc/mwc/bin/mwc_hostdaemon
Binary file not shown.
Binary file modified host/src/pack/dpkg/opt/cfc/mwc/bin/mwc_launcher
Binary file not shown.
14 changes: 11 additions & 3 deletions host/src/pack/dpkg/opt/cfc/mwc/bin/pause_civ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,18 @@ function pause_civ()
{
echo "Send QMP: stop"
local out
local i
echo "{ \"execute\": \"stop\"}" >&4
read -u 5 -t 1 -r out && echo "OUTPUT: $out"
read -u 5 -t 1 -r out && echo "OUTPUT: $out"
for i in {0..9}; do
read -u 5 -t 1 -r out
echo "OUTPUT: $out"
if [[ ${#out} -eq 15 && "${out:0:14}" == '{"return": {}}' ]]; then
return 0
fi
done
echo "Failed to Pause CiV!"
return -1
}

connect_qmp || exit -1
pause_civ
pause_civ || exit -1
2 changes: 1 addition & 1 deletion host/src/pack/dpkg/opt/cfc/mwc/bin/penguin-peak.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ path=/usr/bin/qemu-system-x86_64
size=4G

[vcpu]
num=2
num=4

[firmware]
type=unified
Expand Down
14 changes: 11 additions & 3 deletions host/src/pack/dpkg/opt/cfc/mwc/bin/resume_civ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,18 @@ function resume_civ()
{
echo "Send QMP: cont"
local out
local i
echo "{ \"execute\": \"cont\"}" >&4
read -u 5 -t 1 -r out && echo "OUTPUT: $out"
read -u 5 -t 1 -r out && echo "OUTPUT: $out"
for i in {0..9}; do
read -u 5 -t 1 -r out
echo "OUTPUT: $out"
if [[ ${#out} -eq 15 && "${out:0:14}" == '{"return": {}}' ]]; then
return 0
fi
done
echo "Failed to resume CiV!"
return -1
}

connect_qmp || exit -1
resume_civ
resume_civ || exit -1
Binary file modified host/src/pack/dpkg/opt/cfc/mwc/lib/libkydroid.so
Binary file not shown.
1 change: 0 additions & 1 deletion host/src/pack/pack-cfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cp ../pghost/mwc_hostdaemon dpkg/opt/cfc/mwc/bin/mwc_hostdaemon
cp ../pghost/mwc_launcher dpkg/opt/cfc/mwc/bin/mwc_launcher
cp ../pghost/loadapp.sh dpkg/opt/cfc/mwc/bin/loadapp.sh
cp ../pghost/killapp.sh dpkg/opt/cfc/mwc/bin/killapp.sh
cp ../pghost/lg_launcher.sh dpkg/opt/cfc/mwc/bin/lg_launcher.sh
cp ../pghost/closeapp.sh dpkg/opt/cfc/mwc/bin/closeapp.sh
cp ../pghost/api_test dpkg/opt/cfc/mwc/bin/api_test
cp ../pghost/libkydroid.so dpkg/opt/cfc/mwc/lib/libkydroid.so
Expand Down
1 change: 1 addition & 0 deletions host/src/pghost/connmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ void* Connmgr::conn_loop (void* data)
// TODO: broadcast the socket closed message.
cout << "Read from socket returns: " << read_counts << ", close the connection." << endl;
connmgr->running = 0;
connmgr->NotifyConnectionClose();
}
}
return 0;
Expand Down
69 changes: 0 additions & 69 deletions host/src/pghost/lg_launcher.sh

This file was deleted.

19 changes: 18 additions & 1 deletion host/src/pghost/vatclidaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,24 @@ int main (int argc, char **argv)
(!(epoll_events[i].events & EPOLLIN)))
{
cout << "epoll error, i: " << i << " fd: " << epoll_events[i].data.fd << endl;
close(epoll_events[i].data.fd);
int data_error_fd = epoll_events[i].data.fd;
if (clients.find(data_error_fd) != clients.end()) {
VatClient* vatclient = clients.at(data_error_fd);
cout << "Remove the scoket fd: " << data_error_fd << " client: " << static_cast<void *> (vatclient) << endl;
clients.erase(data_error_fd);
vatclient->CleanUp();
delete vatclient;
}
cout << "Remove the socket fd: " << data_error_fd << " from the epoll list." << endl;
int ret = epoll_ctl(epoll_fd, EPOLL_CTL_DEL, data_error_fd, NULL);
if (ret >= 0) {
cout << "Removed the error socket fd from epoll: " << data_error_fd << endl;
}
else {
cout << "Error to remove error scoket fd from epoll fds: " << data_error_fd << " return: " << ret << endl;
}
close (data_error_fd);

continue;
}
else if(listenfd == epoll_events[i].data.fd)
Expand Down
4 changes: 4 additions & 0 deletions host/src/pghost/vatclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ int VatClient::HandleEventSingleLG(Event* event)
case EVENT_NOTIFY_LG_APP_CLOSED:
running = 0;
break;
case EVENT_CONNECTION_CLOSED:
running = 0;
break;
default:
break;
}
Expand Down Expand Up @@ -497,6 +500,7 @@ void VatClient::CleanUp()
// Stop the instance and free the resources.
m_launcherconnmgr->connDown();
running = 0;
m_eventqueue->awaken();
pthread_join (m_client_loop, NULL);
delete m_eventqueue;
delete m_launcherconnmgr;
Expand Down