Hacking Delphi to Let Older Phones Work with Tokyo.

As explained earlier a Galaxy Pocket Neo (GT-S5310B) enabled testing of normal FMX form applications in Seattle and Berlin but did not render 3D applications correctly. While the Android version is claimed as still supported In Tokyo in fact the simplest form application fails to render and terminates.

Ideally I still wanted to use this phone to test my applications in Tokyo rather than source a new phone.  I traced the cause to the module “FMX.Context.GLES”.  Tokyo seems to initialize 3D graphics even if 3D is not used in the application. The checking for errors in this process raises an exception if 3D is not supported.  By applying the following patch to the function GLHasAnyErrors I have been able to bypass that exception for applications with the conditional variable “Not3DApp” set  thereby supporting the applications on the  Galaxy Pocket Neo (GT-S5310B).

class function TCustomContextOpenGL. GLHasAnyErrors: Boolean;
Result := GLGetErrorFlags <> 0;
{$IfDef Not3DApp}
{$IfDef NextGen}
if Result then

I do not like or recommend patching Delphi library code but this offers me a work around.

Copy the file “FMX.Context.GLES” to a project directory and include that file in the project files. Apply the patch to the copy. Delete all project DCUs and build the application. Stepping through the routine in Debug does not find the new code copy so it is now not possible to step into “FMX.Context.GLES” but the patch is activated and my phone works.