#!/bin/sh
#
# Completely turn off the USB Gadget interface:
#
# * If adbd is started then stop it.
# * If diagrebootapp is started then stop it.
# * If mbimd is started then stop it.
# * Make sure the USB Gadget interface is disabled.
#
# Copyright (c) 2017 Valeo
#

INTERFACE=android0

if pidof adbd > /dev/null
then
    start-stop-daemon --stop --quiet --name adbd
fi
if pidof diagrebootapp > /dev/null
then
    start-stop-daemon --stop --quiet --name diagrebootapp
fi
if pidof mbimd > /dev/null
then
    start-stop-daemon --stop --quiet --name mbimd
fi

# Make sure the USB gadget interface is disabled.
echo 0 > /sys/class/android_usb/$INTERFACE/enable

