4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include "usb-client.h"
22 #include "core/device-notifier.h"
24 #define VCONFKEY_USB_CONTROL "db/private/usb/usb_control"
26 static int usb_control = DEVICE_OPS_STATUS_START;
28 int control_start(void)
30 if (usb_control == DEVICE_OPS_STATUS_START)
33 usb_control = DEVICE_OPS_STATUS_START;
34 if (vconf_set_int(VCONFKEY_USB_CONTROL, usb_control) != 0)
35 _E("Failed to set vconf");
37 if (check_current_usb_state() > 0)
43 int control_stop(void)
46 if (usb_control == DEVICE_OPS_STATUS_STOP)
49 usb_control = DEVICE_OPS_STATUS_STOP;
50 if (vconf_set_int(VCONFKEY_USB_CONTROL, usb_control) != 0)
51 _E("Failed to set vconf");
53 cur_mode = get_current_usb_mode();
54 if (cur_mode <= SET_USB_NONE) {
55 _E("Current usb mode is already none");
59 unset_client_mode(cur_mode, false);
61 launch_syspopup(USB_RESTRICT);
66 int control_status(void)
71 static void check_prev_control_status(void)
73 if (vconf_get_int(VCONFKEY_USB_CONTROL, &usb_control) != 0)
74 usb_control = DEVICE_OPS_STATUS_START;
77 static int usb_client_booting_done(void *data)
79 unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, usb_client_booting_done);
80 check_prev_control_status();
82 usbclient_init_booting_done();
84 if (check_current_usb_state() > 0)
90 void wait_until_booting_done(void)
92 register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, usb_client_booting_done);
93 usb_control = DEVICE_OPS_STATUS_STOP;