Add status icon for bluetooth 23/7823/1
authorsrimaldia <hariasti.srimaldia-1@jp.alps.com>
Thu, 22 Dec 2016 09:42:54 +0000 (18:42 +0900)
committersrimaldia <hariasti.srimaldia-1@jp.alps.com>
Thu, 22 Dec 2016 11:43:33 +0000 (20:43 +0900)
<?xml version="1.0"?> <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <policy context="default">
     <allow send_destination="org.agl.homescreen"/>
  </policy>
</busconfig>

Change-Id: I598fd21f66620a518d5cc4068c352c31961834bd
Signed-off-by: srimaldia <hariasti.srimaldia-1@jp.alps.com>
binding-bluetooth/bluetooth-api.c
binding-bluetooth/bluetooth-manager.c
binding-bluetooth/bluetooth-manager.h

index f7e2d9a..487a79f 100644 (file)
@@ -52,6 +52,8 @@ static void bt_power (struct afb_req request)
 
         if (0==ret)
         {
+
+            setHMIStatus(ACTIVE);
             (TRUE==power_value)?json_object_object_add (jresp, "power", json_object_new_string ("on"))
                                         : json_object_object_add (jresp, "power", json_object_new_string ("off"));
         }
@@ -72,6 +74,7 @@ static void bt_power (struct afb_req request)
                 return;
         }
         json_object_object_add (jresp, "power", json_object_new_string ("on"));
+        setHMIStatus(ACTIVE);
     }
 
     /* "?value=" parameter is "0" or "false" */
@@ -84,6 +87,7 @@ static void bt_power (struct afb_req request)
             }
 
         json_object_object_add (jresp, "power", json_object_new_string ("off"));
+        setHMIStatus(INACTIVE);
     }
     else
     {
index 4c49196..893760d 100644 (file)
@@ -743,5 +743,36 @@ int isHFPConnected(struct btd_device *addr) {
 
 }
 
+GError* setHMIStatus(enum btStates state) {
+
+    gchar *iconString = NULL;
+    GDBusConnection *connection;
+    GVariant *params = NULL;
+    GVariant *message = NULL;
+    GError *error = NULL;
+
+    if (state==INACTIVE) iconString = "qrc:/images/Status/HMI_Status_Bluetooth_Inactive-01.png";
+    else if (state==ACTIVE) iconString = "qrc:/images/Status/HMI_Status_Bluetooth_On-01.png";
+    else iconString = "qrc:/images/Status/HMI_Status_Bluetooth_Inactive-01.png";
+
+    connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+
+    params = g_variant_new("(is)", HOMESCREEN_BT_ICON_POSITION, iconString);
+
+    message = g_dbus_connection_call_sync(connection, HOMESCREEN_SERVICE,
+    HOMESCREEN_ICON_PATH, HOMESCREEN_ICON_INTERFACE, "setStatusIcon", params,
+            NULL, G_DBUS_CALL_FLAGS_NONE,
+            DBUS_REPLY_TIMEOUT, NULL, &error);
+
+    if (error) {
+        printf("error: %s\n", error->message);
+
+        return error;
+    } else {
+        return NULL;
+    }
+
+}
+
 /************************************** The End Of File **************************************/
 
index cb018b0..3602a78 100644 (file)
 #define AGENT_CONN                  (cli.agent_conn)
 #define OBEX_CONN                   (cli.obex_conn)
 
+#define HOMESCREEN_SERVICE                             "org.agl.homescreen"
+#define HOMESCREEN_ICON_INTERFACE              "org.agl.statusbar"
+#define HOMESCREEN_ICON_PATH                   "/StatusBar"
+#define HOMESCREEN_BT_ICON_POSITION            1
+
 #define DBUS_REPLY_TIMEOUT (120 * 1000)
 #define DBUS_REPLY_TIMEOUT_SHORT (10 * 1000)
 
@@ -115,6 +120,9 @@ typedef struct {
     GSList * device;
 } stBluetoothManage;
 
+enum btStates {INACTIVE, ACTIVE};
+
+
 int BluetoothManageInit(void);
 
 int adapter_set_powered(gboolean value);
@@ -136,6 +144,9 @@ int device_set_property(struct btd_device * addr, const char *property, const ch
 int isAVPConnected(struct btd_device *BDdevice);
 int isHFPConnected(struct btd_device *BDdevice);
 
+GError* setHMIStatus(enum btStates);
+
+
 #endif /* BLUETOOTH_MANAGER_H */