Re: [fpc-other] Pascal equivalent to The wakeLock.acquire

2020-05-22 Thread Mgr. Janusz Chmiel via fpc-other
Oh yes. YOu aare really The expert.
Constructing correct Android APi pascal headers is extremely complex work.
And without work of MR Swianovicz there would not be new Android APi
headers. Develop fully automated solution is rather extremely heavy
programmers task. And using Borland Delphi equivalents is may not possible
thanks to differences between Free Pascal compiler and Delphi original
compiler.
There are some attempts on Github to provide Android APi functions based on
JNI. 
Thank you very much for yours advice. I have thought, that my code is non
functioning and yours code should help Me.
I Am also aware, that ANdroid kernel contain routines which will suspend
Wifi chip automatically when phone screen is turned off even if I will use
full Wakelock. It will not turn it completely off, but it will turn it in to
less sensitive level so if there is 1 or 2 wifi bars signal strenght and
phone is turned of for several minutes, it will be too less to receive 128
KB/S MP3 live stream. The work around is to use ping command in Termux but
if is it possible to use equivalent directly from Pascal source, it is
interesting question for thinkink.
Thank you very much for yours professional answer.

___
fpc-other maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-other


Re: [fpc-other] Pascal equivalent to The wakeLock.acquire

2020-05-22 Thread Jonas Maebe
On 22/05/2020 14:34, Mgr. Janusz Chmiel via fpc-other wrote:
> I Am wondering, how to construct The series of Pascal statements which will
> have The same effect like in Java.
> wakeLock.acquire ();
> 
> 
> The command
> wakeLock.newWakeLock (1, '"Migration');
> Work perfectly.
> But
> wakeLock.acquire (
>   );
> Causes error when compiling.
> I Am using AndroidR15
> APi headers for Pascal.

The AOPowerManager.WakeLock inner class declaration is indeed incomplete
in the Pascal translation: it's missing all of the method declarations.
It must be a bug in the javapp program (maybe because the constructor of
that class is private).

You should be able to work around it by placing this declaration in your
own program or unit source file. It should override the incomplete
declaration from the androidr15 unit.

type
  AOPowerManager = class external 'android.os' name 'PowerManager'
(JLObject)
  public
type
  InnerWakeLock = class;
  Arr1InnerWakeLock = array of InnerWakeLock;
  Arr2InnerWakeLock = array of Arr1InnerWakeLock;
  Arr3InnerWakeLock = array of Arr2InnerWakeLock;
  InnerWakeLock = class external 'android.os' name 'WakeLock'
procedure acquire; overload; virtual;
procedure acquire(timeout: jlong); overload; virtual;
function isHeld: boolean; overload; virtual;
procedure release; overload; virtual;
procedure release(flags: jint); overload; virtual;
procedure setReferenceCounted(value: boolean); overload; virtual;
procedure setWorkSource(ws: AOWorkSource); overload; virtual;
function toString(): JLString; overload; virtual;
  end;

  public
const
  PARTIAL_WAKE_LOCK = 1;
  FULL_WAKE_LOCK = 26;
  SCREEN_BRIGHT_WAKE_LOCK = 10;
  SCREEN_DIM_WAKE_LOCK = 6;
  ACQUIRE_CAUSES_WAKEUP = 268435456;
  ON_AFTER_RELEASE = 536870912;
  public
function newWakeLock(para1: jint; para2: JLString):
AOPowerManager.InnerWakeLock; overload; virtual;
procedure userActivity(para1: jlong; para2: jboolean); overload;
virtual;
procedure goToSleep(para1: jlong); overload; virtual;
function isScreenOn(): jboolean; overload; virtual;
procedure reboot(para1: JLString); overload; virtual;
  end;


Jonas
___
fpc-other maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-other


Re: [fpc-other] Pascal equivalent to The wakeLock.acquire

2020-05-22 Thread Mgr. Janusz Chmiel via fpc-other
It seems to Me, that Android APi functions do not contain standalone
procedure to activate Wakelock when other than Java or Kotlin language have
been used.

May be, that somebody very experienced would try to develop new function or
command to PPCJVM or to The Android RTL.
Thank you very much for yours thinkink. Or may be, that I Am doing errors.
And that I do not understand The Pascal API headers as I should to activate
Wakelock.

___
fpc-other maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-other