/
ut_display.c
2063 lines (1690 loc) · 53.6 KB
/
ut_display.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <check.h>
#include <dbus-gmain.h> /* dbus_gmain_set_up_connection */
#include <glib.h>
#include <linux/input.h>
#include <stdbool.h>
#include "common.h"
/* Testing is done with stubs pretending presence of a generic display.
* Disabling libhybris related code saves us from declaring dummy stubs for
* hybris functions */
#ifdef ENABLE_HYBRIS
# undef ENABLE_HYBRIS
#endif
/* Tested module */
#include "../../modules/display.c"
/* Derived from get_display_type(), case DISPLAY_DISPLAY0 */
/* brightness_output.path */
#define STUB__BRIGHTNESS_OUTPUT_PATH \
DISPLAY_BACKLIGHT_PATH DISPLAY_DISPLAY0 \
DISPLAY_CABC_BRIGHTNESS_FILE
/* max_brightness_file */
#define STUB__MAX_BRIGHTNESS_FILE \
DISPLAY_BACKLIGHT_PATH DISPLAY_DISPLAY0 \
DISPLAY_CABC_MAX_BRIGHTNESS_FILE
/* cabc_mode_file */
#define STUB__CABC_MODE_FILE \
DISPLAY_BACKLIGHT_PATH DISPLAY_DISPLAY0 "/device" \
DISPLAY_CABC_MODE_FILE
/* cabc_available_modes_file */
#define STUB__CABC_AVAILABLE_MODES_FILE \
DISPLAY_BACKLIGHT_PATH DISPLAY_DISPLAY0 "/device" \
DISPLAY_CABC_AVAILABLE_MODES_FILE
/* hw_fading_output.path */
#define STUB__HW_FADING_OUTPUT_PATH \
DISPLAY_BACKLIGHT_PATH DISPLAY_DISPLAY0 DISPLAY_DEVICE_PATH \
DISPLAY_HW_DIMMING_FILE
/* high_brightness_mode_output.path */
#define STUB__HIGH_BRIGHTNESS_MODE_OUTPUT_PATH \
DISPLAY_BACKLIGHT_PATH DISPLAY_DISPLAY0 DISPLAY_DEVICE_PATH \
DISPLAY_HBM_FILE
/* low_power_mode_file */
#define STUB__LOW_POWER_MODE_FILE \
DISPLAY_BACKLIGHT_PATH DISPLAY_DISPLAY0 DISPLAY_DEVICE_PATH \
DISPLAY_LPM_FILE
/* ------------------------------------------------------------------------- *
* EXTERN STUBS
* ------------------------------------------------------------------------- */
/*
* Note that the following modules are linked instead of providing stubs:
*
* - datapipe.c
* - mce-lib.c
* - modetransition.c (only submode manipulation helpers are used)
*/
/*
* mce-conf.c stubs {{{1
*/
EXTERN_DUMMY_STUB (
gboolean, mce_conf_has_group, (const gchar *group));
typedef struct stub__mce_conf_get_int_item
{
const gchar *group;
const gchar *key;
gint value;
} stub__mce_conf_get_int_item_t;
static stub__mce_conf_get_int_item_t *stub__mce_conf_get_int_items = NULL;
EXTERN_STUB (
gint, mce_conf_get_int, (const gchar *group, const gchar *key,
const gint defaultval))
{
stub__mce_conf_get_int_item_t *const items =
stub__mce_conf_get_int_items;
for( int i = 0; items[i].key; ++i ) {
if( strcmp(group, items[i].group) == 0
&& strcmp(key, items[i].key) == 0 ) {
return items[i].value != INT_MAX ? items[i].value : defaultval;
}
}
ck_abort_msg("Key not handled: '%s'", key);
return 0;
}
typedef struct stub__mce_conf_get_string_item
{
const gchar *group;
const gchar *key;
const gchar *value;
} stub__mce_conf_get_string_item_t;
static stub__mce_conf_get_string_item_t *stub__mce_conf_get_string_items = NULL;
EXTERN_STUB (
gchar *, mce_conf_get_string, (const gchar *group, const gchar *key,
const gchar *defaultval))
{
stub__mce_conf_get_string_item_t *const items =
stub__mce_conf_get_string_items;
for( int i = 0; items[i].key; ++i ) {
if( strcmp(group, items[i].group) == 0
&& strcmp(key, items[i].key) == 0 ) {
return g_strdup(items[i].value ?: defaultval);
}
}
ck_abort_msg("Key not handled: '%s'", key);
return NULL;
}
EXTERN_DUMMY_STUB (
gchar **, mce_conf_get_string_list, (const gchar *group, const gchar *key,
gsize *length));
static void stub_mce_conf_setup_unchecked(void)
{
static stub__mce_conf_get_int_item_t int_items[] = {
{
MCE_CONF_DISPLAY_GROUP,
MCE_CONF_STEP_TIME_INCREASE,
250, /* multiplied by 20 (steps) gives 5000ms for
one-level brightness change (20% from 0-100
range) */
}, {
MCE_CONF_DISPLAY_GROUP,
MCE_CONF_STEP_TIME_DECREASE,
250,
}, {
MCE_CONF_DISPLAY_GROUP,
MCE_CONF_CONSTANT_TIME_INCREASE,
5000,
}, {
MCE_CONF_DISPLAY_GROUP,
MCE_CONF_CONSTANT_TIME_DECREASE,
5000,
}, {
NULL,
NULL,
INT_MAX,
}
};
stub__mce_conf_get_int_items = int_items;
static stub__mce_conf_get_string_item_t string_items[] = {
{
MCE_CONF_DISPLAY_GROUP,
MCE_CONF_BRIGHTNESS_INCREASE_POLICY,
NULL,
}, {
MCE_CONF_DISPLAY_GROUP,
MCE_CONF_BRIGHTNESS_DECREASE_POLICY,
NULL,
}, {
NULL,
NULL,
NULL,
}
};
stub__mce_conf_get_string_items = string_items;
}
static void stub_mce_conf_teardown_unchecked(void)
{
}
/*
* mce-setting.c stubs {{{1
*/
typedef struct stub__mce_setting_notifier_data
{
GConfClientNotifyFunc callback;
guint cb_id;
} stub__mce_setting_notifier_data_t;
static GHashTable *stub__mce_setting_notifiers = NULL;
EXTERN_STUB (
gboolean, mce_setting_notifier_add, (const gchar *path, const gchar *key,
const GConfClientNotifyFunc callback,
guint *cb_id))
{
(void)path;
typedef stub__mce_setting_notifier_data_t notifier_data_t;
GHashTable *const notifiers = stub__mce_setting_notifiers;
ck_assert(g_hash_table_lookup(notifiers, key) == NULL);
static guint max_id = 0;
++max_id;
notifier_data_t *const notifier = g_new(notifier_data_t, 1);
notifier->callback = callback;
notifier->cb_id = max_id;
g_hash_table_insert(notifiers, g_strdup(key), notifier);
*cb_id = notifier->cb_id;
return TRUE;
}
EXTERN_STUB (
void, mce_setting_notifier_remove, (gpointer cb_id, gpointer user_data))
{
(void)user_data;
typedef stub__mce_setting_notifier_data_t notifier_data_t;
GHashTable *const notifiers = stub__mce_setting_notifiers;
gboolean match_cb_id(gpointer key, gpointer value, gpointer user_data_)
{
(void)key;
(void)user_data_;
notifier_data_t *const notifier = (notifier_data_t *)value;
return notifier->cb_id == GPOINTER_TO_UINT(cb_id);
}
ck_assert_int_eq(1, g_hash_table_foreach_remove(notifiers, match_cb_id,
NULL));
}
typedef struct stub__mce_setting_get_int_item
{
const gchar *key;
gint value;
} stub__mce_setting_get_int_item_t;
static stub__mce_setting_get_int_item_t *stub__mce_setting_get_int_items = NULL;
EXTERN_STUB (
gboolean, mce_setting_get_int, (const gchar *const key, gint *value))
{
stub__mce_setting_get_int_item_t *const items =
stub__mce_setting_get_int_items;
for( int i = 0; items[i].key; ++i ) {
if( strcmp(key, items[i].key) == 0 ) {
*value = items[i].value;
return TRUE;
}
}
ck_abort_msg("Key not handled: '%s'", key);
return FALSE;
}
static gboolean stub__mce_setting_set_int(const gchar *key, gint value)
{
typedef stub__mce_setting_notifier_data_t notifier_data_t;
typedef stub__mce_setting_get_int_item_t item_t;
item_t *const items = stub__mce_setting_get_int_items;
GHashTable *const notifiers = stub__mce_setting_notifiers;
item_t *item = NULL;
for( int i = 0; items[i].key; ++i ) {
if( strcmp(key, items[i].key) == 0 ) {
item = items + i;
break;
}
}
ck_assert_msg(item != NULL, "Key not handled: '%s'", key);
item->value = value;
notifier_data_t *const notifier = g_hash_table_lookup(notifiers, key);
if( notifier != NULL ) {
GConfValue *const entry_value = gconf_value_new(GCONF_VALUE_INT);
gconf_value_set_int(entry_value, value);
GConfEntry *const entry = gconf_entry_new(key, entry_value);
(*notifier->callback)(NULL, notifier->cb_id, entry, NULL);
gconf_entry_free(entry);
gconf_value_free(entry_value);
}
ut_transition_recheck_schedule();
return TRUE;
}
#define STUB__MCE_GCONF_GET_INT_LIST_MAX_ITEMS (10)
typedef struct stub__mce_setting_get_int_list_item
{
const gchar *key;
gint value[STUB__MCE_GCONF_GET_INT_LIST_MAX_ITEMS]; /* INT_MAX term. */
} stub__mce_setting_get_int_list_item_t;
static stub__mce_setting_get_int_list_item_t *stub__mce_setting_get_int_list_items = NULL;
EXTERN_STUB (
gboolean, mce_setting_get_int_list, (const gchar *const key, GSList **values))
{
ck_assert(*values == NULL);
stub__mce_setting_get_int_list_item_t *const items =
stub__mce_setting_get_int_list_items;
for( int i = 0; items[i].key; ++i ) {
if( strcmp(key, items[i].key) != 0 )
continue;
for( int j = 0; items[i].value[j] != INT_MAX; ++j )
*values = g_slist_append(*values,
GINT_TO_POINTER(items[i].value[j]));
return TRUE;
}
ck_abort_msg("Key not handled: '%s'", key);
return FALSE;
}
typedef struct stub__mce_setting_get_bool_item
{
const gchar *key;
gboolean value;
} stub__mce_setting_get_bool_item_t;
static stub__mce_setting_get_bool_item_t *stub__mce_setting_get_bool_items = NULL;
EXTERN_STUB (
gboolean, mce_setting_get_bool, (const gchar *const key, gboolean *value))
{
stub__mce_setting_get_bool_item_t *const items =
stub__mce_setting_get_bool_items;
for( int i = 0; items[i].key; ++i ) {
if( strcmp(key, items[i].key) == 0 ) {
*value = items[i].value;
return TRUE;
}
}
ck_abort_msg("Key not handled: '%s'", key);
return FALSE;
}
static gboolean stub__mce_setting_set_bool(const gchar *key, gboolean value)
{
typedef stub__mce_setting_notifier_data_t notifier_data_t;
typedef stub__mce_setting_get_bool_item_t item_t;
item_t *const items = stub__mce_setting_get_bool_items;
GHashTable *const notifiers = stub__mce_setting_notifiers;
item_t *item = NULL;
for( int i = 0; items[i].key; ++i ) {
if( strcmp(key, items[i].key) == 0 ) {
item = items + i;
break;
}
}
ck_assert_msg(item != NULL, "Key not handled: '%s'", key);
item->value = value;
notifier_data_t *const notifier = g_hash_table_lookup(notifiers, key);
if( notifier != NULL ) {
GConfValue *const entry_value = gconf_value_new(GCONF_VALUE_BOOL);
gconf_value_set_bool(entry_value, value);
GConfEntry *const entry = gconf_entry_new(key, entry_value);
(*notifier->callback)(NULL, notifier->cb_id, entry, NULL);
gconf_entry_free(entry);
gconf_value_free(entry_value);
}
ut_transition_recheck_schedule();
return TRUE;
}
static void stub_mce_setting_setup_unchecked(void)
{
stub__mce_setting_notifiers = g_hash_table_new_full(g_str_hash,
g_str_equal,
g_free, g_free);
static stub__mce_setting_get_int_item_t int_items[] = {
{
MCE_SETTING_CPU_SCALING_GOVERNOR_PATH,
/* governor_conf default */
MCE_DEFAULT_CPU_SCALING_GOVERNOR,
}, {
MCE_SETTING_USE_AUTOSUSPEND_PATH,
/* suspend_policy default */
MCE_DEFAULT_USE_AUTOSUSPEND,
}, {
MCE_SETTING_DISPLAY_BRIGHTNESS_PATH,
/* real_disp_brightness default */
MCE_DEFAULT_DISPLAY_BRIGHTNESS,
}, {
MCE_SETTING_DISPLAY_BLANK_TIMEOUT_PATH,
/* disp_blank_timeout default */
MCE_DEFAULT_DISPLAY_BLANK_TIMEOUT,
}, {
MCE_SETTING_DISPLAY_NEVER_BLANK_PATH,
/* disp_never_blank default */
0,
}, {
MCE_SETTING_DISPLAY_ADAPTIVE_DIM_THRESHOLD_PATH,
/* adaptive_dimming_threshold default */
MCE_DEFAULT_DISPLAY_ADAPTIVE_DIM_THRESHOLD,
}, {
MCE_SETTING_DISPLAY_DIM_TIMEOUT_PATH,
/* disp_dim_timeout default */
MCE_DEFAULT_DISPLAY_DIM_TIMEOUT,
}, {
MCE_SETTING_BLANKING_INHIBIT_MODE_PATH,
/* blanking_inhibit_mode default*/
MCE_DEFAULT_BLANKING_INHIBIT_MODE,
}, {
NULL,
0,
}
};
stub__mce_setting_get_int_items = int_items;
static stub__mce_setting_get_int_list_item_t int_list_items[] = {
{
MCE_SETTING_DISPLAY_DIM_TIMEOUT_LIST_PATH,
{ 1, 5, 10, 15, 20, INT_MAX },
}, {
NULL,
{ INT_MAX },
}
};
stub__mce_setting_get_int_list_items = int_list_items;
static stub__mce_setting_get_bool_item_t bool_items[] = {
{
MCE_SETTING_DISPLAY_ADAPTIVE_DIMMING_PATH,
/* adaptive_dimming_enabled default */
MCE_DEFAULT_DISPLAY_ADAPTIVE_DIMMING,
}, {
MCE_SETTING_USE_LOW_POWER_MODE_PATH,
/* use_low_power_mode default */
FALSE,
}, {
NULL,
FALSE,
}
};
stub__mce_setting_get_bool_items = bool_items;
}
static void stub_mce_setting_teardown_unchecked(void)
{
g_hash_table_destroy(stub__mce_setting_notifiers),
stub__mce_setting_notifiers = NULL;
}
/*
* mce-io.c stubs {{{1
*/
#define STUB__MCE_FILE_IO_ITEM_DATA_MAX (64)
typedef struct stub__mce_io_item
{
const gchar *file;
gchar data[STUB__MCE_FILE_IO_ITEM_DATA_MAX];
gint write_count;
} stub__mce_io_item_t;
static stub__mce_io_item_t *stub__mce_io_items = NULL;
EXTERN_STUB (
gboolean, mce_read_string_from_file, (const gchar *const file, gchar **string))
{
stub__mce_io_item_t *const items =
stub__mce_io_items;
for( int i = 0; items[i].file; ++i ) {
if( strcmp(file, items[i].file) == 0 ) {
*string = g_strdup(items[i].data);
return TRUE;
}
}
ck_abort_msg("File not handled: '%s'", file);
return FALSE;
}
EXTERN_STUB (
gboolean, mce_write_string_to_file, (const gchar *const file,
const gchar *const string))
{
ck_assert(strlen(string) < STUB__MCE_FILE_IO_ITEM_DATA_MAX);
stub__mce_io_item_t *const items =
stub__mce_io_items;
for( int i = 0; items[i].file; ++i ) {
if( strcmp(file, items[i].file) == 0 ) {
const int nwritten = snprintf(items[i].data,
STUB__MCE_FILE_IO_ITEM_DATA_MAX,
"%s", string);
ck_assert(nwritten < STUB__MCE_FILE_IO_ITEM_DATA_MAX);
++items[i].write_count;
ut_transition_recheck_schedule();
return TRUE;
}
}
ck_abort_msg("File not handled: '%s'", file);
return FALSE;
}
EXTERN_STUB (
gboolean, mce_read_number_string_from_file, (const gchar *const file,
gulong *number, FILE **fp,
gboolean rewind_file,
gboolean close_on_exit))
{
ck_assert(fp == NULL);
ck_assert(rewind_file == FALSE);
ck_assert(close_on_exit == TRUE);
stub__mce_io_item_t *const items =
stub__mce_io_items;
for( int i = 0; items[i].file; ++i ) {
if( strcmp(file, items[i].file) == 0 ) {
*number = atol(items[i].data);
return TRUE;
}
}
ck_abort_msg("File not handled: '%s'", file);
return FALSE;
}
EXTERN_STUB (
gboolean, mce_write_number_string_to_file, (output_state_t *output,
const gulong number))
{
ck_assert(output->truncate_file == TRUE);
ck_assert(output->path != NULL);
ck_assert(output->file == NULL);
stub__mce_io_item_t *const items =
stub__mce_io_items;
for( int i = 0; items[i].file; ++i ) {
if( strcmp(output->path, items[i].file) == 0 ) {
const int nwritten = snprintf(items[i].data,
STUB__MCE_FILE_IO_ITEM_DATA_MAX,
"%lu", number);
ck_assert(nwritten < STUB__MCE_FILE_IO_ITEM_DATA_MAX);
++items[i].write_count;
ut_transition_recheck_schedule();
return TRUE;
}
}
ck_abort_msg("File not handled: '%s'", output->path);
return FALSE;
}
EXTERN_STUB (
void, mce_close_output, (output_state_t *output))
{
output->file = 0;
}
static gint stub__mce_io_write_count(const gchar *file)
{
stub__mce_io_item_t *const items =
stub__mce_io_items;
for( int i = 0; items[i].file; ++i ) {
if( strcmp(file, items[i].file) == 0 ) {
return items[i].write_count;
}
}
ck_abort_msg("File not handled: '%s'", file);
return 0;
}
static void stub_mce_io_setup_unchecked(void)
{
static stub__mce_io_item_t items[] = {
{
/* cabc_available_modes_file */
STUB__CABC_AVAILABLE_MODES_FILE,
"",
0,
}, {
/* cabc_mode_file */
STUB__CABC_MODE_FILE,
"",
0,
}, {
/* max_brightness_file */
STUB__MAX_BRIGHTNESS_FILE,
"100",
0,
}, {
/* brightness_output.path */
STUB__BRIGHTNESS_OUTPUT_PATH,
"20",
0,
}, {
/* hw_fading_output.path */
STUB__HW_FADING_OUTPUT_PATH,
"",
0,
}, {
/* high_brightness_mode_output.path */
STUB__HIGH_BRIGHTNESS_MODE_OUTPUT_PATH,
"",
0,
}, {
/* low_power_mode_file */
STUB__LOW_POWER_MODE_FILE,
"",
0,
}, {
NULL,
"",
0,
}
};
stub__mce_io_items = items;
}
static void stub_mce_io_teardown_unchecked(void)
{
}
/*
* mce-dbus.c stubs {{{1
*/
EXTERN_DUMMY_STUB (
DBusMessage *, dbus_new_method_reply, (DBusMessage *const message));
EXTERN_DUMMY_STUB (
DBusMessage *, dbus_new_signal, (const gchar *const path,
const gchar *const interface,
const gchar *const name));
EXTERN_DUMMY_STUB (
gboolean, dbus_send_message, (DBusMessage *const msg));
EXTERN_DUMMY_STUB (
gboolean, dbus_send, (const gchar *const service, const gchar *const path,
const gchar *const interface, const gchar *const name,
DBusPendingCallNotifyFunction callback,
int first_arg_type, ...));
static DBusConnection *stub__dbus_connection = NULL;
EXTERN_STUB (
DBusConnection *, dbus_connection_get, (void))
{
if( !stub__dbus_connection ) {
DBusBusType bus_type = DBUS_BUS_SYSTEM;
DBusError error = DBUS_ERROR_INIT;
if( (stub__dbus_connection = dbus_bus_get(bus_type,
&error)) == NULL ) {
printf("%s: Failed to open connection to message bus; %s",
G_STRFUNC, error.message);
dbus_error_free(&error);
abort();
}
dbus_connection_setup_with_g_main(stub__dbus_connection, NULL);
}
return dbus_connection_ref(stub__dbus_connection);
}
EXTERN_STUB (
gconstpointer, mce_dbus_handler_add, (const gchar *const interface,
const gchar *const name,
const gchar *const rules,
const guint type,
gboolean (*callback)(DBusMessage *const msg)))
{
(void)interface;
(void)name;
(void)rules;
(void)type;
(void)callback;
return (gconstpointer)1;
}
EXTERN_DUMMY_STUB (
gboolean, mce_dbus_is_owner_monitored, (const gchar *service,
GSList *monitor_list));
EXTERN_STUB (
gssize, mce_dbus_owner_monitor_add, (const gchar *service,
gboolean (*callback)(DBusMessage *const msg),
GSList **monitor_list,
gssize max_num))
{
(void)callback;
gssize retval = -1;
gssize num;
/* If service or monitor_list is NULL, fail */
ck_assert(service != NULL);
ck_assert(monitor_list != NULL);
/* If the service is already in the list, we're done */
if( g_slist_find_custom(*monitor_list, service,
(GCompareFunc)g_strcmp0) != NULL ) {
retval = 0;
goto EXIT;
}
/* If the service isn't in the list, and the list already
* contains max_num elements, bail out
*/
if( (num = g_slist_length(*monitor_list)) == max_num )
goto EXIT;
*monitor_list = g_slist_prepend(*monitor_list, g_strdup(service));
retval = num + 1;
EXIT:
return retval;
}
EXTERN_STUB (
gssize, mce_dbus_owner_monitor_remove, (const gchar *service,
GSList **monitor_list))
{
gssize retval = -1;
GSList *tmp;
/* If service or monitor_list is NULL, fail */
ck_assert(service != NULL);
ck_assert(monitor_list != NULL);
/* If the service is not in the list, fail */
if( (tmp = g_slist_find_custom(*monitor_list, service,
(GCompareFunc)g_strcmp0)) == NULL)
goto EXIT;
g_free(tmp->data);
*monitor_list = g_slist_remove(*monitor_list, tmp->data);
retval = g_slist_length(*monitor_list);
EXIT:
return retval;
}
EXTERN_STUB (
void, mce_dbus_owner_monitor_remove_all, (GSList **monitor_list))
{
void free_foreach(gpointer handler, gpointer user_data)
{
(void)user_data;
g_free(handler);
}
if( (monitor_list != NULL) && (*monitor_list != NULL) ) {
g_slist_foreach(*monitor_list, (GFunc)free_foreach, NULL);
g_slist_free(*monitor_list);
*monitor_list = NULL;
}
}
/*
* mce-sensorfw.c stubs {{{1
*/
EXTERN_STUB (
void, mce_sensorfw_suspend, (void))
{
}
EXTERN_STUB (
void, mce_sensorfw_resume, (void))
{
}
EXTERN_STUB (
void, mce_sensorfw_orient_enable, (void))
{
}
EXTERN_STUB (
void, mce_sensorfw_orient_disable, (void))
{
}
EXTERN_STUB (
void, mce_sensorfw_orient_set_notify, (void (*cb)(int state)))
{
(void)cb;
}
/*
* tklock.c stubs {{{1
*/
EXTERN_STUB (
void, mce_tklock_show_tklock_ui, (void))
{
/* empty */
}
/*
* libwakelock.c stubs {{{1
*/
static GHashTable *stub__wakelock_locks = NULL;
EXTERN_STUB (
void, wakelock_lock, (const char *name, long long ns))
{
ck_assert(!g_hash_table_lookup_extended(stub__wakelock_locks, name,
NULL, NULL));
ck_assert_int_eq(ns, -1);
g_hash_table_insert(stub__wakelock_locks,
g_strdup(name), NULL);
ut_transition_recheck_schedule();
}
EXTERN_STUB (
void, wakelock_unlock, (const char *name))
{
ck_assert(g_hash_table_lookup_extended(stub__wakelock_locks, name,
NULL, NULL));
g_hash_table_remove(stub__wakelock_locks, name);
ut_transition_recheck_schedule();
}
#if 0
static bool stub__wakelock_locked(const char *name)
{
if( name == NULL )
return g_hash_table_size(stub__wakelock_locks) != 0;
else
return g_hash_table_lookup_extended(stub__wakelock_locks, name,
NULL, NULL);
}
#endif
static gboolean stub__waitfb_event_cb(gpointer data);
EXTERN_STUB (
void, wakelock_allow_suspend, (void))
{
g_idle_add(stub__waitfb_event_cb, GINT_TO_POINTER(TRUE));
}
EXTERN_STUB (
void, wakelock_block_suspend, (void))
{
g_idle_add(stub__waitfb_event_cb, GINT_TO_POINTER(FALSE));
}
/* Stub init/cleanup */
static void stub_wakelock_setup_unchecked(void)
{
stub__wakelock_locks = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
}
static void stub_wakelock_teardown_unchecked(void)
{
g_hash_table_destroy(stub__wakelock_locks), stub__wakelock_locks = NULL;
}
/*
* filewatcher.c stubs {{{1
*/
EXTERN_DUMMY_STUB (
filewatcher_t *, filewatcher_create, (const char *dirpath,
const char *filename,
filewatcher_changed_fn change_cb,
gpointer user_data,
GDestroyNotify delete_cb));
EXTERN_DUMMY_STUB (
void, filewatcher_delete, (filewatcher_t *self));
EXTERN_DUMMY_STUB (
void, filewatcher_force_trigger, (filewatcher_t *self));
/*
* }}}
*/
/* ------------------------------------------------------------------------- *
* LOCAL STUBS
* ------------------------------------------------------------------------- */
/*
* Display HW related stubs {{{1
*/
LOCAL_DUMMY_STUB (
gboolean, get_brightness_controls, (const gchar *dirpath,
char **setpath, char **maxpath));
LOCAL_DUMMY_STUB (
gboolean, get_display_type_from_config, (display_type_t *display_type));
LOCAL_DUMMY_STUB (
gboolean, get_display_type_from_sysfs_probe, (display_type_t *display_type));
LOCAL_DUMMY_STUB (
gboolean, get_display_type_from_hybris, (display_type_t *display_type));
/*
* Derived from get_display_type(), case DISPLAY_DISPLAY0
*/
LOCAL_STUB (
display_type_t, get_display_type, (void))
{
static display_type_t display_type = DISPLAY_TYPE_UNSET;
/* If we have the display type already, return it */
if( display_type != DISPLAY_TYPE_UNSET )
goto EXIT;
display_type = DISPLAY_TYPE_DISPLAY0;
brightness_output.path = g_strdup(STUB__BRIGHTNESS_OUTPUT_PATH);
max_brightness_file = g_strdup(STUB__MAX_BRIGHTNESS_FILE);
cabc_mode_file = g_strdup(STUB__CABC_MODE_FILE);
cabc_available_modes_file = g_strdup(STUB__CABC_AVAILABLE_MODES_FILE);
hw_fading_output.path = g_strdup(STUB__HW_FADING_OUTPUT_PATH);
high_brightness_mode_output.path =
g_strdup(STUB__HIGH_BRIGHTNESS_MODE_OUTPUT_PATH);
low_power_mode_file = g_strdup(STUB__LOW_POWER_MODE_FILE);
cabc_supported = TRUE;
hw_fading_supported = TRUE;
high_brightness_mode_supported = TRUE;
low_power_mode_supported = TRUE;
backlight_ioctl_hook = backlight_ioctl_default;
EXIT:
return display_type;
}
#ifdef USE_LIBCAL
# error "FIXME: implement stub for update_display_timers()"
#endif
static int stub__backlight_ioctl_value_set = FB_BLANK_UNBLANK;
LOCAL_STUB (
gboolean, backlight_ioctl_default, (int value))
{
stub__backlight_ioctl_value_set = value;
ut_transition_recheck_schedule();
return TRUE;
}
/*
* CPU governor related stubs {{{1
*/
governor_setting_t *stub__governor_settings_default = NULL;
governor_setting_t *stub__governor_settings_interactive = NULL;
/* That one set with governor_apply_setting */