|
@@ -80,6 +80,9 @@ procedure UnhookSignal(RtlSigNum: Integer; OnlyIfHooked: Boolean = True);
|
|
implementation
|
|
implementation
|
|
|
|
|
|
Uses
|
|
Uses
|
|
|
|
+{$ifdef android}
|
|
|
|
+ dl,
|
|
|
|
+{$endif android}
|
|
{$ifdef FPC_USE_LIBC}initc{$ELSE}Syscall{$ENDIF}, Baseunix, unixutil;
|
|
{$ifdef FPC_USE_LIBC}initc{$ELSE}Syscall{$ENDIF}, Baseunix, unixutil;
|
|
|
|
|
|
type
|
|
type
|
|
@@ -1428,7 +1431,6 @@ end;
|
|
|
|
|
|
var
|
|
var
|
|
_HomeDir: string;
|
|
_HomeDir: string;
|
|
- IsNDKLib: boolean;
|
|
|
|
|
|
|
|
Function GetHomeDir : String;
|
|
Function GetHomeDir : String;
|
|
var
|
|
var
|
|
@@ -1438,7 +1440,7 @@ begin
|
|
Result:=_HomeDir;
|
|
Result:=_HomeDir;
|
|
if Result <> '' then
|
|
if Result <> '' then
|
|
exit;
|
|
exit;
|
|
- if IsLibrary then
|
|
|
|
|
|
+ if IsJniLibrary then
|
|
begin
|
|
begin
|
|
// For shared library get the package name of a host Java application
|
|
// For shared library get the package name of a host Java application
|
|
h:=FileOpen('/proc/self/cmdline', fmOpenRead or fmShareDenyNone);
|
|
h:=FileOpen('/proc/self/cmdline', fmOpenRead or fmShareDenyNone);
|
|
@@ -1449,8 +1451,8 @@ begin
|
|
SetLength(Result, strlen(PChar(Result)));
|
|
SetLength(Result, strlen(PChar(Result)));
|
|
FileClose(h);
|
|
FileClose(h);
|
|
Result:='/data/data/' + Result;
|
|
Result:='/data/data/' + Result;
|
|
- IsNDKLib:=DirectoryExists(Result);
|
|
|
|
- if IsNDKLib then
|
|
|
|
|
|
+ IsJniLibrary:=DirectoryExists(Result);
|
|
|
|
+ if IsJniLibrary then
|
|
Result:=Result + '/files/'
|
|
Result:=Result + '/files/'
|
|
else
|
|
else
|
|
Result:=''; // No package
|
|
Result:=''; // No package
|
|
@@ -1497,7 +1499,7 @@ begin
|
|
else
|
|
else
|
|
Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
|
|
Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
|
|
{$ifdef android}
|
|
{$ifdef android}
|
|
- if IsNDKLib then
|
|
|
|
|
|
+ if IsJniLibrary then
|
|
exit;
|
|
exit;
|
|
{$endif android}
|
|
{$endif android}
|
|
if VendorName<>'' then
|
|
if VendorName<>'' then
|
|
@@ -1513,7 +1515,7 @@ begin
|
|
else
|
|
else
|
|
Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
|
|
Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
|
|
{$ifdef android}
|
|
{$ifdef android}
|
|
- if IsNDKLib then
|
|
|
|
|
|
+ if IsJniLibrary then
|
|
begin
|
|
begin
|
|
Result:=Result+'config'+ConfigExtension;
|
|
Result:=Result+'config'+ConfigExtension;
|
|
exit;
|
|
exit;
|
|
@@ -1596,6 +1598,26 @@ begin
|
|
Result := -Tzseconds div 60;
|
|
Result := -Tzseconds div 60;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{$ifdef android}
|
|
|
|
+
|
|
|
|
+procedure InitAndroid;
|
|
|
|
+var
|
|
|
|
+ dlinfo: dl_info;
|
|
|
|
+ s: string;
|
|
|
|
+begin
|
|
|
|
+ if IsJniLibrary then
|
|
|
|
+ begin
|
|
|
|
+ FillChar(dlinfo, sizeof(dlinfo), 0);
|
|
|
|
+ dladdr(@InitAndroid, @dlinfo);
|
|
|
|
+ s:=dlinfo.dli_fname;
|
|
|
|
+ if s <> '' then
|
|
|
|
+ SetDefaultSysLogTag(ExtractFileName(s));
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{$endif android}
|
|
|
|
+
|
|
|
|
+
|
|
{****************************************************************************
|
|
{****************************************************************************
|
|
Initialization code
|
|
Initialization code
|
|
****************************************************************************}
|
|
****************************************************************************}
|
|
@@ -1605,7 +1627,10 @@ Initialization
|
|
InitInternational; { Initialize internationalization settings }
|
|
InitInternational; { Initialize internationalization settings }
|
|
SysConfigDir:='/etc'; { Initialize system config dir }
|
|
SysConfigDir:='/etc'; { Initialize system config dir }
|
|
OnBeep:=@SysBeep;
|
|
OnBeep:=@SysBeep;
|
|
-
|
|
|
|
|
|
+{$ifdef android}
|
|
|
|
+ InitAndroid;
|
|
|
|
+{$endif android}
|
|
|
|
+
|
|
Finalization
|
|
Finalization
|
|
FreeDriveStr;
|
|
FreeDriveStr;
|
|
DoneExceptions;
|
|
DoneExceptions;
|