Recent

Author Topic: LAMW (solved) how to prevent location mocking / fake gps on LAMW  (Read 8257 times)

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW (solved) how to prevent location mocking / fake gps on LAMW
« Reply #15 on: August 23, 2021, 06:07:47 pm »

Quote
I am trying to extend it by bringing Java/Android classes to Pascal.

There is a "conceptual" attempt here:
 
"Laz_And_jni_Controls.pas"  and demo "AppTest2"
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: LAMW (solved) how to prevent location mocking / fake gps on LAMW
« Reply #16 on: August 23, 2021, 10:05:14 pm »
Remember that "LAMW Pascal" side/code  talk to "LAMW java" [multi-thread?] side/code..... 

All I mentioned was for a single thread, and I am leaving JNIEnv out for now. Later both will be included. That's why I asked you for the simplest example. In the simplest case with a single thread and a single activity, any jobject we receive inside events is going to stale by the end of the event. If we need the object outside that event, then we need to turn it into a Java global reference.

For now, I can manage without any changes to LAMW. So let's keep LAMW as is.

There is a "conceptual" attempt here:
 
"Laz_And_jni_Controls.pas"  and demo "AppTest2"

Yes, this is what I want to do. Can you please correct me if I state something not accurate in any of the following:

I noticed IDs we get from calling Get_j*ID can be reused and we do not need to call Get_j*ID again for the same member.
For instance instead of:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidListView.NotifyDataSetChanged(jAdapter: jObject);
  2. var
  3.   jClass_arrayAdapter: jClass;
  4.   jMethodId_notifyDataSetChanged:  jMethodID;
  5. begin
  6.   jClass_arrayAdapter:= Get_jClassLocalRef('android/widget/ArrayAdapter');
  7.   jMethodId_notifyDataSetChanged:= Get_jMethodID(jClass_arrayAdapter, 'notifyDataSetChanged','()V');
  8.   Call_jVoidMethod(jAdapter, jMethodId_notifyDataSetChanged);
  9. end;


we can write:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidListView.NotifyDataSetChanged(jAdapter: jObject);
  2. begin
  3.   Call_jVoidMethod(jAdapter, jMethodId_notifyDataSetChanged);
  4. end;

Assuming jMethodId_notifyDataSetChanged declared as a "static" member of the TAndroidListView and has the correct value.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: LAMW (solved) how to prevent location mocking / fake gps on LAMW
« Reply #17 on: August 23, 2021, 10:25:07 pm »

Quote
I am trying to extend it by bringing Java/Android classes to Pascal.

There is a "conceptual" attempt here:
 
"Laz_And_jni_Controls.pas"  and demo "AppTest2"

I just installed this example on my phone, and now I want to know what problems did you face to prevent you from moving in this direction?
Asked in a different way, why do you keep adding to the Java part?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW (solved) how to prevent location mocking / fake gps on LAMW
« Reply #18 on: August 23, 2021, 11:38:04 pm »
Quote
I want to know what problems did you face to prevent you from moving in this direction?

just absolute lack of time.....

Quote
Asked in a different way, why do you keep adding to the Java part?

0) LAMW "GUI" was the way found after experiences/trials [and frustrations] for me and for many others (felipemdc, simonsayz, .... )

1) Code reuse: thousands of java/android tutorials deliver ready-to-use solutions....

2) we can embed all the logic (including asynchronous routines, exception handle, ....) in java side and leaving to pascal only the work of making the methods calls and responding to the events ..... making code generation [and use] on the pascal side "clear" and easier.

side note 1: yes, it is still possible other approaches in LAMW "GUI" and "fixes" including your suggestion about a global "gThis"
but we need a lot of [time and] code refactoring, testing/maturation  otherwise we run the risk of break/stop  everything [legacy] that is working ....

side note 2: @loaded is working in another direction:  LAMW "NoGUI"
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: LAMW (solved) how to prevent location mocking / fake gps on LAMW
« Reply #19 on: August 25, 2021, 02:30:19 pm »
side note 2: @loaded is working in another direction:  LAMW "NoGUI"

LAMW, The Platform that pushes the limits of the possible.
We can't thank enough the legendary developers of LAMW for bringing this masterpiece to us.

It's up to your imagination and skills to do what you want with NoGUI...

https://youtu.be/SCAOeAN3eU4 In this study, I wanted to show how .so files created with LAMW module can be used in Android Studio.

https://youtu.be/gBS0AMrJ50s Also, the CAD application named Polygon, which I wrote with this method; He started running, he will be in the 1st league soon :)
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: LAMW (solved) how to prevent location mocking / fake gps on LAMW
« Reply #20 on: August 27, 2021, 10:02:00 am »
Amazing !  :o

 

TinyPortal © 2005-2018