[REF] DFT_SSPL_MINI.c - HD Mini ROM Development
DFT_SSPL_MINI.c
Hi im sorry, this is decompiled
hi,what is this?
file extension c
tzacapaca said:
hi,what is this?
file extension c
Click to expand...
Click to collapse
Isn't that a file for VS2008 or higher with C-code? I'll check that for you
Checked that for you, and indeed it is decompiled C++. This is what it contains, but I don't know what we should do with this code? Maybe someone who knows C++ can make HSPL with this as a basis?
Code:
/* This file has been generated by the Hex-Rays decompiler.
Copyright (c) 2009 Hex-Rays <[email protected]>
Detected compiler: Visual C++
*/
#include <windows.h>
#include <defs.h>
//-------------------------------------------------------------------------
// Data declarations
extern char aGetprocesswind[]; // idb
extern char aGetuserobjecti[]; // idb
extern char aGetlastactivep[19]; // weak
extern char aGetactivewindo[16]; // weak
extern char aMessageboxa[]; // idb
extern char LibFileName[]; // idb
extern char aRomupdateutili[21]; // weak
extern char Caption[]; // idb
extern _UNKNOWN unk_409300; // weak
extern char Text[]; // idb
extern char aErrorDuringExt[]; // idb
extern _UNKNOWN unk_409400; // weak
extern _UNKNOWN unk_409408; // weak
extern int dword_40AA58; // weak
extern int dword_40ACA0; // weak
extern char off_40ACA4[92]; // idb
extern int dword_40AD10; // weak
extern int dword_40AD1C; // weak
extern int dword_40B2E0; // weak
extern int dword_40B2F0; // weak
extern int dword_40B308; // weak
extern int dword_40B30C; // weak
extern int dword_40B310; // weak
extern int dword_40B314; // weak
extern int dword_40B318; // weak
extern int dword_40B31C; // weak
extern int dword_40B320; // weak
extern int dword_40B324; // weak
extern CHAR Filename; // idb
extern char FileName[]; // idb
extern int dword_40BB68; // weak
//-------------------------------------------------------------------------
// Function declarations
#define __thiscall __cdecl // Test compile in C mode
// signed int __usercall sub_401000<eax>(int a1<eax>, int a2<edx>, int a3<ecx>);
LPVOID __cdecl sub_401050(DWORD NumberOfBytesWritten);
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
// char *__cdecl strrchr(const char *, int);
signed int __cdecl sub_4017D5(int a1);
signed int __cdecl sub_40180C(int a1);
int (*__cdecl sub_40247B())(void);
int (*__cdecl sub_40249F())(void);
// _DWORD __cdecl _encode_pointer(_DWORD); weak
// int _encoded_null(void); weak
// _DWORD __cdecl _decode_pointer(_DWORD); weak
int __cdecl sub_402EE1(int a1);
// int __cdecl _invoke_watson(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); weak
// int __cdecl _invalid_parameter(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); weak
// int *__cdecl _errno();
int __cdecl sub_403325();
int __cdecl sub_4034EC(int a1);
int __cdecl sub_4034F6(int a1);
int __cdecl sub_4035D5(int a1);
int __cdecl sub_403601(int a1, int a2, int a3);
int __thiscall sub_40544A(void *this, char a2);
void __cdecl sub_4055AF();
// void *__cdecl memset(void *, int, size_t);
// _DWORD __thiscall __report_gsfailure(_DWORD ecx0, _BYTE _4); weak
// int __cdecl _unwind_handler(int, int, int, int, int); weak
// int __cdecl _abnormal_termination();
// HANDLE __stdcall CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
// HRSRC __stdcall FindResourceA(HMODULE hModule, LPCSTR lpName, LPCSTR lpType);
// HGLOBAL __stdcall LoadResource(HMODULE hModule, HRSRC hResInfo);
// DWORD __stdcall WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
// BOOL __stdcall WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
// DWORD __stdcall SizeofResource(HMODULE hModule, HRSRC hResInfo);
// BOOL __stdcall CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
// BOOL __stdcall SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes);
// LPVOID __stdcall LockResource(HGLOBAL hResData);
// DWORD __stdcall GetModuleFileNameA(HMODULE hModule, LPCH lpFilename, DWORD nSize);
// BOOL __stdcall CloseHandle(HANDLE hObject);
// BOOL __stdcall DeleteFileA(LPCSTR lpFileName);
// FARPROC __stdcall GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
// HMODULE __stdcall LoadLibraryA(LPCSTR lpLibFileName);
// int __stdcall MessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
//----- (00401000) --------------------------------------------------------
signed int __usercall sub_401000<eax>(int a1<eax>, int a2<edx>, int a3<ecx>)
{
signed int result; // [email protected]
int v4; // [email protected]
int v5; // [email protected]
v5 = a1;
v4 = a3;
result = 0;
if ( a3 )
{
while ( *(_BYTE *)v5 )
{
*(_BYTE *)a2++ = *(_BYTE *)v5++;
--v4;
if ( !v4 )
{
result = -2147024774;
*(_BYTE *)(a2 - 1) = 0;
return result;
}
}
if ( !v4 )
{
--a2;
result = -2147024774;
}
*(_BYTE *)a2 = 0;
}
else
{
result = -2147024809;
}
return result;
}
//----- (00401050) --------------------------------------------------------
LPVOID __cdecl sub_401050(DWORD NumberOfBytesWritten)
{
HRSRC v1; // [email protected]
HRSRC v2; // [email protected]
LPVOID result; // [email protected]
HGLOBAL v4; // [email protected]
const void *v5; // [email protected]
HANDLE v6; // [email protected]
DWORD v7; // [email protected]
void *v8; // [email protected]
v1 = FindResourceA(0, (LPCSTR)(unsigned __int16)NumberOfBytesWritten, (LPCSTR)0xA);
v2 = v1;
if ( v1 && (v4 = LoadResource(0, v1)) != 0 )
{
result = LockResource(v4);
v5 = result;
if ( result )
{
v7 = SizeofResource(0, v2);
v6 = CreateFileA(FileName, 0x40000000u, 1u, 0, 2u, 2u, 0);
v8 = v6;
if ( v6 == (HANDLE)-1 )
{
result = 0;
}
else
{
WriteFile(v6, v5, v7, &NumberOfBytesWritten, 0);
CloseHandle(v8);
SetFileAttributesA(FileName, 2u);
result = (LPVOID)1;
}
}
}
else
{
result = 0;
}
return result;
}
//----- (004010F0) --------------------------------------------------------
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
char *v4; // [email protected]
unsigned int v5; // [email protected]
unsigned int v6; // [email protected]
int v7; // [email protected]
signed int v8; // [email protected]
char v9; // [email protected]
int v10; // [email protected]
signed int v11; // [email protected]
char *v12; // [email protected]
int v13; // [email protected]
char *v14; // [email protected]
char v15; // [email protected]
int v16; // [email protected]
signed int v17; // [email protected]
int v18; // [email protected]
signed int v19; // [email protected]
char v20; // [email protected]
int v22; // [email protected]
signed int v23; // [email protected]
char *v24; // [email protected]
int v25; // [email protected]
char *v26; // [email protected]
char v27; // [email protected]
int v28; // [email protected]
signed int v29; // [email protected]
char *v30; // [email protected]
int v31; // [email protected]
char *v32; // [email protected]
char v33; // [email protected]
unsigned int v34; // [email protected]
int v35; // [email protected]
signed int v36; // [email protected]
char v37; // [email protected]
int v38; // [email protected]
signed int v39; // [email protected]
char *v40; // [email protected]
int v41; // [email protected]
char *v42; // [email protected]
char v43; // [email protected]
int v44; // [email protected]
signed int v45; // [email protected]
char *v46; // [email protected]
int v47; // [email protected]
char *v48; // [email protected]
char v49; // [email protected]
struct _PROCESS_INFORMATION ProcessInformation; // [sp+4h] [bp-54h]@64
struct _STARTUPINFOA StartupInfo; // [sp+14h] [bp-44h]@64
Filename = 0;
GetModuleFileNameA(0, &Filename, 0x1FFu);
v4 = strrchr(&Filename, 92);
if ( v4 )
*v4 = 0;
v5 = &Filename - FileName;
v6 = 0;
do
{
v8 = 512;
v7 = (int)FileName;
while ( 1 )
{
v9 = *(_BYTE *)(v5 + v7);
if ( !v9 )
break;
*(_BYTE *)v7++ = v9;
--v8;
if ( !v8 )
goto LABEL_9;
}
if ( v8 )
goto LABEL_10;
LABEL_9:
--v7;
LABEL_10:
*(_BYTE *)v7 = 0;
v11 = 512;
v10 = (int)FileName;
while ( *(_BYTE *)v10 )
{
++v10;
--v11;
if ( !v11 )
goto LABEL_23;
}
if ( v11 )
{
v13 = 512 - (512 - v11);
v12 = &FileName[512 - v11];
if ( 0 != v11 )
{
v14 = (char *)(&unk_409300 - (_UNKNOWN *)v12);
while ( 1 )
{
v15 = *(_BYTE *)((_DWORD)v14 + (_DWORD)v12);
if ( !v15 )
break;
*v12++ = v15;
--v13;
if ( !v13 )
goto LABEL_21;
}
if ( v13 )
goto LABEL_22;
LABEL_21:
--v12;
LABEL_22:
*v12 = 0;
}
}
LABEL_23:
v17 = 512;
v16 = (int)FileName;
while ( *(_BYTE *)v16 )
{
++v16;
--v17;
if ( !v17 )
goto LABEL_29;
}
if ( v17 )
sub_401000(*(_DWORD *)&off_40ACA4[v6], (int)&FileName[512 - v17], 512 - (512 - v17));
LABEL_29:
if ( !sub_401050(*(int *)((char *)&dword_40ACA0 + v6)) )
{
MessageBoxA(0, "Error during application start! Possible file corrupted!", Caption, 0x40010u);
return -1;
}
v6 += 8;
}
while ( v6 < 0x50 );
v19 = 512;
v18 = (int)FileName;
while ( 1 )
{
v20 = *(_BYTE *)(v5 + v18);
if ( !v20 )
break;
*(_BYTE *)v18++ = v20;
--v19;
if ( !v19 )
goto LABEL_37;
}
if ( v19 )
goto LABEL_38;
LABEL_37:
--v18;
LABEL_38:
*(_BYTE *)v18 = 0;
v23 = 512;
v22 = (int)FileName;
while ( *(_BYTE *)v22 )
{
++v22;
--v23;
if ( !v23 )
goto LABEL_51;
}
if ( v23 )
{
v25 = 512 - (512 - v23);
v24 = &FileName[512 - v23];
if ( 0 != v23 )
{
v26 = (char *)(&unk_409300 - (_UNKNOWN *)v24);
while ( 1 )
{
v27 = *(_BYTE *)((_DWORD)v26 + (_DWORD)v24);
if ( !v27 )
break;
*v24++ = v27;
--v25;
if ( !v25 )
goto LABEL_49;
}
if ( v25 )
goto LABEL_50;
LABEL_49:
--v24;
LABEL_50:
*v24 = 0;
}
}
LABEL_51:
v29 = 512;
v28 = (int)FileName;
while ( *(_BYTE *)v28 )
{
++v28;
--v29;
if ( !v29 )
goto LABEL_64;
}
if ( v29 )
{
v31 = 512 - (512 - v29);
v30 = &FileName[512 - v29];
if ( 0 != v29 )
{
v32 = (char *)("ROMUpdateUtility.exe" - v30);
while ( 1 )
{
v33 = *(_BYTE *)((_DWORD)v30 + (_DWORD)v32);
if ( !v33 )
break;
*v30++ = v33;
--v31;
if ( !v31 )
goto LABEL_62;
}
if ( v31 )
goto LABEL_63;
LABEL_62:
--v30;
LABEL_63:
*v30 = 0;
}
}
LABEL_64:
memset(&StartupInfo, 0, 0x44u);
if ( CreateProcessA(FileName, 0, 0, 0, 0, 0, 0, 0, &StartupInfo, &ProcessInformation)
&& (_DWORD)ProcessInformation.hProcess )
{
WaitForSingleObject(ProcessInformation.hProcess, 0xFFFFFFFFu);
CloseHandle(ProcessInformation.hProcess);
}
else
{
MessageBoxA(0, "Error during extraction! Possible file corrupted!", Caption, 0x40010u);
}
v34 = 0;
do
{
v36 = 512;
v35 = (int)FileName;
while ( 1 )
{
v37 = *(_BYTE *)(&Filename - FileName + v35);
if ( !v37 )
break;
*(_BYTE *)v35++ = v37;
--v36;
if ( !v36 )
goto LABEL_74;
}
if ( v36 )
goto LABEL_75;
LABEL_74:
--v35;
LABEL_75:
*(_BYTE *)v35 = 0;
v39 = 512;
v38 = (int)FileName;
while ( *(_BYTE *)v38 )
{
++v38;
--v39;
if ( !v39 )
goto LABEL_88;
}
if ( v39 )
{
v41 = 512 - (512 - v39);
v40 = &FileName[512 - v39];
if ( 0 != v39 )
{
v42 = (char *)(&unk_409300 - (_UNKNOWN *)v40);
while ( 1 )
{
v43 = *(_BYTE *)((_DWORD)v42 + (_DWORD)v40);
if ( !v43 )
break;
*v40++ = v43;
--v41;
if ( !v41 )
goto LABEL_86;
}
if ( v41 )
goto LABEL_87;
LABEL_86:
--v40;
LABEL_87:
*v40 = 0;
}
}
LABEL_88:
v45 = 512;
v44 = (int)FileName;
while ( *(_BYTE *)v44 )
{
++v44;
--v45;
if ( !v45 )
goto LABEL_101;
}
if ( v45 )
{
v47 = 512 - (512 - v45);
v46 = &FileName[512 - v45];
if ( 0 != v45 )
{
v48 = (char *)(*(_DWORD *)&off_40ACA4[v34] - (_DWORD)v46);
while ( 1 )
{
v49 = *(_BYTE *)((_DWORD)v46 + (_DWORD)v48);
if ( !v49 )
break;
*v46++ = v49;
--v47;
if ( !v47 )
goto LABEL_99;
}
if ( v47 )
goto LABEL_100;
LABEL_99:
--v46;
LABEL_100:
*v46 = 0;
}
}
LABEL_101:
SetFileAttributesA(FileName, 0x80u);
DeleteFileA(FileName);
v34 += 8;
}
while ( v34 < 0x50 );
return 0;
}
// 40ACA0: using guessed type int dword_40ACA0;
//----- (004017D5) --------------------------------------------------------
signed int __cdecl sub_4017D5(int a1)
{
signed int result; // [email protected]
if ( a1 && dword_40AD10 )
{
*(_DWORD *)a1 = dword_40AD10;
result = 0;
}
else
{
*_errno() = 22;
_invalid_parameter(0, 0, 0, 0, 0);
result = 22;
}
return result;
}
// 402FE7: using guessed type int __cdecl _invalid_parameter(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
// 40AD10: using guessed type int dword_40AD10;
//----- (0040180C) --------------------------------------------------------
signed int __cdecl sub_40180C(int a1)
{
signed int result; // [email protected]
if ( a1 && dword_40AD10 )
{
*(_DWORD *)a1 = dword_40AD1C;
result = 0;
}
else
{
*_errno() = 22;
_invalid_parameter(0, 0, 0, 0, 0);
result = 22;
}
return result;
}
// 402FE7: using guessed type int __cdecl _invalid_parameter(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
// 40AD10: using guessed type int dword_40AD10;
// 40AD1C: using guessed type int dword_40AD1C;
//----- (0040247B) --------------------------------------------------------
int (*__cdecl sub_40247B())(void)
{
int (*result)(void); // [email protected]
unsigned int v1; // [email protected]
result = (int (*)(void))&unk_409400;
v1 = (unsigned int)&unk_409400;
if ( &unk_409400 < &unk_409400 )
{
do
{
result = *(int (**)(void))v1;
if ( *(_DWORD *)v1 )
result = (int (*)(void))result();
v1 += 4;
}
while ( v1 < (unsigned int)&unk_409400 );
}
return result;
}
//----- (0040249F) --------------------------------------------------------
int (*__cdecl sub_40249F())(void)
{
int (*result)(void); // [email protected]
unsigned int v1; // [email protected]
result = (int (*)(void))&unk_409408;
v1 = (unsigned int)&unk_409408;
if ( &unk_409408 < &unk_409408 )
{
do
{
result = *(int (**)(void))v1;
if ( *(_DWORD *)v1 )
result = (int (*)(void))result();
v1 += 4;
}
while ( v1 < (unsigned int)&unk_409408 );
}
return result;
}
//----- (00402EE1) --------------------------------------------------------
int __cdecl sub_402EE1(int a1)
{
int result; // [email protected]
result = a1;
dword_40B2E0 = a1;
return result;
}
// 40B2E0: using guessed type int dword_40B2E0;
//----- (00403325) --------------------------------------------------------
int __cdecl sub_403325()
{
return _decode_pointer(dword_40B2F0);
}
// 40252F: using guessed type _DWORD __cdecl _decode_pointer(_DWORD);
// 40B2F0: using guessed type int dword_40B2F0;
//----- (004034EC) --------------------------------------------------------
int __cdecl sub_4034EC(int a1)
{
int result; // [email protected]
result = a1;
dword_40B308 = a1;
return result;
}
// 40B308: using guessed type int dword_40B308;
//----- (004034F6) --------------------------------------------------------
int __cdecl sub_4034F6(int a1)
{
int result; // [email protected]
result = a1;
dword_40B30C = a1;
return result;
}
// 40B30C: using guessed type int dword_40B30C;
//----- (004035D5) --------------------------------------------------------
int __cdecl sub_4035D5(int a1)
{
int result; // [email protected]
result = a1;
dword_40B310 = a1;
return result;
}
// 40B310: using guessed type int dword_40B310;
//----- (00403601) --------------------------------------------------------
int __cdecl sub_403601(int a1, int a2, int a3)
{
HMODULE v3; // [email protected]
HMODULE v4; // [email protected]
FARPROC v6; // [email protected]
FARPROC v7; // [email protected]
FARPROC v8; // [email protected]
FARPROC v9; // [email protected]
FARPROC v10; // [email protected]
int v11; // [email protected]
int v12; // [email protected]
int (__thiscall *v13)(_DWORD); // [email protected]
int v14; // [email protected]
int v15; // [email protected]
int (__thiscall *v16)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); // [email protected]
int v17; // [email protected]
int (__thiscall *v18)(_DWORD); // [email protected]
int v19; // [email protected]
int v20; // [email protected]
int (__thiscall *v21)(_DWORD, _DWORD); // [email protected]
int v22; // [email protected]
int v23; // [email protected]
int (__thiscall *v24)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); // [email protected]
int v25; // [email protected]
char v26; // [sp+10h] [bp-20h]@13
char v27; // [sp+18h] [bp-18h]@14
char v28; // [sp+1Ch] [bp-14h]@13
int v29; // [sp+20h] [bp-10h]@1
unsigned int v30; // [sp+24h] [bp-Ch]@1
int v31; // [sp+28h] [bp-8h]@1
int v32; // [sp+2Ch] [bp-4h]@1
v29 = _encoded_null();
v32 = 0;
v31 = 0;
v30 = 0;
if ( !dword_40B314 )
{
v3 = LoadLibraryA("USER32.DLL");
v4 = v3;
if ( !v3 || (v6 = GetProcAddress(v3, "MessageBoxA"), !v6) )
return 0;
dword_40B314 = _encode_pointer(v6);
v7 = GetProcAddress(v4, "GetActiveWindow");
dword_40B318 = _encode_pointer(v7);
v8 = GetProcAddress(v4, "GetLastActivePopup");
dword_40B31C = _encode_pointer(v8);
if ( sub_4017D5((int)&v31) )
_invoke_watson(0, 0, 0, 0, 0);
if ( v31 == 2 )
{
v9 = GetProcAddress(v4, "GetUserObjectInformationA");
dword_40B324 = _encode_pointer(v9);
if ( dword_40B324 )
{
v10 = GetProcAddress(v4, "GetProcessWindowStation");
dword_40B320 = _encode_pointer(v10);
}
}
}
v11 = v29;
if ( dword_40B320 == v29
|| dword_40B324 == v29
|| (v13 = (int (__thiscall *)(_DWORD))_decode_pointer(dword_40B320), (v12 = v13(v14)) != 0)
&& (v15 = v12,
v16 = (int (__thiscall *)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))_decode_pointer(dword_40B324),
v16(v17, v15, 1, &v26, 12, &v28))
&& v27 & 1 )
{
if ( dword_40B318 != v11 )
{
v18 = (int (__thiscall *)(_DWORD))_decode_pointer(dword_40B318);
v32 = v18(v19);
if ( v32 )
{
if ( dword_40B31C != v11 )
{
v20 = v32;
v21 = (int (__thiscall *)(_DWORD, _DWORD))_decode_pointer(dword_40B31C);
v32 = v21(v22, v20);
}
}
}
}
else
{
if ( sub_40180C((int)&v30) )
_invoke_watson(0, 0, 0, 0, 0);
if ( v30 < 4 )
a3 |= 0x40000u;
else
a3 |= 0x200000u;
}
v23 = v32;
v24 = (int (__thiscall *)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD))_decode_pointer(dword_40B314);
return v24(v25, v23, a1, a2, a3);
}
// 4024C3: using guessed type _DWORD __cdecl _encode_pointer(_DWORD);
// 402526: using guessed type int _encoded_null(void);
// 40252F: using guessed type _DWORD __cdecl _decode_pointer(_DWORD);
// 402EEB: using guessed type int __cdecl _invoke_watson(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
// 40B314: using guessed type int dword_40B314;
// 40B318: using guessed type int dword_40B318;
// 40B31C: using guessed type int dword_40B31C;
// 40B320: using guessed type int dword_40B320;
// 40B324: using guessed type int dword_40B324;
//----- (0040544A) --------------------------------------------------------
int __thiscall sub_40544A(void *this, char a2)
{
if ( this == (void *)dword_40AA58 )
__asm { rep retn }
return __report_gsfailure(this, a2);
}
// 406A85: using guessed type _DWORD __thiscall __report_gsfailure(_DWORD ecx0, _BYTE _4);
// 40AA58: using guessed type int dword_40AA58;
//----- (004055AF) --------------------------------------------------------
void __cdecl sub_4055AF()
{
dword_40BB68 = 0;
}
// 40BB68: using guessed type int dword_40BB68;
// ALL OK, 15 function(s) have been successfully decompiled
for hard spl you must to decompile spl first and than to reverse enginer it to make hard spl. I was try that but im not c++ or c programer
cardsharing said:
for hard spl you must to decompile spl first and than to reverse enginer it to make hard spl. I was try that but im not c++ or c programer
Click to expand...
Click to collapse
Me neither, I do C#
Related
diffing kj4 - kj6 kernels
as kj6 is supposed to bring some bug fixes, I thought I'd check the kernel source. there's not a huge amount of difference, but some looks interesting, hopefully of use to anyone wanting to building it. Code: --- drivers/input/touchscreen/mxt540e.c 2011-10-20 02:58:48.000000000 +++ drivers/input/touchscreen/mxt540e.c 2011-10-25 17:58:10.000000000 @@ -907,16 +907,16 @@ } if (object_type == PROCG_NOISESUPPRESSION_T48) { if (msg[4] == 5) { /* Median filter error */ printk("[TSP] Median filter Error\n"); get_object_info(data, PROCG_NOISESUPPRESSION_T48, &size, &obj_address); - value = data->calcfg_batt_e; + value = 0; error = write_mem(data, obj_address+2, 1, &value); - msleep(5); - value |= 0x20; + msleep(15); + value = data->calcfg_batt_e; error |= write_mem(data, obj_address+2, 1, &value); if(error) printk(KERN_ERR "[TSP] failed to reenable CHRGON\n"); } } if (object_type == TOUCH_MULTITOUCHSCREEN_T9) { Code: --- drivers/input/keyboard/cypress/cypress-touchkey.c 2011-10-20 02:58:48.000000000 +++ drivers/input/keyboard/cypress/cypress-touchkey.c 2011-10-25 17:58:10.000000000 @@ -1909,18 +1909,20 @@ int ret = 0; #ifdef TEST_JIG_MODE unsigned char get_touch = 0x40; #endif +#ifndef CONFIG_MACH_Q1_REV02 if (gpio_request(_3_TOUCH_SDA_28V, "_3_TOUCH_SDA_28V")) WARN(1, "Fail to request gpio (_3_TOUCH_SDA_28V)\n"); if (gpio_request(_3_TOUCH_SCL_28V, "_3_TOUCH_SCL_28V")) WARN(1, "Fail to request gpio (_3_TOUCH_SCL_28V)\n"); if (gpio_request(_3_GPIO_TOUCH_EN, "_3_GPIO_TOUCH_EN")) WARN(1, "Fail to request gpio (_3_GPIO_TOUCH_EN)\n"); +#endif if (gpio_request(_3_GPIO_TOUCH_INT, "_3_GPIO_TOUCH_INT")) WARN(1, "Fail to request gpio (_3_GPIO_TOUCH_INT)\n"); /*20110222 N1_firmware_sync*/ sec_touchkey = device_create(sec_class, NULL, 0, NULL, "sec_touchkey"); @@ -2212,18 +2214,20 @@ misc_deregister(&touchkey_update_device); if (touchkey_wq) { destroy_workqueue(touchkey_wq); } +#ifndef CONFIG_MACH_Q1_REV02 gpio_free(_3_TOUCH_SDA_28V); gpio_free(_3_TOUCH_SCL_28V); gpio_free(_3_GPIO_TOUCH_EN); +#endif gpio_free(_3_GPIO_TOUCH_INT); } late_initcall(touchkey_init); module_exit(touchkey_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("@@@"); MODULE_DESCRIPTION("melfas touch keypad");
Code: --- drivers/leds/leds-max8997.c 2011-10-20 02:58:48.000000000 +++ drivers/leds/leds-max8997.c 2011-10-25 17:58:10.000000000 @@ -242,19 +242,30 @@ regulator_led_disable(led); regulator_put(led->vcc); kfree(led); return 0; } +static void regulator_led_shutdown(struct platform_device *pdev) +{ + struct regulator_led *led = platform_get_drvdata(pdev); + + if (regulator_is_enabled(led->vcc)) { + regulator_led_disable(led); + } + return; +} + static struct platform_driver regulator_led_driver = { .driver = { .name = "leds-max8997", .owner = THIS_MODULE, }, .probe = regulator_led_probe, .remove = __devexit_p(regulator_led_remove), + .shutdown = regulator_led_shutdown, }; static int __init regulator_led_init(void) { return platform_driver_register(®ulator_led_driver); } Code: --- drivers/media/video/samsung/mali/common/mali_kernel_mem_os.c 2011-10-20 02:58:48.000000000 +++ drivers/media/video/samsung/mali/common/mali_kernel_mem_os.c 2011-10-25 17:58:10.000000000 @@ -251,12 +251,13 @@ { if ( allocation_order > 0 ) { --allocation_order; } else { /* return OOM */ _mali_osk_lock_signal(info->mutex, _MALI_OSK_LOCKMODE_RW); + MALI_PRINT(("Failed to allocate consistent memory in all sizes.\n")); return MALI_MEM_ALLOC_NONE; } } /* try to allocate 2^(allocation_order) pages, if that fails, try * allocation_order-1 to allocation_order 0 (inclusive) */ @@ -270,18 +271,21 @@ --allocation_order; } if ( NULL == virt ) { MALI_DEBUG_PRINT(1, ("Failed to allocate consistent memory. Is CONSISTENT_DMA_SIZE set too low?\n")); + MALI_PRINT(("Failed to allocate consistent memory. Is CONSISTENT_DMA_SIZE set too low?\n")); /* return OOM */ _mali_osk_lock_signal(info->mutex, _MALI_OSK_LOCKMODE_RW); return MALI_MEM_ALLOC_NONE; } MALI_DEBUG_PRINT(5, ("os_allocator_allocate_page_table_block: Allocation of order %i succeeded\n", + allocation_order)); + MALI_PRINT(("os_allocator_allocate_page_table_block: Allocation of order %i succeeded\n", allocation_order)); /* we now know the size of the allocation since we know for what * allocation_order the allocation succeeded */ size = _MALI_OSK_CPU_PAGE_SIZE << allocation_order;
Code: --- drivers/media/video/m5mo.c 2011-10-20 02:58:48.000000000 +++ drivers/media/video/m5mo.c 2011-10-25 17:58:10.000000000 @@ -1707,13 +1707,13 @@ } #endif static int m5mo_set_touch_auto_focus(struct v4l2_subdev *sd, int val) { struct m5mo_state *state = to_state(sd); - int err = -EINVAL; + int err; cam_info("%s\n", val ? "start" : "stop"); state->focus.touch = val; if (val) { err = m5mo_set_af_mode(sd, FOCUS_MODE_TOUCH); @@ -1727,13 +1727,13 @@ err = m5mo_writew(sd, M5MO_CATEGORY_LENS, M5MO_LENS_AF_TOUCH_POSY, state->focus.pos_y); CHECK_ERR(err); } cam_trace("X\n"); - return err; + return 0; } static int m5mo_set_zoom(struct v4l2_subdev *sd, struct v4l2_control *ctrl) { struct m5mo_state *state = to_state(sd); struct v4l2_queryctrl qc = {0,};
Code: --- drivers/power/smb328_charger.c 2011-10-20 02:58:49.000000000 +++ drivers/power/smb328_charger.c 2011-10-25 17:58:10.000000000 @@ -820,18 +820,26 @@ { struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct smb328_chip *chip; int ret = 0; int gpio = 0; u8 data; + int i; - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) - return -EIO; + i = 10; + while (1) { + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) + goto I2CERROR; - if (smb328_i2c_read(client, 0x36, &data)<0) /* check HW */ - return -EIO; + if (smb328_i2c_read(client, 0x36, &data)>=0) /* check HW */ + break; + +I2CERROR: + if (!i--) return -EIO; + msleep(300); + } dev_info(&client->dev, "%s : SMB328 Charger Driver Loading\n", __func__); chip = kzalloc(sizeof(struct smb328_chip), GFP_KERNEL); if (!chip) return -ENOMEM;
Code: --- drivers/video/samsung/s3cfb_s6e8aa0.c 2011-10-20 02:58:50.000000000 +++ drivers/video/samsung/s3cfb_s6e8aa0.c 2011-10-25 17:58:10.000000000 @@ -1009,19 +1009,27 @@ return 0; } int s6e8ax0_read_mtp(struct lcd_info *lcd, u8 *mtp_data) { int ret; + u8 retry_cnt = 3; s6e8ax0_write(lcd, enable_mtp_register, ARRAY_SIZE(enable_mtp_register)); + +read_retry: ret = s6e8ax0_read(lcd, LDI_MTP_ADDR, LDI_MTP_LENGTH, mtp_data); if (!ret) { - printk("ERROR:MTP read failed\n"); - return 0; + if (retry_cnt) { + printk("[WARN:LCD] : %s : retry cnt : %d\n", __func__, retry_cnt); + retry_cnt--; + goto read_retry; + } else + printk("ERROR:MTP read failed\n"); } + s6e8ax0_write(lcd, disable_mtp_register, ARRAY_SIZE(disable_mtp_register)); return ret; } #endif static ssize_t lcdtype_show(struct device *dev, struct @@ -1228,12 +1236,13 @@ struct s5p_platform_dsim *pd = (struct s5p_platform_dsim *)pdev->dev.platform_data; #endif #ifdef SMART_DIMMING u8 mtp_data[LDI_MTP_LENGTH] = {0,}; u32 i; u8 id_buf[3] = {0,}; + u8 retry_cnt = 3; #endif lcd = kzalloc(sizeof(struct lcd_info), GFP_KERNEL); if (!lcd) { pr_err("failed to allocate for lcd\n"); ret = -ENOMEM; @@ -1330,17 +1339,24 @@ dev_info(&lcd->ld->dev, "s6e8aa0 lcd panel driver has been probed.\n"); #ifdef SMART_DIMMING mutex_init(&lcd->bl_lock); - //read mpt +read_retry: ret = s6e8ax0_read(lcd, PANEL_ID_COMMAND, 3, id_buf); if (!ret) { - printk("[LCD:ERROR] : %s read id failed\n", __func__); - //return -1; + if (retry_cnt) { + printk("[WARN:LCD] : %s : retry cnt : %d\n", __func__, retry_cnt); + retry_cnt--; + goto read_retry; + } else { + printk("[ERROR:LCD] : %s : Read ID Failed\n", __func__); + /*To protect ELVSS Wrong Operation*/ + id_buf[2] = 0x33; + } } printk("Read ID : %x, %x, %x\n", id_buf[0], id_buf[1], id_buf[2]); if (id_buf[2] == 0x33) { lcd->support_elvss = 0; @@ -1361,22 +1377,23 @@ init_table_info(&lcd->smart); ret = s6e8ax0_read_mtp(lcd, mtp_data); if (!ret) { printk("[LCD:ERROR] : %s read mtp failed\n", __func__); - //return -1; + lcd->connected = 0; + dev_info(&lcd->ld->dev, "panel is not connected well\n"); + /*return -1;*/ } calc_voltage_table(&lcd->smart, mtp_data); s6e8ax0_adb_brightness_update(lcd, lcd->bd->props.brightness, 1); #endif - if (id_buf[0] == 0xa2) { - lcd->connected = 1; + if (lcd->connected) { INIT_DELAYED_WORK(&hs_clk_re_try, hs_clk_re_try_work); lcd->irq = gpio_to_irq(GPIO_OLED_DET); s3c_gpio_cfgpin(GPIO_OLED_DET, S3C_GPIO_SFN(0xf)); s3c_gpio_setpull(GPIO_OLED_DET, S3C_GPIO_PULL_NONE); @@ -1384,15 +1401,12 @@ if (request_irq(lcd->irq, oled_det_int, IRQF_TRIGGER_FALLING, "vgh_toggle", 0)) { pr_err("failed to reqeust irq. %d\n", lcd->irq); ret = -EINVAL; goto out_free_backlight; } - } else { - lcd->connected = 0; - dev_info(&lcd->ld->dev, "panel is not connected\n"); } return 0; out_free_backlight: lcd_device_unregister(lcd->ld);
Code: --- drivers/video/samsung/s5p-dsim.c 2011-10-20 02:58:50.000000000 +++ drivers/video/samsung/s5p-dsim.c 2011-10-25 17:58:10.000000000 @@ -115,13 +115,13 @@ #define MIPI_CMD_GENERIC_RD_2 0x24 #define MIPI_CMD_DSI_RD_0 0x06 #define MIPI_CMD_DSI_SET_PKT_SZ 0x37 -#define MIPI_RX_TIMEOUT HZ +#define MIPI_RX_TIMEOUT msecs_to_jiffies(250) #define DSMI_RX_FIFO_READ_DONE 0x30800002 #define DSIM_MAX_RX_FIFO 20 #define S5P_DSIM_INT_SFR_FIFO_EMPTY 29 #define S5P_DSIM_INT_BTA 25 #define S5P_DSIM_INT_MSK_FRAME_DONE 24 @@ -358,13 +358,13 @@ } rxhd = readl(reg_base + S5P_DSIM_RXFIFO); printk("rxhd : %x\n", rxhd); if ((u8)(rxhd & 0xff) != response) { printk(KERN_ERR "[DSIM:ERROR]:%s wrong response rxhd : %x, response:%x\n" - ,__func__, rxhd, response); + , __func__, rxhd, response); goto clear_rx_fifo; } // for short packet if (count <= 2) { for (i = 0; i < count; i++) buf[i] = (rxhd >> (8+(i*8))) & 0xff; @@ -379,21 +379,21 @@ goto clear_rx_fifo; } for (i = 0; i < rxsize>>2; i++) { temp = readl(reg_base + S5P_DSIM_RXFIFO); printk("pkt : %08x\n", temp); - for(j=0; j < 4; j++) { + for (j = 0; j < 4; j++) { buf[(i*4)+j] = (u8)(temp>>(j*8))&0xff; //printk("Value : %02x\n",(temp>>(j*8))&0xff); } } if (rxsize % 4) { temp = readl(reg_base + S5P_DSIM_RXFIFO); printk("pkt-l : %08x\n", temp); - for(j=0; j < rxsize%4; j++) { + for (j = 0; j < rxsize%4; j++) { buf[(i*4)+j] = (u8)(temp>>(j*8))&0xff; //printk("Value : %02x\n",(temp>>(j*8))&0xff); } } } @@ -1089,30 +1089,30 @@ writel(int_stat, dsim.reg_base + S5P_DSIM_INTMSK); } int s5p_dsim_fifo_clear(void) { - int dsim_count=0,ret; + int dsim_count = 0, ret; writel(SwRstRelease, dsim.reg_base + S5P_DSIM_INTSRC); - + writel(DSIM_FUNCRST, dsim.reg_base + S5P_DSIM_SWRST); - do{ - if(++dsim_count>90000){ - printk("dsim fifo clear fail re_try dsim resume\n"); - ret=0; + do { + if (++dsim_count > 90000) { + printk("dsim fifo clear fail re_try dsim resume\n"); + ret = 0; break; - } - - if(readl(dsim.reg_base + S5P_DSIM_INTSRC) & SwRstRelease){ - s5p_dsim_interrupt_mask_set(); - ret=1; + } + + if (readl(dsim.reg_base + S5P_DSIM_INTSRC) & SwRstRelease) { + s5p_dsim_interrupt_mask_set(); + ret = 1; break; } - }while(1); + } while (1); return ret; } #ifdef CONFIG_HAS_EARLYSUSPEND void s5p_dsim_early_suspend(void) @@ -1140,24 +1140,24 @@ if (dsim.mipi_drv->suspend) dsim.mipi_drv->suspend(dsim.dev, state); if (dsim.mipi_ddi_pd->lcd_power_on) dsim.mipi_ddi_pd->lcd_power_on(dsim.dev, 0); - + s5p_dsim_enable_hs_clock(dsim.reg_base, 0); s5p_dsim_set_clock(dsim.reg_base, dsim.dsim_info->e_byte_clk, 0); - + writel(0xffff, dsim.reg_base + S5P_DSIM_CLKCTRL); writel(0x0, dsim.reg_base + S5P_DSIM_PLLCTRL); writel(0x0, dsim.reg_base + S5P_DSIM_PLLTMR); writel(0x0, dsim.reg_base + S5P_DSIM_PHYACCHR); - writel(0x0, dsim.reg_base + S5P_DSIM_PHYACCHR1); + writel(0x0, dsim.reg_base + S5P_DSIM_PHYACCHR1); writel(0x1, dsim.reg_base + S5P_DSIM_SWRST); - + clk_disable(dsim.clock); #if 0 if (dsim.pd->mipi_power) dsim.pd->mipi_power(0); else
Code: --- drivers/video/samsung/s6e8aa0_param.h 2011-10-20 02:58:50.000000000 +++ drivers/video/samsung/s6e8aa0_param.h 2011-10-25 17:58:10.000000000 @@ -66,13 +66,14 @@ static const unsigned char SEQ_APPLY_LEVEL_2_KEY[] = { 0xFC, 0x5A, 0x5A }; static const unsigned char SEQ_SLEEP_OUT[] = { - 0x11 + 0x11, + 0x00,0x00 }; static const unsigned char SEQ_PANEL_CONDITION_SET[] = { 0xF8, 0x25, 0x34, 0x00, 0x00, 0x00, 0x95, 0x00, 0x3C, 0x7D, 0x08, 0x27, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, @@ -83,13 +84,14 @@ static const unsigned char SEQ_DISPLAY_CONDITION_SET[] = { 0xF2, 0x80, 0x03, 0x0D }; static const unsigned char SEQ_GAMMA_UPDATE[] = { - 0xF7, 0x03 + 0xF7, 0x03, + 0x00 }; static const unsigned char SEQ_ETC_SOURCE_CONTROL[] = { 0xF6, 0x00, 0x02, 0x00 }; @@ -116,30 +118,35 @@ 0x14, 0x40, 0x0C, 0xCB, 0xCE, 0x6E, 0xC4, 0x0F, 0x40, 0x41, 0xD9, 0x00, 0x00, 0x00 }; static const unsigned char SEQ_DISPLAY_ON[] = { - 0x29 + 0x29, + 0x00,0x00 }; static const unsigned char SEQ_DISPLAY_OFF[] = { - 0x28 + 0x28, + 0x00,0x00 }; static const unsigned char SEQ_STANDBY_ON[] = { - 0x01 + 0x01, + 0x00,0x00 }; static const unsigned char SEQ_ACL_ON[] = { 0xC0, 0x01, + 0x00 }; static const unsigned char SEQ_ACL_OFF[] = { 0xC0, 0x00, + 0x00 }; static const unsigned char SEQ_ACL_CUTOFF_20[] = { 0xC1, 0x47, 0x53, 0x13, 0x53, 0x00, 0x00, 0x03, 0x1F, 0x00, 0x00,
and they changed to codesourcery for toolchain +CROSS_COMPILE ?= /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi- Not a massive amount of differences, the screen driver changes looks most interesting to me.
fards said: and they changed to codesourcery for toolchain +CROSS_COMPILE ?= /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi- Not a massive amount of differences, the screen driver changes looks most interesting to me. Click to expand... Click to collapse Is there a new kernel source? Sent from my GT-I9100
yes, kj6 is up, the diffs are between kj4 and that kj6 to show the file differences (there's also some docs changes but they aren't really needed)
fards said: yes, kj6 is up, the diffs are between kj4 and that kj6 to show the file differences (there's also some docs changes but they aren't really needed) Click to expand... Click to collapse Where did you get the kernel source?
https://opensource.samsung.com/index.jsp search for N7000 I presume the kkx build will be there under the other device code.
fards said: https://opensource.samsung.com/index.jsp search for N7000 I presume the kkx build will be there under the other device code. Click to expand... Click to collapse LOL you have the Hong Kong version source code xD
netchip said: LOL you have the Hong Kong version source code xD Click to expand... Click to collapse kj6 as I said... to compare against kj4 as 6 is supposed to bring bugfixes..
fards said: Not a massive amount of differences, the screen driver changes looks most interesting to me. Click to expand... Click to collapse Maybe that diff solves my screen issue. Just to explain, sometimes my screen does not wake up even if the phone is still running (long pressing the on/off button makes the phone vibrate which means that it is still working) and when I hard reboot it (8 seconds long on/off button press), it restarts and in the battery usage I can see that the phone has been awake for a long time instead of having been idle (when it happens, it is generally during the night). As I am facing it globally (with both European stock and Hong Kong ROMs), I hope this kernel change corrects it.
The_Steph said: Maybe that diff solves my screen issue. Just to explain, sometimes my screen does not wake up even if the phone is still running (long pressing the on/off button makes the phone vibrate which means that it is still working) and when I hard reboot it (8 seconds long on/off button press), it restarts and in the battery usage I can see that the phone has been awake for a long time instead of having been idle (when it happens, it is generally during the night). As I am facing it globally (with both European stock and Hong Kong ROMs), I hope this kernel change corrects it. Click to expand... Click to collapse I've seen the same thing a couple of times. Still haven't tested the KJ6 kernel to see the effect of those patches yet.
Actually thats spurred me onto testing the KJ6.. Initialtesting suggests Screen powers back up Much quicker from standby
KJ6, where did you get it? Edit: I have Baseband version N7000XXKJ6 but Kernel N7000ZSKK1. Is is this version you are talking about?
The_Steph said: KJ6, where did you get it? Edit: I have Baseband version N7000XXKJ6 but Kernel N7000ZSKK1. Is is this version you are talking about? Click to expand... Click to collapse no there's threads with the kj6 kernel, including the CF root thread. I've just built kernel with the patches, working well so far.
Basically, what you did is you installed KJ6 kernel, rooted it and install the kernel you built? If yes, do you mind, allowing me to download the kernel you built in order to use it?
[Q]scan for ble device
I'm trying to develop an app to scan for a BLE device. However, it only scans one time. I tried to use a while loop to loop it but it hangs there. The scanning part is at the proceed function: Code: package com.example.user.myfriend; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothManager; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.os.Handler; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import org.w3c.dom.Text; public class MainActivity extends ActionBarActivity { BluetoothAdapter mBluetoothAdapter; @Override protected void onCreate(Bundle savedInstanceState) { BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); hello(); } public void hello() { if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) { Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBluetooth, 1); } proceed(); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == RESULT_OK) { proceed(); } } super.onActivityResult(requestCode, resultCode, data); } private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) { int startByte = 2; boolean patternFound = false; while (startByte <= 5) { if (((int) scanRecord[startByte + 2] & 0xff) == 0x02 && //Identifies an iBeacon ((int) scanRecord[startByte + 3] & 0xff) == 0x15) { //Identifies correct data length patternFound = true; break; } startByte++; } if (patternFound) { //Convert to hex String byte[] uuidBytes = new byte[16]; System.arraycopy(scanRecord, startByte + 4, uuidBytes, 0, 16); String hexString = bytesToHex(uuidBytes); //Here is your UUID String uuid = hexString.substring(0, 8) + "-" + hexString.substring(8, 12) + "-" + hexString.substring(12, 16) + "-" + hexString.substring(16, 20) + "-" + hexString.substring(20, 32); //Here is your Major value int major = (scanRecord[startByte + 20] & 0xff) * 0x100 + (scanRecord[startByte + 21] & 0xff); //Here is your Minor value int minor = (scanRecord[startByte + 22] & 0xff) * 0x100 + (scanRecord[startByte + 23] & 0xff); if (major == 1) { RelativeLayout hai = (RelativeLayout) findViewById(R.id.hai); hai.setBackgroundColor(Color.YELLOW); } if (major == 2) { RelativeLayout hai = (RelativeLayout) findViewById(R.id.hai); hai.setBackgroundColor(Color.RED); } } } }; private static String bytesToHex(byte[] bytes) { final char[] hexArray = "0123456789ABCDEF".toCharArray(); char[] hexChars = new char[bytes.length * 2]; for (int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2 + 1] = hexArray[v & 0x0F]; } return new String(hexChars); } public void proceed() { boolean scanning = true; mBluetoothAdapter.startLeScan(mLeScanCallback); Handler handler = new Handler(); handler.postDelayed(new Runnable() { // @Override public void run() { mBluetoothAdapter.stopLeScan(mLeScanCallback); } }, 50000000); } Code:
Need help with Thunderplug hotplug compilation
As it states I am trying to add Thundeplug to my hotplug. Heres the code. /* Copyright (c) 2015, Varun Chitre <[email protected]> * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * A simple hotplugging driver. * Compatible from dual core CPUs to Octa Core CPUs */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/hrtimer.h> #include <linux/init.h> #include <linux/device.h> #include <linux/input.h> #include <linux/slab.h> #include <linux/cpu.h> #include <linux/lcd_notify.h> #include <linux/cpufreq.h> #include "thunderplug.h" #define DEBUG 0 #define THUNDERPLUG "thunderplug" #define DRIVER_VERSION 5 #define DRIVER_SUBVER 0 #define DEFAULT_CPU_LOAD_THRESHOLD (65) #define MIN_CPU_LOAD_THRESHOLD (10) #define HOTPLUG_ENABLED (0) #define DEFAULT_HOTPLUG_STYLE HOTPLUG_SCHED #define DEFAULT_SCHED_MODE BALANCED #define DEF_SAMPLING_MS (500) #define MIN_SAMLING_MS (50) #define MIN_CPU_UP_TIME (750) #define TOUCH_BOOST_ENABLED (0) static bool isSuspended = false; struct notifier_block lcd_worker; static int suspend_cpu_num = 2, resume_cpu_num = (NR_CPUS -1); static int endurance_level = 0; static int core_limit = NR_CPUS; static int now[8], last_time[8]; static int sampling_time = DEF_SAMPLING_MS; static int load_threshold = DEFAULT_CPU_LOAD_THRESHOLD; static int stop_boost = 0; struct cpufreq_policy old_policy[NR_CPUS]; #ifdef CONFIG_SCHED_HMP static int tplug_hp_style = DEFAULT_HOTPLUG_STYLE; #else static int tplug_hp_enabled = HOTPLUG_ENABLED; #endif static int tplug_sched_mode = DEFAULT_SCHED_MODE; static int touch_boost_enabled = TOUCH_BOOST_ENABLED; static struct workqueue_struct *tplug_wq; static struct delayed_work tplug_work; static struct workqueue_struct *tplug_boost_wq; static struct delayed_work tplug_boost; static struct workqueue_struct *tplug_resume_wq; static struct delayed_work tplug_resume_work; static unsigned int last_load[8] = { 0 }; struct cpu_load_data { u64 prev_cpu_idle; u64 prev_cpu_wall; unsigned int avg_load_maxfreq; unsigned int cur_load_maxfreq; unsigned int samples; unsigned int window_size; cpumask_var_t related_cpus; }; static DEFINE_PER_CPU(struct cpu_load_data, cpuload); /* Two Endurance Levels for Octa Cores, * Two for Quad Cores and * One for Dual */ static inline void offline_cpus(void) { unsigned int cpu; switch(endurance_level) { case 1: if(suspend_cpu_num > NR_CPUS / 2 ) suspend_cpu_num = NR_CPUS / 2; break; case 2: if( NR_CPUS >=4 && suspend_cpu_num > NR_CPUS / 4) suspend_cpu_num = NR_CPUS / 4; break; default: break; } for(cpu = NR_CPUS - 1; cpu > (suspend_cpu_num - 1); cpu--) { if (cpu_online(cpu)) cpu_down(cpu); } pr_info("%s: %d cpus were offlined\n", THUNDERPLUG, (NR_CPUS - suspend_cpu_num)); } static inline void cpus_online_all(void) { unsigned int cpu; switch(endurance_level) { case 1: if(resume_cpu_num > (NR_CPUS / 2) - 1 || resume_cpu_num == 1) resume_cpu_num = ((NR_CPUS / 2) - 1); break; case 2: if( NR_CPUS >= 4 && resume_cpu_num > ((NR_CPUS / 4) - 1)) resume_cpu_num = ((NR_CPUS / 4) - 1); break; case 0: resume_cpu_num = (NR_CPUS - 1); break; default: break; } if(DEBUG) pr_info("%s: resume_cpu_num = %d\n",THUNDERPLUG, resume_cpu_num); for (cpu = 1; cpu <= resume_cpu_num; cpu++) { if (cpu_is_offline(cpu)) cpu_up(cpu); } pr_info("%s: all cpus were onlined\n", THUNDERPLUG); } static void __ref tplug_boost_work_fn(struct work_struct *work) { struct cpufreq_policy policy; int cpu, ret; for(cpu = 1; cpu < NR_CPUS; cpu++) { #ifdef CONFIG_SCHED_HMP if(tplug_hp_style == 1) #else if(tplug_hp_enabled == 1) #endif if(cpu_is_offline(cpu)) cpu_up(cpu); ret = cpufreq_get_policy(&policy, cpu); if (ret) continue; old_policy[cpu] = policy; policy.min = policy.max; cpufreq_update_policy(cpu); } if(stop_boost == 0) queue_delayed_work_on(0, tplug_boost_wq, &tplug_boost, msecs_to_jiffies(10)); } static void tplug_input_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) { if (type == EV_KEY && code == BTN_TOUCH) { if(DEBUG) pr_info("%s : type = %d, code = %d, value = %d\n", THUNDERPLUG, type, code, value); if(value == 0) { stop_boost = 1; if(DEBUG) pr_info("%s: stopping boost\n", THUNDERPLUG); } else { stop_boost = 0; if(DEBUG) pr_info("%s: starting boost\n", THUNDERPLUG); } } #ifdef CONFIG_SCHED_HMP if ((type == EV_KEY) && (code == BTN_TOUCH) && (value == 1) && touch_boost_enabled == 1) #else if ((type == EV_KEY) && (code == BTN_TOUCH) && (value == 1) && touch_boost_enabled == 1) #endif { if(DEBUG) pr_info("%s : touch boost\n", THUNDERPLUG); queue_delayed_work_on(0, tplug_boost_wq, &tplug_boost, msecs_to_jiffies(0)); } } static int tplug_input_connect(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id) { struct input_handle *handle; int error; handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); if (!handle) return -ENOMEM; handle->dev = dev; handle->handler = handler; handle->name = "cpufreq"; error = input_register_handle(handle); if (error) goto err2; error = input_open_device(handle); if (error) goto err1; return 0; err1: input_unregister_handle(handle); err2: kfree(handle); return error; } static void tplug_input_disconnect(struct input_handle *handle) { input_close_device(handle); input_unregister_handle(handle); kfree(handle); } static const struct input_device_id tplug_ids[] = { { .driver_info = 1 }, { }, }; static struct input_handler tplug_input_handler = { .event = tplug_input_event, .connect = tplug_input_connect, .disconnect = tplug_input_disconnect, .name = "tplug_handler", .id_table = tplug_ids, }; static ssize_t thunderplug_suspend_cpus_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", suspend_cpu_num); } static ssize_t thunderplug_suspend_cpus_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val; sscanf(buf, "%d", &val); if(val < 1 || val > NR_CPUS) pr_info("%s: suspend cpus off-limits\n", THUNDERPLUG); else suspend_cpu_num = val; return count; } static ssize_t thunderplug_endurance_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", endurance_level); } static ssize_t __ref thunderplug_endurance_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val; sscanf(buf, "%d", &val); if(tplug_hp_style == 1) { switch(val) { case 0: case 1: case 2: if(endurance_level!=val && !(endurance_level > 1 && NR_CPUS < 4)) { endurance_level = val; offline_cpus(); cpus_online_all(); } break; default: pr_info("%s: invalid endurance level\n", THUNDERPLUG); break; } } else pr_info("%s: per-core hotplug style is disabled, ignoring endurance mode values\n", THUNDERPLUG); return count; } static ssize_t thunderplug_sampling_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", sampling_time); } static ssize_t __ref thunderplug_sampling_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val; sscanf(buf, "%d", &val); if(val > MIN_SAMLING_MS) sampling_time = val; return count; } static ssize_t thunderplug_tb_enabled_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", touch_boost_enabled); } static ssize_t __ref thunderplug_tb_enabled_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val; sscanf(buf, "%d", &val); switch(val) { case 0: case 1: touch_boost_enabled = val; break; default: pr_info("%s : invalid choice\n", THUNDERPLUG); break; } return count; } static ssize_t thunderplug_load_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", load_threshold); } static ssize_t __ref thunderplug_load_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val; sscanf(buf, "%d", &val); if(val > 10) load_threshold = val; return count; } static unsigned int get_curr_load(unsigned int cpu) { int ret; unsigned int idle_time, wall_time; unsigned int cur_load; u64 cur_wall_time, cur_idle_time; struct cpu_load_data *pcpu = &per_cpu(cpuload, cpu); struct cpufreq_policy policy; ret = cpufreq_get_policy(&policy, cpu); if (ret) return -EINVAL; cur_idle_time = get_cpu_idle_time(cpu, &cur_wall_time, 0); wall_time = (unsigned int) (cur_wall_time - pcpu->prev_cpu_wall); pcpu->prev_cpu_wall = cur_wall_time; idle_time = (unsigned int) (cur_idle_time - pcpu->prev_cpu_idle); pcpu->prev_cpu_idle = cur_idle_time; if (unlikely(!wall_time || wall_time < idle_time)) return 0; cur_load = 100 * (wall_time - idle_time) / wall_time; return cur_load; } static void thunderplug_suspend(void) { offline_cpus(); pr_info("%s: suspend\n", THUNDERPLUG); } static void __ref thunderplug_resume(void) { cpus_online_all(); pr_info("%s: resume\n", THUNDERPLUG); } static void __cpuinit tplug_resume_work_fn(struct work_struct *work) { thunderplug_resume(); } static void __cpuinit tplug_work_fn(struct work_struct *work) { int i; unsigned int load[8], avg_load[8]; switch(endurance_level) { case 0: core_limit = NR_CPUS; break; case 1: core_limit = NR_CPUS / 2; break; case 2: core_limit = NR_CPUS / 4; break; default: core_limit = NR_CPUS; break; } for(i = 0 ; i < core_limit; i++) { if(cpu_online(i)) load = get_curr_load(i); else load = 0; avg_load = ((int) load + (int) last_load) / 2; last_load = load; } for(i = 0 ; i < core_limit; i++) { if(cpu_online(i) && avg_load > load_threshold && cpu_is_offline(i+1)) { if(DEBUG) pr_info("%s : bringing back cpu%d\n", THUNDERPLUG,i); if(!((i+1) > 7)) { last_time[i+1] = ktime_to_ms(ktime_get()); cpu_up(i+1); } } else if(cpu_online(i) && avg_load < load_threshold && cpu_online(i+1)) { if(DEBUG) pr_info("%s : offlining cpu%d\n", THUNDERPLUG,i); if(!(i+1)==0) { now[i+1] = ktime_to_ms(ktime_get()); if((now[i+1] - last_time[i+1]) > MIN_CPU_UP_TIME) cpu_down(i+1); } } } #ifdef CONFIG_SCHED_HMP if(tplug_hp_style == 1 && !isSuspended) #else if(tplug_hp_enabled != 0 && !isSuspended) #endif queue_delayed_work_on(0, tplug_wq, &tplug_work, msecs_to_jiffies(sampling_time)); else { if(!isSuspended) cpus_online_all(); else thunderplug_suspend(); } } static int lcd_notifier_callback(struct notifier_block *nb, unsigned long event, void *data) { switch (event) { case LCD_EVENT_ON_START: isSuspended = false; #ifdef CONFIG_SCHED_HMP if(tplug_hp_style==1) #else if(tplug_hp_enabled) #endif queue_delayed_work_on(0, tplug_wq, &tplug_work, msecs_to_jiffies(sampling_time)); else queue_delayed_work_on(0, tplug_resume_wq, &tplug_resume_work, msecs_to_jiffies(10)); pr_info("thunderplug : resume called\n"); break; case LCD_EVENT_ON_END: break; case LCD_EVENT_OFF_START: break; case LCD_EVENT_OFF_END: isSuspended = true; pr_info("thunderplug : suspend called\n"); break; default: break; } return 0; } /* Thunderplug load balancer */ #ifdef CONFIG_SCHED_HMP static void set_sched_profile(int mode) { switch(mode) { case 1: /* Balanced */ sched_set_boost(DISABLED); break; case 2: /* Turbo */ sched_set_boost(ENABLED); break; default: pr_info("%s: Invalid mode\n", THUNDERPLUG); break; } } static ssize_t thunderplug_sched_mode_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", tplug_sched_mode); } static ssize_t __ref thunderplug_sched_mode_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val; sscanf(buf, "%d", &val); set_sched_profile(val); tplug_sched_mode = val; return count; } static ssize_t thunderplug_hp_style_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", tplug_hp_style); } static ssize_t __ref thunderplug_hp_style_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val, last_val; sscanf(buf, "%d", &val); last_val = tplug_hp_style; switch(val) { case HOTPLUG_PERCORE: case HOTPLUG_SCHED: tplug_hp_style = val; break; default: pr_info("%s : invalid choice\n", THUNDERPLUG); break; } if(tplug_hp_style == HOTPLUG_PERCORE && tplug_hp_style != last_val) { pr_info("%s: Switching to Per-core hotplug model\n", THUNDERPLUG); sched_set_boost(DISABLED); queue_delayed_work_on(0, tplug_wq, &tplug_work, msecs_to_jiffies(sampling_time)); } else if(tplug_hp_style==2) { pr_info("%s: Switching to sched based hotplug model\n", THUNDERPLUG); set_sched_profile(tplug_sched_mode); } return count; } static struct kobj_attribute thunderplug_hp_style_attribute = __ATTR(hotplug_style, 0666, thunderplug_hp_style_show, thunderplug_hp_style_store); static struct kobj_attribute thunderplug_mode_attribute = __ATTR(sched_mode, 0666, thunderplug_sched_mode_show, thunderplug_sched_mode_store); #else static ssize_t thunderplug_hp_enabled_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d", tplug_hp_enabled); } static ssize_t __ref thunderplug_hp_enabled_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int val; sscanf(buf, "%d", &val); int last_val = tplug_hp_enabled; switch(val) { case 0: case 1: tplug_hp_enabled = val; break; default: pr_info("%s : invalid choice\n", THUNDERPLUG); break; } if(tplug_hp_enabled == 1 && tplug_hp_enabled != last_val) queue_delayed_work_on(0, tplug_wq, &tplug_work, msecs_to_jiffies(sampling_time)); return count; } static struct kobj_attribute thunderplug_hp_enabled_attribute = __ATTR(hotplug_enabled, 0666, thunderplug_hp_enabled_show, thunderplug_hp_enabled_store); #endif static ssize_t thunderplug_ver_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "ThunderPlug %u.%u", DRIVER_VERSION, DRIVER_SUBVER); } static struct kobj_attribute thunderplug_ver_attribute = __ATTR(version, 0444, thunderplug_ver_show, NULL); static struct kobj_attribute thunderplug_suspend_cpus_attribute = __ATTR(suspend_cpus, 0666, thunderplug_suspend_cpus_show, thunderplug_suspend_cpus_store); static struct kobj_attribute thunderplug_endurance_attribute = __ATTR(endurance_level, 0666, thunderplug_endurance_show, thunderplug_endurance_store); static struct kobj_attribute thunderplug_sampling_attribute = __ATTR(sampling_rate, 0666, thunderplug_sampling_show, thunderplug_sampling_store); static struct kobj_attribute thunderplug_load_attribute = __ATTR(load_threshold, 0666, thunderplug_load_show, thunderplug_load_store); static struct kobj_attribute thunderplug_tb_enabled_attribute = __ATTR(touch_boost, 0666, thunderplug_tb_enabled_show, thunderplug_tb_enabled_store); static struct attribute *thunderplug_attrs[] = { &thunderplug_ver_attribute.attr, &thunderplug_suspend_cpus_attribute.attr, &thunderplug_endurance_attribute.attr, &thunderplug_sampling_attribute.attr, &thunderplug_load_attribute.attr, #ifdef CONFIG_SCHED_HMP &thunderplug_mode_attribute.attr, &thunderplug_hp_style_attribute.attr, #else &thunderplug_hp_enabled_attribute.attr, #endif &thunderplug_tb_enabled_attribute.attr, NULL, }; static struct attribute_group thunderplug_attr_group = { .attrs = thunderplug_attrs, }; static struct kobject *thunderplug_kobj; static int __init thunderplug_init(void) { int ret = 0; int sysfs_result; printk(KERN_DEBUG "[%s]\n",__func__); thunderplug_kobj = kobject_create_and_add("thunderplug", kernel_kobj); if (!thunderplug_kobj) { pr_err("%s Interface create failed!\n", __FUNCTION__); return -ENOMEM; } sysfs_result = sysfs_create_group(thunderplug_kobj, &thunderplug_attr_group); if (sysfs_result) { pr_info("%s sysfs create failed!\n", __FUNCTION__); kobject_put(thunderplug_kobj); } lcd_worker.notifier_call = lcd_notifier_callback; lcd_register_client(&lcd_worker); pr_info("%s : registering input boost", THUNDERPLUG); ret = input_register_handler(&tplug_input_handler); if (ret) { pr_err("%s: Failed to register input handler: %d\n", THUNDERPLUG, ret); } tplug_wq = alloc_workqueue("tplug", WQ_HIGHPRI | WQ_UNBOUND, 1); tplug_resume_wq = alloc_workqueue("tplug_resume", WQ_HIGHPRI | WQ_UNBOUND, 1); tplug_boost_wq = alloc_workqueue("tplug_boost", WQ_HIGHPRI | WQ_UNBOUND, 1); INIT_DELAYED_WORK(&tplug_work, tplug_work_fn); INIT_DELAYED_WORK(&tplug_resume_work, tplug_resume_work_fn); INIT_DELAYED_WORK(&tplug_boost, tplug_boost_work_fn); queue_delayed_work_on(0, tplug_wq, &tplug_work, msecs_to_jiffies(10)); pr_info("%s: init\n", THUNDERPLUG); return ret; } MODULE_LICENSE("GPL and additional rights"); MODULE_AUTHOR("Varun Chitre <[email protected]>"); MODULE_DESCRIPTION("Hotplug driver for ARM SoCs"); late_initcall(thunderplug_init); Here is my error. CC arch/arm/mach-msm/thunderplug.o arch/arm/mach-msm/thunderplug.c: In function 'thunderplug_endurance_store': arch/arm/mach-msm/thunderplug.c:283:5: error: 'tplug_hp_style' undeclared (first use in this function) if(tplug_hp_style == 1) { ^ arch/arm/mach-msm/thunderplug.c:283:5: note: each undeclared identifier is reported only once for each function it appears in arch/arm/mach-msm/thunderplug.c: In function 'thunderplug_hp_enabled_store': arch/arm/mach-msm/thunderplug.c:598:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] error, forbidden warning: thunderplug.c:598 make[1]: *** [arch/arm/mach-msm/thunderplug.o] Error 1 make[1]: *** Waiting for unfinished jobs.... Any help would be appreciated
http://forum.xda-developers.com/nexus-6/devs-only
[REQUEST] BLOCK/DISABLE Pull-down Quick Toggle on Secure Lockscreen
Maybe any devs can adapt this for Magisk module? https://github.com/char101/xposed-q...main/java/com/github/char101/qslock/Main.java Code: package com.github.char101.qslock; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import android.util.Log; public class Main implements IXposedHookLoadPackage { private static final String TAG = "qslock"; private static final int DISABLE_EXPAND = 0x00010000; private static final int DISABLE_NOTIFICATION_ICONS = 0x00020000; private static final int DISABLE_NOTIFICATION_ALERTS = 0x00040000; private static final int DISABLE_NOTIFICATION_TICKER = 0x00080000; private static final int DISABLE_SYSTEM_INFO = 0x00100000; private static final int DISABLE_HOME = 0x00200000; private static final int DISABLE_RECENT = 0x01000000; private static final int DISABLE_BACK = 0x00400000; private static final int DISABLE_CLOCK = 0x00800000; private static final int DISABLE_SEARCH = 0x02000000; private static final int DISABLE_NONE = 0x00000000; private static final int DISABLE2_QUICK_SETTINGS = 1; private static final int DISABLE2_SYSTEM_ICONS = 1 << 1; private static final int DISABLE2_NOTIFICATION_SHADE = 1 << 2; private static final int DISABLE2_GLOBAL_ACTIONS = 1 << 3; private static final int DISABLE2_ROTATE_SUGGESTIONS = 1 << 4; private static final int DISABLE2_NONE = 0x00000000; public int getProp(Class<?> SystemProperties, String name, int defaultValue) { String val = (String) XposedHelpers.callStaticMethod(SystemProperties, "get", new Class<?>[]{String.class}, name); try { return val.equals("") ? defaultValue : Integer.parseInt(val); } catch (NumberFormatException ex) { Log.e(TAG, "invalid value for " + name + ": " + val); return defaultValue; } } public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable { if (!lpparam.packageName.equals("com.android.systemui")) { return; } XposedBridge.log(TAG + ": started"); final Class<?> SystemProperties = XposedHelpers.findClass("android.os.SystemProperties", null); XposedHelpers.findAndHookMethod("com.android.systemui.keyguard.KeyguardViewMediator", lpparam.classLoader, "adjustStatusBarLocked", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Object mStatusBarManager = XposedHelpers.getObjectField(param.thisObject, "mStatusBarManager"); if (mStatusBarManager != null) { boolean mShowing = (boolean) XposedHelpers.getBooleanField(param.thisObject, "mShowing"); final int mode2 = getProp(SystemProperties,"persist.qslock.mode2", DISABLE2_QUICK_SETTINGS); if (mShowing) { final int mode = getProp(SystemProperties,"persist.qslock.mode", 0); if (mode > 0) { Log.i(TAG, "disable: " + mode); XposedHelpers.callMethod(mStatusBarManager, "disable", new Class<?>[]{int.class}, mode); } if (mode2 > 0) { Log.i(TAG, "disable2: " + mode2); XposedHelpers.callMethod(mStatusBarManager, "disable2", new Class<?>[]{int.class}, mode2); } } else { if (mode2 > 0) { XposedHelpers.callMethod(mStatusBarManager, "disable2", new Class<?>[]{int.class}, DISABLE2_NONE); } } } else { Log.e(TAG, "mStatusBarManager is null"); } } }); } }
Crescendo Xenomorph said: Maybe any devs can adapt this for Magisk module? https://github.com/char101/xposed-q...main/java/com/github/char101/qslock/Main.java Click to expand... Click to collapse Not possible,Xposed alters code while magisk alters files,you can't convert an Xposed module into a magisk module Sent from my Moto G 2015 using XDA Labs
DanGLES3 said: Not possible,Xposed alters code while magisk alters files,you can't convert an Xposed module into a magisk module Sent from my Moto G 2015 using XDA Labs Click to expand... Click to collapse or maybe a cue of what code in what smali that it replaces? Sent from my MI 5s Plus using Tapatalk
[HELP] why Zygisk need to force dlopen /system/bin/app_process
1. Why use android_dlopen_ext in the first_stage_entry function to force open /system/bin/app_process? 2. Why dlclose immediately after dlopen in second_stage_entry? Why do it? // native/jni/zygisk/entry.cpp static void first_stage_entry() { android_logging(); ZLOGD("inject 1st stage\n"); char path[PATH_MAX]; char buf[256]; char *ld = getenv("LD_PRELOAD"); if (char *c = strrchr(ld, ':')) { *c = '\0'; strlcpy(path, c + 1, sizeof(path)); setenv("LD_PRELOAD", ld, 1); // Restore original LD_PRELOAD } else { unsetenv("LD_PRELOAD"); strlcpy(path, ld, sizeof(path)); } // Force the linker to load the library on top of ourselves, so we do not // need to unmap the 1st stage library that was loaded with LD_PRELOAD. int fd = xopen(path, O_RDONLY | O_CLOEXEC); // Use fd here instead of path to make sure inode is the same as 2nd stage snprintf(buf, sizeof(buf), "%d", fd); setenv(MAGISKFD_ENV, buf, 1); struct stat s{}; xfstat(fd, &s); android_dlextinfo info { .flags = ANDROID_DLEXT_FORCE_LOAD | ANDROID_DLEXT_USE_LIBRARY_FD, .library_fd = fd, }; // 通过 inode 在 maps 中搜索 /sbin/magisk(app_process) 对应的内存区域 auto [addr, size] = find_map_range(path, s.st_ino); if (addr && size) { // 下面使用 android_dlopen_ext 重复加载 /sbin/magisk, // 通过 reserved_addr 强制覆盖内存. info.flags |= ANDROID_DLEXT_RESERVED_ADDRESS; info.reserved_addr = addr; // The existing address is guaranteed to fit, as 1st stage and 2nd stage // are exactly the same ELF (same inode). However, the linker could over // estimate the required size and refuse to dlopen. The estimated size // is not accurate so size the size to unlimited. info.reserved_size = -1; } setenv(INJECT_ENV_2, "1", 1); // Force dlopen ourselves to make ourselves dlclose-able. // After this call, all global variables will be reset. // 重复加载 /sbin/magisk 到内存, 覆盖之后全局变量将被重置 // 这里为什么要强制 dlopen? 只是为了以后可以使用 dlclose 释放 zygisk 吗???? android_dlopen_ext(path, RTLD_LAZY, &info); } Code: // // native/jni/zygisk/entry.cpp static void second_stage_entry() { zygisk_logging(); ZLOGD("inject 2nd stage\n"); char path[PATH_MAX]; MAGISKTMP = getenv(MAGISKTMP_ENV); int fd = parse_int(getenv(MAGISKFD_ENV)); snprintf(path, sizeof(path), "/proc/self/fd/%d", fd); xreadlink(path, path, PATH_MAX); android_dlextinfo info { .flags = ANDROID_DLEXT_USE_LIBRARY_FD, .library_fd = fd, }; // 这里的dlopen并不会重新调用 zygisk_init, 这里是假的dlopen? 只是为了下一行的 dlclose? // 为什么要这样做? // Why do this? self_handle = android_dlopen_ext(path, RTLD_LAZY, &info); dlclose(self_handle); close(fd); unsetenv(MAGISKTMP_ENV); unsetenv(MAGISKFD_ENV); sanitize_environ(); hook_functions(); }