Ver código fonte

* android: Try to get the package files directory for any shared library. If it is valid use it as a home dir.
* android: Always set the syslog tag.

git-svn-id: trunk@34926 -

yury 8 anos atrás
pai
commit
1ccf551d1c
1 arquivos alterados com 11 adições e 13 exclusões
  1. 11 13
      rtl/unix/sysutils.pp

+ 11 - 13
rtl/unix/sysutils.pp

@@ -1431,6 +1431,7 @@ end;
 
 
 var
 var
   _HomeDir: string;
   _HomeDir: string;
+  _HasPackageDataDir: boolean;
 
 
 Function GetHomeDir : String;
 Function GetHomeDir : String;
 var
 var
@@ -1440,7 +1441,7 @@ begin
   Result:=_HomeDir;
   Result:=_HomeDir;
   if Result <> '' then
   if Result <> '' then
     exit;
     exit;
-  if IsJniLibrary then
+  if IsLibrary 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);
@@ -1451,8 +1452,8 @@ begin
           SetLength(Result, strlen(PChar(Result)));
           SetLength(Result, strlen(PChar(Result)));
           FileClose(h);
           FileClose(h);
           Result:='/data/data/' + Result;
           Result:='/data/data/' + Result;
-          IsJniLibrary:=DirectoryExists(Result);
-          if IsJniLibrary then
+          _HasPackageDataDir:=DirectoryExists(Result);
+          if _HasPackageDataDir then
             begin
             begin
               Result:=Result + '/files/';
               Result:=Result + '/files/';
               ForceDirectories(Result);
               ForceDirectories(Result);
@@ -1502,7 +1503,7 @@ begin
   else
   else
     Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
     Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
 {$ifdef android}
 {$ifdef android}
-  if IsJniLibrary then
+  if _HasPackageDataDir then
     exit;
     exit;
 {$endif android}
 {$endif android}
   if VendorName<>'' then
   if VendorName<>'' then
@@ -1518,7 +1519,7 @@ begin
   else
   else
     Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
     Result:=IncludeTrailingPathDelimiter(XdgConfigHome);
 {$ifdef android}
 {$ifdef android}
-  if IsJniLibrary then
+  if _HasPackageDataDir then
     begin
     begin
       Result:=Result+'config'+ConfigExtension;
       Result:=Result+'config'+ConfigExtension;
       exit;
       exit;
@@ -1608,14 +1609,11 @@ var
   dlinfo: dl_info;
   dlinfo: dl_info;
   s: string;
   s: string;
 begin
 begin
-  if IsJniLibrary then
-    begin
-      FillChar(dlinfo, sizeof(dlinfo), 0);
-      dladdr(@InitAndroid, @dlinfo);
-      s:=dlinfo.dli_fname;
-      if s <> '' then
-        SetDefaultSysLogTag(ExtractFileName(s));
-    end;
+  FillChar(dlinfo, sizeof(dlinfo), 0);
+  dladdr(@InitAndroid, @dlinfo);
+  s:=dlinfo.dli_fname;
+  if s <> '' then
+    SetDefaultSysLogTag(ExtractFileName(s));
 end;
 end;
 
 
 {$endif android}
 {$endif android}