distriqt / ANE-Message

Send messages from AIR using email and SMS
https://airnativeextensions.com/extension/com.distriqt.Message
0 stars 0 forks source link

Android jpeg attachment not working #48

Closed adamski68 closed 5 years ago

adamski68 commented 5 years ago

Message ANE is working fine in IOS - attaches screen shot to email without any issues. Was working fine on Android, but now refuses to work.

Have checked on 2 Android tablets and both the same - refuses to create attachment or even open Gmail app.

Rechecked on iOS, and is fine.

Regenerated key, app name is correct. Calling Core and Support ANEs correctly.

It has done this before and then mysteriously started working OK. But it is going to be a real problem if it frequently becomes non-working.

marchbold commented 5 years ago

Attachment issues on Android are normally an issue with the manifest:

https://github.com/distriqt/ANE-Message/wiki/i.Add-the-Extension#android-manifest-additions

Ensure you have correctly added the file provider to your app.

adamski68 commented 5 years ago

Thanks. Have rechecked the manifest and it is correct - with APPLICATION_ID replaced with the app ID.

When you say add the file provider to your app, do you mean in the manifest or actually in the AS3 code?

It is really peculiar as it was working fine on Android and then stopped for no reason that I can discern - no code changes.

adamski68 commented 5 years ago

my manifest is below:

 <android>

        <manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <uses-permission android:name="android.permission.CAMERA"/>
            <uses-permission android:name="android.permission.RECORD_AUDIO"/>
            <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
            <uses-permission android:name="android.permission.WAKE_LOCK"/>

<application>
<provider
            android:name="com.distriqt.extension.message.content.MessageFileProvider"
            android:authorities="com.sportsofficialsolutions.sosRUGBY4th.messagefileprovider"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/distriqt_message_paths" />
        </provider>

        <activity android:name="com.distriqt.extension.message.permissions.AuthorisationActivity"
         android:theme="@android:style/Theme.Translucent.NoTitleBar" />
                    <activity android:name="com.distriqt.extension.permissions.permissions.AuthorisationActivity"
                    android:theme="@android:style/Theme.Translucent.NoTitleBar" />

            </application>
</manifest>
]]></manifestAdditions>

    </android>

and then right at the bottom.

<extensions>
    <extensionID>com.distriqt.androidsupport.V4</extensionID>
    <extensionID>com.distriqt.Permissions</extensionID>
    <extensionID>com.distriqt.Core</extensionID>
    <extensionID>com.distriqt.Message</extensionID>
  </extensions>
</application>
marchbold commented 5 years ago

Are you removing the air prefix from your application package name? Try prepending air. to your application id :

<provider
    android:name="com.distriqt.extension.message.content.MessageFileProvider"
    android:authorities="air.com.sportsofficialsolutions.sosRUGBY4th.messagefileprovider"
    android:grantUriPermissions="true"
    android:exported="false">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/distriqt_message_paths" />
</provider>
adamski68 commented 5 years ago

Thanks.

Tried it with and without the air. prefix.

It does not work either way.

On Wed, 13 Feb 2019, 22:21 Michael <notifications@github.com wrote:

Are you removing the air prefix from your application package name? Try prepending air. to your application id :

<provider android:name="com.distriqt.extension.message.content.MessageFileProvider" android:authorities="air.com.sportsofficialsolutions.sosRUGBY4th.messagefileprovider" android:grantUriPermissions="true" android:exported="false"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/distriqt_message_paths" />

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/distriqt/ANE-Message/issues/48#issuecomment-463399293, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahq3jTpuaxb3W2zlb0Zb49GPbI7X5t-wks5vNI_WgaJpZM4agEbn .

marchbold commented 5 years ago

Can you post the logs from the device?

https://airnativeextensions.github.io/tutorials/device-logs

adamski68 commented 5 years ago

Is below, seems to be calling it OK, but then unable to complete the screen grab. Reduce the JPEG quality to 50, which reduced the number of frame it skips to 213, from 330 or so when quality is set to 100.

02-14 18:33:42.009 1109 2339 V LocSvc_HIDL_IzatProvider: [onLocationChanged][67] [HS] =>>>> [HC]

02-14 18:33:42.009 1640 27062 V LocSvc_HIDL_IzatProvider_jni: [onLocationChanged][136] [HC] <<= [HS]

02-14 18:33:42.009 1109 2339 V LocSvc_HIDL_IzatProvider: [onLocationChanged][67] [HS] =>>>> [HC]

02-14 18:33:42.010 1640 27062 V LocSvc_HIDL_IzatProvider_jni: [onLocationChanged][136] [HC] <<= [HS]

02-14 18:33:43.136 1640 2128 V ActivityManager: Broadcast: Intent { act=RCS.keep_alive_manager.keep_alive_sender flg=0x14 (has extras) } ordered=true userid=0 callerApp=null

02-14 18:33:43.138 1640 1717 V ActivityManager: Broadcast: Intent { act=android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED flg=0x40000010 } ordered=false userid=0 callerApp=ProcessRecord{4178960 1640:system/1000}

02-14 18:33:43.277 1069 1069 I QNS : QNS: soc=16, v=3783, i=419, t=260

02-14 18:33:43.277 1069 1069 I QNS : QNS: requested charging params: current: 2325, voltage: 4380

02-14 18:33:44.639 1640 2388 V ActivityManager: Broadcast sticky: Intent { act=android.intent.action.SIG_STR flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{4178960 1640:system/1000}

02-14 18:33:46.994 1640 2388 V ActivityManager: Broadcast sticky: Intent { act=android.intent.action.SIG_STR flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{4178960 1640:system/1000}

02-14 18:33:49.247 1640 1743 D AutomaticBrightnessController: UP updateAutoBrightness: value_up=0.1764706, value_mid=0.09019607, mScreenAutoBrightnessAdjustment=0.9980469, value=0.17630209

02-14 18:33:51.499 17768 17768 D com.distriqt.Message: MessageController::sendMailWithOptions( FT_Fourth_gghn_v_iijj, 4th Official Report, [adent739@googlemail.com] )

02-14 18:33:51.501 17768 17768 D com.distriqt.Message: MessageController::attachment: /data/user/0/air.com.sportsofficialsolutions.sosRUGBY4th/com.sportsofficialsolutions.sosRUGBY4th/Local Store/FT_Fourth_gghn_v_iijj.jpg

02-14 18:33:51.505 17768 17768 I Choreographer: Skipped 213 frames! The application may be doing too much work on its main thread.

02-14 18:33:51.795 1640 2121 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:962 com.android.server.BatteryService$1.ExecuteThermalCamera:285 com.android.server.BatteryService$1.run:393 android.os.Handler.handleCallback:789 android.os.Handler.dispatchMessage:98

02-14 18:33:51.795 1640 2121 V ActivityManager: Broadcast: Intent { act=com.sonyericsson.psm.action.CAMERA_COOLED_DOWN_NORMAL flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{4178960 1640:system/1000}

02-14 18:33:53.190 1640 1715 V ActivityManager: Broadcast: Intent { act=android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED flg=0x40000010 } ordered=false userid=0 callerApp=ProcessRecord{4178960 1640:system/1000}

02-14 18:33:56.100 1640 1743 D AutomaticBrightnessController: UP updateAutoBrightness: value_up=0.1764706, value_mid=0.09019608, mScreenAutoBrightnessAdjustment=0.9980469, value=0.17630209

This is the code for creating the screen grab:

function createAttachmentImageFile( filename:String ):File{

                                            var bd:BitmapData = new BitmapData( 800, 1280 ); 

                                            bd.draw(stage);

                                            var jpg:JPGEncoder = new JPGEncoder(50);

                                            var ba:ByteArray = jpg.encode( bd );

                                            var file:File = File.applicationStorageDirectory.resolvePath( filename );

                                            var stream:FileStream = new FileStream();

                                            stream.open(file, FileMode.WRITE);

                                            stream.writeBytes(ba);

                                            stream.close();

                                            return file;

                            }

What I do not understand is that this was all working fine previously and still works OK in iOS, but just will not work on any Android device I try it on.

This is the code for creating the attachment and sending the mail.

function backup(e:MouseEvent):void {

mysound2.play();

msg1.visible = false;

msg2.visible = false;

submit_btn.visible = false;

            msgBack.visible = false;

            subject = "4th Official " + homeTeam + "_v_" + awayTeam;

imagefileNativePath = createAttachmentImageFile( subject + ".jpg").nativePath;

Message.service.sendMailWithOptions(

                                                                            subject, 

                                                                            "4th Official Report", 

                                                                            fourthmail, 

                                                                            "",

                                                                            "",

                                                                            [

                                                                                            new MessageAttachment( imagefileNativePath, "image/jpeg" )

                                                                            ],

                                                                            true        

                                                                            )

}

From: Michael notifications@github.com Sent: 14 February 2019 08:10 To: distriqt/ANE-Message ANE-Message@noreply.github.com Cc: adamski68 adent739@googlemail.com; Author author@noreply.github.com Subject: Re: [distriqt/ANE-Message] Android jpeg attachment not working (#48)

Can you post the logs from the device?

https://airnativeextensions.github.io/tutorials/device-logs

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/distriqt/ANE-Message/issues/48#issuecomment-463531935 , or mute the thread https://github.com/notifications/unsubscribe-auth/Ahq3jZgyNGsDFWr25XuBgTD8N5cqEWBYks5vNRnAgaJpZM4agEbn . https://github.com/notifications/beacon/Ahq3jSkcmGR252_-1Skfyo07gSKLo99gks5vNRnAgaJpZM4agEbn.gif

marchbold commented 5 years ago

What version of AIR are you using?

adamski68 commented 5 years ago

31.0.0.96

On Fri, 15 Feb 2019, 00:06 Michael <notifications@github.com wrote:

What version of AIR are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/distriqt/ANE-Message/issues/48#issuecomment-463853790, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahq3jQAElKbDGGFD8m6VCxmtTJDsnKanks5vNfoNgaJpZM4agEbn .

adamski68 commented 5 years ago

Have just downloaded the latest version 32.0.0.89

Android still does not work. Log is now showing:

02-15 06:56:35.861 32228 32228 D com.distriqt.Message: MessageController::sendMailWithOptions( 4th Official hyh_v_hi ik, 4th Official Report, [adent739@googlemail.com] )

02-15 06:56:35.863 32228 32228 D com.distriqt.Message: MessageController::attachment: /data/user/0/air.com.sportsofficialsolutions.sosRUGBY4th/com.sportsofficialsolutions.sosRUGBY4th/Local Store/4th Official hyh_v_hi ik.jpg

02-15 06:56:40.226 1640 2121 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:962 com.android.server.BatteryService$1.ExecuteThermalCamera:285 com.android.server.BatteryService$1.run:393 android.os.Handler.handleCallback:789 android.os.Handler.dispatchMessage:98

0

From: Michael notifications@github.com Sent: 15 February 2019 00:07 To: distriqt/ANE-Message ANE-Message@noreply.github.com Cc: adamski68 adent739@googlemail.com; Author author@noreply.github.com Subject: Re: [distriqt/ANE-Message] Android jpeg attachment not working (#48)

What version of AIR are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/distriqt/ANE-Message/issues/48#issuecomment-463853790 , or mute the thread https://github.com/notifications/unsubscribe-auth/Ahq3jQAElKbDGGFD8m6VCxmtTJDsnKanks5vNfoNgaJpZM4agEbn . https://github.com/notifications/beacon/Ahq3jaJ2meei8XH_H3IEVdr0SVZ1YU2Uks5vNfoNgaJpZM4agEbn.gif

marchbold commented 5 years ago

When you say: "What I do not understand is that this was all working fine previously and still works OK in iOS"

do you mean the ANE was working for you but has stopped? What has changed since it was working? Did you update the ANE?

adamski68 commented 5 years ago

For reasons that are not clear to me, the message ane is no longer producing an attachment when accessed in Android. The same code and setup works perfectly in iOS. This suggests it is not a license verification issue.

I have sent you all the relevant bits of code and manifest and there do not seem to be any issues with those.

I have updated the ane to the latest version. The core and support libraries have also been updated. But were not working in Android prior to the update.

I have looked at all the code in the app and on the screen that I need to grab there are no changes from when the ane was working. It is a static screen of textboxes that has no real processing overhead.

The fact that it works in iOS suggests to me that the code is doing its job. Or am I incorrect in thinking that?

So, my conclusion is that there is something peculiar going on in the android manifest or setup.. but you have not flagged anything that looks funny in those.

There is the entry in the log about skipping frames.. what does that mean?

I am calling permissions ane in the same app, would that have any bearing?

I cannot believe that it "just won't work" so I am going through a process to try and establish where the issue lies.

I now cannot tell at what point it stopped working. My earlier discipline of saving previous versions of the app prior to an update went South some time ago.. My bad..

To confirm, as far as you can see from all the code and manifest elements I have sent you, there is nothing that seems wrong?

Regards

Adam

On Fri, 15 Feb 2019, 22:01 Michael <notifications@github.com wrote:

When you say: "What I do not understand is that this was all working fine previously and still works OK in iOS"

do you mean the ANE was working for you but has stopped? What has changed since it was working? Did you update the ANE?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/distriqt/ANE-Message/issues/48#issuecomment-464218296, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahq3jV4yhuTRrMZbutRGPp8prseT1wDuks5vNy4pgaJpZM4agEbn .

adamski68 commented 5 years ago

I think it is something to do with where the attachment is being saved.

When I point the screen grab function at applicationstorage directory it does not seem to do anything on Android. Or maybe it is, but I cannot find the files when I search for them.

When I point it at documentsDirectory, I can see that the screen grab is saved but in the 1st level of the internal storage..

When I plug the phone into my PC, the jpg files that I can see in the file manager on the phone do not appear when I browse to that folder on the PC. Screenshot below..

Is there some new android permission that I have missed? Why does it not seem to work when I point it at applicationstoragedirectory, I thought that was accessible as standard?

Seem to be getting closer to a resolution

From: Michael notifications@github.com Sent: 15 February 2019 22:01 To: distriqt/ANE-Message ANE-Message@noreply.github.com Cc: adamski68 adent739@googlemail.com; Author author@noreply.github.com Subject: Re: [distriqt/ANE-Message] Android jpeg attachment not working (#48)

When you say: "What I do not understand is that this was all working fine previously and still works OK in iOS"

do you mean the ANE was working for you but has stopped? What has changed since it was working? Did you update the ANE?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/distriqt/ANE-Message/issues/48#issuecomment-464218296 , or mute the thread https://github.com/notifications/unsubscribe-auth/Ahq3jV4yhuTRrMZbutRGPp8prseT1wDuks5vNy4pgaJpZM4agEbn . https://github.com/notifications/beacon/Ahq3jQe6i-SdGCn3le6YUytxOG_zPXCZks5vNy4pgaJpZM4agEbn.gif

marchbold commented 5 years ago

The application storage directory is an application internal directory that you can use to store data. It's not accessible to other applications directly as each application is "sandboxed" to their own storage.

The documents directory is the "external storage" area that is accessible to all apps and has no sandbox limitations. This area requires permission to read / write.

The File provider is an "Android content provider" and allows you to provide a file from your internal application space to another application temporarily. This is the process we use to pass your attachment to another application.

iOS and Android are very different, so you have to be careful with the line, "it works on iOS so must work on Android"

The skipping frames log is probably to do with the jpeg encoding you are doing on your main thread.

Everything looks okay from what we have seen, so it's hard to guess exactly what the issue is.

Perhaps try a different filename, it could be some issues with the space's you have in the filename?

adamski68 commented 5 years ago

When I say it works on ios, what I mean is that there is no issue with the license key, so this a specific android issue.

Not sure if you saw my later mail – whichever I tell it to do, the app is not saving the screenshot in the applicationStorage directory or the documents directory. It is putting it in the lowest level of the internal storage.. as a result the command to attach the file is not finding the attachment.

Now I need to work out why it is saving to the wrong location.

adamski68 commented 5 years ago

Just stumbled on the answer.

Needs a specific reference to core.init() and an import command at the top of the code.

It definitely did not need that before so something has changed in the ANE.

Might be an idea to make that a bit clearer.

marchbold commented 5 years ago

Core.init() is not required here, however the Core ANE definitely is.

Perhaps you weren't previously packaging it with your application correctly or you had an older version of the Core ANE? That could have lead to this behaviour.

adamski68 commented 5 years ago

Core ane packaging had definitely not changed at any time.

Permissions requires the same core and support anes and that has worked without any issues while message would not.

It matters not, it now works.

On Tue, 19 Feb 2019, 01:04 Michael <notifications@github.com wrote:

Core.init() is not required here, however the Core ANE definitely is.

Perhaps you weren't previously packaging it with your application correctly? That could have lead to this behaviour.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/distriqt/ANE-Message/issues/48#issuecomment-464937823, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahq3jZoa0XEH6Qdx206Q0YrTiitg-UChks5vO025gaJpZM4agEbn .

marchbold commented 5 years ago

Glad to hear!