Android and IOS Front and Back Camera and WIFI Scanning

Share your advanced knowledge/code with the community.
tj1010
Posts: 201
Joined: Wed May 27, 2015 1:36 pm
Contact:

Android and IOS Front and Back Camera and WIFI Scanning

Post by tj1010 »

This is about 12 hours of reading Cordova and Cordova package docs and trial and error in chrome inspector since Import documentation was released two days ago. I got tired of it before I wrote filesystem enumerate, write, and read; those are only about 30 more lines.

From what I seen the only thing you probably can't do with Cordova plugins still is Google Maps stuff because SB is custon UI. Maybe with some inline JS to a webgadget to do markers, icons, links with Maps JS API.

Where to get more packages: https://cordova.apache.org/plugins/

Code: Select all

Import "cordova telemetry on" : EndImport
Import "cordova plugin add cordova-plugin-camera" : EndImport
Import "cordova plugin add wifiwizard" : EndImport

;Returns BASE64 data URL for bitmap
Procedure PictureOut(image.s)
  If Len(image)>0 : Debug image.s : EndIf
EndProcedure
PictureOut("")

;if you want to get a picture without user interaction you'll need one of the other camera plugins
Procedure.s GetPicture(camera.s)
  !if(v_camera=='FRONT') var direction=1;
  !if(v_camera=='BACK') var direction=0;
  !navigator.camera.getPicture(onSuccess, onFail,
  !{
  !    destinationType: Camera.DestinationType.DATA_URL,
  !    quality:100,
  !    cameraDirection:direction,
  !    sourceType: Camera.PictureSourceType.CAMERA,
  !    popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)
  !});
  !function onSuccess(image){
  !f_pictureout(image);
  !}
  !function onFail(message){
  !f_pictureout(message);
  !}
EndProcedure

;WIFI JSON output callback
Procedure APOutput(nodes.s)
  If Len(nodes.s)>0 : Debug nodes.s : EndIf
EndProcedure
APOutput("")

;scan WIFI APs
;getScanResults might need to be in a timer
Procedure GetAccessPoints()
  !function iweufwhi(isenabled){
  !if(isenabled===true){
  !WifiWizard.startScan(function(){},function(){});
  !WifiWizard.getScanResults({},function(networks){f_apoutput(JSON.stringify(networks));},function(networks){});
  !}
  !}
  !WifiWizard.isWifiEnabled(function(enabled){iweufwhi(enabled);},function(){});
EndProcedure

GetPicture("FRONT")
GetAccessPoints()
Last edited by tj1010 on Wed Jul 05, 2017 5:28 pm, edited 1 time in total.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Android and IOS Front and Back Camera and WIFI Scanning

Post by Peter »

Interesting, thanks!

Too bad that it is still not possible to create Android-Apps with Linux. :(

Greetings ... Peter
tj1010
Posts: 201
Joined: Wed May 27, 2015 1:36 pm
Contact:

Re: Android and IOS Front and Back Camera and WIFI Scanning

Post by tj1010 »

Peter wrote:Interesting, thanks!

Too bad that it is still not possible to create Android-Apps with Linux. :(

Greetings ... Peter
VM and CLI via a basic server written in PB. I do it with an xubuntu VM in windows for PB Debian builds. It's easier than the IDE menus.
firace
Posts: 28
Joined: Tue Jan 02, 2018 6:59 pm

Re: Android and IOS Front and Back Camera and WIFI Scanning

Post by firace »

@tj1010: Does not work for me. I'm getting the below errors. Should I manually download/install these plugins first? If so, how?

Code: Select all

Uncaught TypeError: Cannot read property 'getPicture' of undefined
    at f_getpicture (spiderbasic.js:268)
    at SpiderLaunch (spiderbasic.js:311)
    at SpiderMain (main.js:24)
    at main.js:41
    at fa (dojo.js:19)
    at dojo.js:20
    at ga (dojo.js:20)
    at da (dojo.js:20)
    at s (dojo.js:22)
    at HTMLScriptElement.<anonymous> (dojo.js:27)
Thanks!
tj1010
Posts: 201
Joined: Wed May 27, 2015 1:36 pm
Contact:

Re: Android and IOS Front and Back Camera and WIFI Scanning

Post by tj1010 »

Are you running it on Android or IOS? It won't work on x86 browsers.

If you're running it on mobile platforms then it looks like a bug in recent SB linker-chain. It was tested two versions ago. I'm still working around the adb bug in SB where I have to manually call adb with the output apk, and don't get mutch time to test things. You shouldn't need to download anything though; I never did.
firace
Posts: 28
Joined: Tue Jan 02, 2018 6:59 pm

Re: Android and IOS Front and Back Camera and WIFI Scanning

Post by firace »

tj1010 wrote:Are you running it on Android or IOS? It won't work on x86 browsers.

If you're running it on mobile platforms then it looks like a bug in recent SB linker-chain. It was tested two versions ago. I'm still working around the adb bug in SB where I have to manually call adb with the output apk, and don't get mutch time to test things. You shouldn't need to download anything though; I never did.
Ah, that was it! It works fine on my mobile indeed. Thanks.

I was running it on my desktop browser and had so many errors that I did not even think of trying it on my mobile... :oops:

About your adb issue, not sure what the cause is. For me the toolchain is working just fine (SB 2.20 x86 + JDK 1.8.0_151 on Win 10 x64)

For a quick fix, perhaps you could try to uninstall/reinstall? IIRC this should take less than 15 minutes.
tj1010
Posts: 201
Joined: Wed May 27, 2015 1:36 pm
Contact:

Re: Android and IOS Front and Back Camera and WIFI Scanning

Post by tj1010 »

FYI https://cordova.apache.org/plugins/ is broken. Was going to do Android file system stuff and I just get infinite "Loading..." under all browsers... Need to enumerate folder, write files, read files under Android "local" and SD storage...

Might do cloud based call blocking and a TEE/TPM password manager too... I am also interesting in plugins that help with raw WIFI AP packet data and DNS changes too; mainly for a customizable hotspot AP login app.. There is some cool stuff with Blutooth device classes too..
Post Reply