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(enum device_flags flags)
32 if (usb_control == DEVICE_OPS_STATUS_START)
35 usb_control = DEVICE_OPS_STATUS_START;
36 if (vconf_set_int(VCONFKEY_USB_CONTROL, usb_control) != 0)
37 _E("Failed to set vconf");
39 state = get_current_usb_physical_state();
40 usb_state_changed(state);
48 int control_stop(enum device_flags flags)
51 if (usb_control == DEVICE_OPS_STATUS_STOP)
54 usb_control = DEVICE_OPS_STATUS_STOP;
55 if (vconf_set_int(VCONFKEY_USB_CONTROL, usb_control) != 0)
56 _E("Failed to set vconf");
58 cur_mode = get_current_usb_mode();
59 if (cur_mode <= SET_USB_NONE) {
60 _E("Current usb mode is already none");
64 unset_client_mode(cur_mode, false);
66 launch_syspopup(USB_RESTRICT);
71 int control_status(void)
76 static void check_prev_control_status(void)
78 if (vconf_get_int(VCONFKEY_USB_CONTROL, &usb_control) != 0)
79 usb_control = DEVICE_OPS_STATUS_START;
82 static int usb_client_booting_done(void *data)
86 unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, usb_client_booting_done);
87 check_prev_control_status();
89 usbclient_init_booting_done();
91 state = get_current_usb_physical_state();
92 usb_state_changed(state);
100 void wait_until_booting_done(void)
102 register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, usb_client_booting_done);
103 usb_control = DEVICE_OPS_STATUS_STOP;