Created
February 10, 2016 04:33
-
-
Save moetayuko/2648b42e1f4436d979e3 to your computer and use it in GitHub Desktop.
che1-cl10 official lolipop lights hal decomplie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This file has been generated by the Hex-Rays decompiler. | |
| Copyright (c) 2007-2015 Hex-Rays <info@hex-rays.com> | |
| Detected compiler: GNU C++ | |
| */ | |
| #include <defs.h> | |
| //------------------------------------------------------------------------- | |
| // Function declarations | |
| // int __fastcall _cxa_finalize(_DWORD); weak | |
| // int __fastcall pthread_mutex_init(_DWORD, _DWORD); weak | |
| // void free(void *); | |
| // int _android_log_print(_DWORD, _DWORD, const char *, ...); weak | |
| // int __fastcall oem_qmi_common_stream_from_modem_len(_DWORD, _DWORD, _DWORD, _DWORD); weak | |
| // int __fastcall pthread_mutex_lock(_DWORD); weak | |
| // int __fastcall pthread_mutex_unlock(_DWORD); weak | |
| // int strcmp(const char *, const char *); | |
| // int __fastcall pthread_once(_DWORD, _DWORD); weak | |
| // void *malloc(size_t); | |
| // void *memset(void *, int, size_t); | |
| // int open(void); weak | |
| // int snprintf(char *, size_t, const char *, ...); | |
| // int __fastcall write(_DWORD, _DWORD, _DWORD); weak | |
| // int __fastcall close(_DWORD); weak | |
| // int _errno(void); weak | |
| // int __fastcall _stack_chk_fail(_DWORD); weak | |
| int sub_944(); | |
| int (*__fastcall sub_964(int (*result)(void)))(void); | |
| int init_globals(); // weak | |
| int __fastcall sub_A08(void *a1); | |
| signed int __fastcall sub_A14(int a1, int a2); | |
| signed int __fastcall sub_AA8(int a1); | |
| int __fastcall sub_AC4(int a1, int a2); | |
| int __fastcall sub_B0C(int a1, int a2); | |
| int __fastcall sub_B40(int a1, int a2); | |
| signed int __fastcall sub_B74(int a1, const char *a2, _DWORD *a3); | |
| int __fastcall sub_C9C(int a1, int a2); | |
| signed int __fastcall sub_D3C(int a1, _BYTE *a2); | |
| signed int __fastcall sub_D70(int a1, _DWORD *a2); | |
| int sub_DC4(); // weak | |
| int __fastcall j_j_pthread_mutex_init(int a1, int a2); | |
| int __fastcall j_pthread_mutex_init(int a1, int a2); | |
| //------------------------------------------------------------------------- | |
| // Data declarations | |
| void *off_3000 = &off_3000; // weak | |
| int dword_3088; // weak | |
| _UNKNOWN unk_308C; // weak | |
| _UNKNOWN unk_3090; // weak | |
| _UNKNOWN unk_3094; // weak | |
| _UNKNOWN unk_3098; // weak | |
| _UNKNOWN unk_309C; // weak | |
| int dword_30A0; // weak | |
| _UNKNOWN unk_30A4; // weak | |
| _UNKNOWN unk_30A8; // weak | |
| _UNKNOWN unk_30AC; // weak | |
| _UNKNOWN unk_30B0; // weak | |
| _UNKNOWN unk_30B4; // weak | |
| _UNKNOWN unk_30B8; // weak | |
| int dword_30BC; // weak | |
| _UNKNOWN unk_30C0; // weak | |
| _UNKNOWN unk_30C4; // weak | |
| // extern _UNKNOWN _stack_chk_guard; weak | |
| //----- (00000944) -------------------------------------------------------- | |
| int sub_944() | |
| { | |
| return _cxa_finalize(&off_3000); | |
| } | |
| // 848: using guessed type int __fastcall _cxa_finalize(_DWORD); | |
| // 3000: using guessed type void *off_3000; | |
| //----- (00000964) -------------------------------------------------------- | |
| int (*__fastcall sub_964(int (*result)(void)))(void) | |
| { | |
| if ( result ) | |
| result = (int (*)(void))result(); | |
| return result; | |
| } | |
| //----- (000009D8) -------------------------------------------------------- | |
| int init_globals() | |
| { | |
| pthread_mutex_init(&unk_30B8, 0); | |
| pthread_mutex_init(&unk_30B4, 0); | |
| return j_j_pthread_mutex_init((int)&unk_30C0, 0); | |
| } | |
| // 860: using guessed type int __fastcall pthread_mutex_init(_DWORD, _DWORD); | |
| // 9D8: using guessed type int init_globals(); | |
| //----- (00000A08) -------------------------------------------------------- | |
| int __fastcall sub_A08(void *a1) | |
| { | |
| if ( a1 ) | |
| free(a1); | |
| return 0; | |
| } | |
| //----- (00000A14) -------------------------------------------------------- | |
| signed int __fastcall sub_A14(int a1, int a2) | |
| { | |
| int v2; // r4@0 | |
| int v3; // r6@0 | |
| int v4; // r3@2 | |
| int v5; // r7@2 | |
| signed int result; // r0@11 | |
| char v7; // [sp+13h] [bp-2Dh]@8 | |
| int v8; // [sp+14h] [bp-2Ch]@1 | |
| int v9; // [sp+18h] [bp-28h]@8 | |
| int v10; // [sp+1Ch] [bp-24h]@8 | |
| int v11; // [sp+20h] [bp-20h]@8 | |
| int v12; // [sp+24h] [bp-1Ch]@1 | |
| v8 = 1; | |
| v12 = 1; | |
| if ( a1 ) | |
| { | |
| v4 = *(_DWORD *)(a2 + 4); | |
| v5 = *(_DWORD *)a2; | |
| if ( v4 == 1 ) | |
| v3 = *(_DWORD *)(a2 + 8); | |
| else | |
| v2 = 0; | |
| if ( v4 == 1 ) | |
| v2 = *(_DWORD *)(a2 + 12); | |
| else | |
| v3 = v2; | |
| _android_log_print(4, "qdlights", "set_speaker_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d\n"); | |
| v9 = v5; | |
| v10 = v3; | |
| v11 = v2; | |
| if ( oem_qmi_common_stream_from_modem_len(143, &v9, 16, &v7) == 1 ) | |
| _android_log_print(3, "qdlights", "write tri_color success"); | |
| else | |
| _android_log_print( | |
| 6, | |
| "qdlights", | |
| "####%s , Line: %05d: write tri_color failed ", | |
| "set_speaker_light_locked", | |
| 238, | |
| v3, | |
| v2); | |
| result = 0; | |
| } | |
| else | |
| { | |
| result = -1; | |
| } | |
| return result; | |
| } | |
| // 878: using guessed type int _android_log_print(_DWORD, _DWORD, const char *, ...); | |
| // 884: using guessed type int __fastcall oem_qmi_common_stream_from_modem_len(_DWORD, _DWORD, _DWORD, _DWORD); | |
| //----- (00000AA8) -------------------------------------------------------- | |
| signed int __fastcall sub_AA8(int a1) | |
| { | |
| int *v1; // r1@1 | |
| v1 = &dword_30A0; | |
| if ( !(dword_30A0 & 0xFFFFFF) ) | |
| v1 = (int *)&unk_308C; | |
| return sub_A14(a1, (int)v1); | |
| } | |
| // 30A0: using guessed type int dword_30A0; | |
| //----- (00000AC4) -------------------------------------------------------- | |
| int __fastcall sub_AC4(int a1, int a2) | |
| { | |
| int v2; // r5@1 | |
| int v3; // r4@1 | |
| int v4; // r3@1 | |
| v2 = a1; | |
| v3 = a2; | |
| pthread_mutex_lock(&unk_30B8); | |
| v4 = *(_DWORD *)(v3 + 4); | |
| if ( v4 == 2 ) | |
| { | |
| dword_30BC = *(_DWORD *)(v3 + 8); | |
| } | |
| else if ( !v4 ) | |
| { | |
| dword_30BC = 0; | |
| } | |
| sub_AA8(v2); | |
| pthread_mutex_unlock(&unk_30B8); | |
| return 0; | |
| } | |
| // 890: using guessed type int __fastcall pthread_mutex_lock(_DWORD); | |
| // 89C: using guessed type int __fastcall pthread_mutex_unlock(_DWORD); | |
| // 30BC: using guessed type int dword_30BC; | |
| //----- (00000B0C) -------------------------------------------------------- | |
| int __fastcall sub_B0C(int a1, int a2) | |
| { | |
| int v2; // r7@1 | |
| int v3; // r5@1 | |
| int v4; // r1@1 | |
| int v5; // r2@1 | |
| int v6; // r3@1 | |
| v2 = a1; | |
| v3 = a2; | |
| pthread_mutex_lock(&unk_30B8); | |
| v4 = *(_DWORD *)(v3 + 4); | |
| v5 = *(_DWORD *)(v3 + 8); | |
| v6 = *(_DWORD *)(v3 + 12); | |
| unk_308C = *(_DWORD *)v3; | |
| unk_3090 = v4; | |
| unk_3094 = v5; | |
| unk_3098 = v6; | |
| unk_309C = *(_DWORD *)(v3 + 16); | |
| sub_AA8(v2); | |
| pthread_mutex_unlock(&unk_30B8); | |
| return 0; | |
| } | |
| // 890: using guessed type int __fastcall pthread_mutex_lock(_DWORD); | |
| // 89C: using guessed type int __fastcall pthread_mutex_unlock(_DWORD); | |
| //----- (00000B40) -------------------------------------------------------- | |
| int __fastcall sub_B40(int a1, int a2) | |
| { | |
| int v2; // r7@1 | |
| int v3; // r5@1 | |
| int v4; // r1@1 | |
| int v5; // r2@1 | |
| int v6; // r3@1 | |
| v2 = a1; | |
| v3 = a2; | |
| pthread_mutex_lock(&unk_30B8); | |
| v4 = *(_DWORD *)(v3 + 4); | |
| v5 = *(_DWORD *)(v3 + 8); | |
| v6 = *(_DWORD *)(v3 + 12); | |
| dword_30A0 = *(_DWORD *)v3; | |
| unk_30A4 = v4; | |
| unk_30A8 = v5; | |
| unk_30AC = v6; | |
| unk_30B0 = *(_DWORD *)(v3 + 16); | |
| sub_AA8(v2); | |
| pthread_mutex_unlock(&unk_30B8); | |
| return 0; | |
| } | |
| // 890: using guessed type int __fastcall pthread_mutex_lock(_DWORD); | |
| // 89C: using guessed type int __fastcall pthread_mutex_unlock(_DWORD); | |
| // 30A0: using guessed type int dword_30A0; | |
| //----- (00000B74) -------------------------------------------------------- | |
| signed int __fastcall sub_B74(int a1, const char *a2, _DWORD *a3) | |
| { | |
| int v3; // r8@1 | |
| const char *v4; // r4@1 | |
| _DWORD *v5; // r7@1 | |
| signed int result; // r0@7 | |
| int (*v7)(); // r5@8 | |
| _DWORD *v8; // r0@14 | |
| _DWORD *v9; // r4@14 | |
| v3 = a1; | |
| v4 = a2; | |
| v5 = a3; | |
| if ( !strcmp("backlight", a2) ) | |
| { | |
| v7 = (int (*)())sub_D70; | |
| } | |
| else if ( !strcmp("battery", v4) ) | |
| { | |
| v7 = (int (*)())sub_B40; | |
| } | |
| else if ( !strcmp("notifications", v4) ) | |
| { | |
| v7 = (int (*)())sub_B0C; | |
| } | |
| else if ( !strcmp("buttons", v4) ) | |
| { | |
| v7 = (int (*)())sub_D3C; | |
| } | |
| else if ( !strcmp("attention", v4) ) | |
| { | |
| v7 = (int (*)())sub_AC4; | |
| } | |
| else | |
| { | |
| if ( strcmp("flash", v4) ) | |
| { | |
| _android_log_print(6, "qdlights", "####%s , Line: %05d: func: %s, name: %s can't open\n "); | |
| return -22; | |
| } | |
| v7 = sub_DC4; | |
| } | |
| pthread_once(&unk_30C4, init_globals); | |
| v8 = malloc(0x44u); | |
| v9 = v8; | |
| if ( v8 ) | |
| { | |
| memset(v8, 0, 0x44u); | |
| v9[2] = v3; | |
| *v9 = 1213678676; | |
| v9[1] = 0; | |
| result = 0; | |
| v9[15] = sub_A08; | |
| v9[16] = v7; | |
| *v5 = v9; | |
| } | |
| else | |
| { | |
| result = -12; | |
| } | |
| return result; | |
| } | |
| // 878: using guessed type int _android_log_print(_DWORD, _DWORD, const char *, ...); | |
| // 8B4: using guessed type int __fastcall pthread_once(_DWORD, _DWORD); | |
| // 9D8: using guessed type int init_globals(); | |
| // DC4: using guessed type int sub_DC4(); | |
| //----- (00000C9C) -------------------------------------------------------- | |
| int __fastcall sub_C9C(int a1, int a2) | |
| { | |
| int v2; // r7@1 | |
| int v3; // r6@1 | |
| int v4; // r4@1 | |
| int v5; // r0@2 | |
| int v6; // r7@2 | |
| int result; // r0@3 | |
| char v8; // [sp+8h] [bp-30h]@2 | |
| int v9; // [sp+1Ch] [bp-1Ch]@1 | |
| v2 = a2; | |
| v3 = a1; | |
| v9 = _stack_chk_guard; | |
| v4 = open(); | |
| if ( v4 < 0 ) | |
| { | |
| if ( !dword_3088 ) | |
| { | |
| _android_log_print(6, "qdlights", "####%s , Line: %05d: write_int failed to open %s\n ", "write_int", 144, v3); | |
| dword_3088 = 1; | |
| } | |
| } | |
| else | |
| { | |
| v5 = snprintf(&v8, 0x14u, "%d\n", v2); | |
| v6 = write(v4, &v8, v5); | |
| close(v4); | |
| if ( v6 != -1 ) | |
| { | |
| result = 0; | |
| goto LABEL_7; | |
| } | |
| } | |
| result = -*(_DWORD *)_errno(); | |
| LABEL_7: | |
| if ( v9 != _stack_chk_guard ) | |
| _stack_chk_fail(result); | |
| return result; | |
| } | |
| // 878: using guessed type int _android_log_print(_DWORD, _DWORD, const char *, ...); | |
| // 8D8: using guessed type int open(void); | |
| // 8F0: using guessed type int __fastcall write(_DWORD, _DWORD, _DWORD); | |
| // 8FC: using guessed type int __fastcall close(_DWORD); | |
| // 908: using guessed type int _errno(void); | |
| // 914: using guessed type int __fastcall _stack_chk_fail(_DWORD); | |
| // 3088: using guessed type int dword_3088; | |
| //----- (00000D3C) -------------------------------------------------------- | |
| signed int __fastcall sub_D3C(int a1, _BYTE *a2) | |
| { | |
| _BYTE *v2; // r5@1 | |
| int v3; // r5@2 | |
| signed int result; // r0@2 | |
| v2 = a2; | |
| if ( a1 ) | |
| { | |
| pthread_mutex_lock(&unk_30C0); | |
| v3 = sub_C9C((int)"/sys/class/leds/button-backlight/brightness", *v2); | |
| pthread_mutex_unlock(&unk_30C0); | |
| result = v3; | |
| } | |
| else | |
| { | |
| result = -1; | |
| } | |
| return result; | |
| } | |
| // 890: using guessed type int __fastcall pthread_mutex_lock(_DWORD); | |
| // 89C: using guessed type int __fastcall pthread_mutex_unlock(_DWORD); | |
| //----- (00000D70) -------------------------------------------------------- | |
| signed int __fastcall sub_D70(int a1, _DWORD *a2) | |
| { | |
| int v2; // r5@1 | |
| int v3; // r5@2 | |
| signed int result; // r0@2 | |
| v2 = (150 * ((unsigned __int16)*a2 >> 8) + 77 * ((*a2 & 0xFFFFFF) >> 16) + 29 * (unsigned __int8)*a2) >> 8; | |
| if ( a1 ) | |
| { | |
| pthread_mutex_lock(&unk_30B4); | |
| v3 = sub_C9C((int)"/sys/class/leds/lcd-backlight/brightness", v2); | |
| pthread_mutex_unlock(&unk_30B4); | |
| result = v3; | |
| } | |
| else | |
| { | |
| result = -1; | |
| } | |
| return result; | |
| } | |
| // 890: using guessed type int __fastcall pthread_mutex_lock(_DWORD); | |
| // 89C: using guessed type int __fastcall pthread_mutex_unlock(_DWORD); | |
| //----- (0000118C) -------------------------------------------------------- | |
| int __fastcall j_j_pthread_mutex_init(int a1, int a2) | |
| { | |
| return j_pthread_mutex_init(a1, a2); | |
| } | |
| //----- (00001190) -------------------------------------------------------- | |
| int __fastcall j_pthread_mutex_init(int a1, int a2) | |
| { | |
| return pthread_mutex_init(a1, a2); | |
| } | |
| // 860: using guessed type int __fastcall pthread_mutex_init(_DWORD, _DWORD); | |
| // ALL OK, 15 function(s) have been successfully decompiled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment