Thursday, February 16, 2023

Android 12 & Delphi 11.2


I finally got around to updating my three Android Apps for API 32/ Android 12.  So to start this blog post off, the following Apps are now available:

 

T-DUST  is a small module to monitor the  temperature in your Maker projects.  The app provides all the control  functions for a T-Dust device.  This includes displaying in Fahrenheit  or Centigrade, setting the data rate, recording to internal memory and placing the device in the power down collection mode.  The module has a 32Mbit memory on board for recording temperature data.  The app will  chart the temperature data on the mobile device or convert to a CSV file  for download. The module can record for over 120 hours at a 1 second  rate. 

 

The Power  Monitor is a small monitor module that plugs in between the USB Power Modules and your application.  The USB connection provides a constant  reading of the voltage and current on all of the voltages (12VDC, 5VDC  or VUSB, 3.3VDC, 2.5VDC and 1.8VDC).  The PC program provides all the  control functions and will keep a record of the voltage and current.   The module also has a 32Mbit memory on board for operating in the stand  alone mode.  Power comes from the Port 1 connection.  You can record up  to 65000 records, which is over 18 hours at a 1 second rate.  There is  an optional BT connection for controlling the monitor.  We provide the  API for both USB and BLE so that you can create your own custom  applications.

 

This is a dedicated brick controller for running your platform  designs. This  controller is dedicated to the task at hand.  Using a simple Android  mobile interface over Bluetooth, the sequence of up to 4 motor  controllers can be setup.  Additionally there are 4 LED lighting control  lines for dramatic lighting effects.  Finally it has three inputs for  sensing different types of real world events.  A Windows PC input setup  is in development and future versions will have an audio amplifier to  provide a single source for controlling your MOC.

Getting here did have some issues.  There were major changes to Android BT permissions.   You can see the changes here. Delphi will automatically generate the Manifest for you based on settings in the Project Options menu.  But this is very basic.  What is needed in some cases, especially Bluetooth implementation, are the qualifiers that go with the manifest entry.

Basically in Android 12 they introduced a SCAN, CONNECT, ADVERTISE permissions and eliminated BLUETOOTH and BT ADMIN.   Though what Google does not say is the ACCESS_FINE_LOCATION permission is not needed anymore, though it was never clear in the docs that it was needed prior to Android 13.  What you need for the basic private BT connection is

<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"  android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />

 Unfortunately there is no way inside of Delphi to add these qualifiers, ie android:maxSdkVersion=30.  What I did was modify the AndroidManifest_Template to include these lines.  Then in the Project Options men, I made sure these options were deselected.  This way Delphi will not generate these permissions in the android manifest and all will work as expected.  You can find more information about this at the Delphi forums, here.  You may need a guest login to see the thread.

 
 

 




No comments:

Post a Comment