mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 04:59:25 +02:00
* android: Added functions GetSystemProperty() and SystemApiLevel().
git-svn-id: trunk@34346 -
This commit is contained in:
parent
b10e4aa27b
commit
c2ba68df44
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8352,6 +8352,7 @@ rtl/android/jvm/rtl.cfg svneol=native#text/plain
|
||||
rtl/android/mipsel/dllprt0.as svneol=native#text/plain
|
||||
rtl/android/mipsel/prt0.as svneol=native#text/plain
|
||||
rtl/android/sysandroid.inc svneol=native#text/plain
|
||||
rtl/android/sysandroidh.inc svneol=native#text/plain
|
||||
rtl/android/unixandroid.inc svneol=native#text/plain
|
||||
rtl/arm/arm.inc svneol=native#text/plain
|
||||
rtl/arm/armdefines.inc svneol=native#text/plain
|
||||
|
@ -58,3 +58,28 @@ begin
|
||||
// Register the finalization routine
|
||||
atexit(@SysAndroidLibExit);
|
||||
end;
|
||||
|
||||
function __system_property_get(name:Pchar; value:Pchar):longint;cdecl;external 'c' name '__system_property_get';
|
||||
|
||||
function GetSystemProperty(Name: PAnsiChar): shortstring;
|
||||
begin
|
||||
SetLength(Result, __system_property_get(Name, @Result[1]));
|
||||
end;
|
||||
|
||||
var
|
||||
_ApiLevel: shortint = -1;
|
||||
|
||||
function SystemApiLevel: shortint;
|
||||
var
|
||||
s: string;
|
||||
c: integer;
|
||||
begin
|
||||
if _ApiLevel < 0 then
|
||||
begin
|
||||
s:=GetSystemProperty('ro.build.version.sdk');
|
||||
Val(s, _ApiLevel, c);
|
||||
if c <> 0 then
|
||||
_ApiLevel:=0;
|
||||
end;
|
||||
Result:=_ApiLevel;
|
||||
end;
|
||||
|
19
rtl/android/sysandroidh.inc
Normal file
19
rtl/android/sysandroidh.inc
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 2016 by Yury Sidorov,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
Android-specific part of the System unit.
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
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.
|
||||
**********************************************************************}
|
||||
|
||||
// Returns an Android system property
|
||||
function GetSystemProperty(Name: PAnsiChar): shortstring;
|
||||
// Returns an Android API level of the current system
|
||||
function SystemApiLevel: shortint;
|
@ -44,6 +44,10 @@ property cmdline:Pchar read get_cmdline;
|
||||
|
||||
{$endif defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6))}
|
||||
|
||||
{$ifdef android}
|
||||
{$I sysandroidh.inc}
|
||||
{$endif android}
|
||||
|
||||
{*****************************************************************************}
|
||||
implementation
|
||||
{*****************************************************************************}
|
||||
@ -78,7 +82,7 @@ const calculated_cmdline:Pchar=nil;
|
||||
{$I system.inc}
|
||||
|
||||
{$ifdef android}
|
||||
{$I sysandroid.inc}
|
||||
{$I sysandroid.inc}
|
||||
{$endif android}
|
||||
|
||||
{*****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user