croconaut / cpt

This is the Wi-Fi / Wi-Fi Direct based peer to peer communication framework for Android. It stands for "Croconaut Public Transport", Croconaut was a "startup" from the times when we thought we can finish the product in three months. :)
GNU General Public License v3.0
5 stars 1 forks source link

Bad Notification for startForeground #15

Open hassammughal opened 5 years ago

hassammughal commented 5 years ago

I am getting this isssue again and again android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 actions=2 number=0 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)

mikrosk commented 5 years ago

Thanks for the bug report. What are the steps to reproduce?

hassammughal commented 5 years ago

Dear Miro, Just include your library in a new android project, and develop an app similar to the wifon mini, you can easily reproduce the similar issue. Let me share my code with you. https://drive.google.com/file/d/1PvOxYSkkQwTlZIfdE5G-fLSkGx0AIK_B/view?usp=sharing

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Friday, December 14, 2018 10:13 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

Thanks for the bug report. What are the steps to reproduce?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-447321484, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOlOabax5-oXp22l_yjGT1fqN6UdTks5u46PpgaJpZM4ZTaVo.

hassammughal commented 5 years ago

https://stackoverflow.com/questions/50529138/notifications-not-working-on-api-278-1-0 https://stackoverflow.com/questions/51587863/bad-notification-for-start-foreground-invalid-channel-for-service-notification https://stackoverflow.com/questions/47531742/startforeground-fail-after-upgrade-to-android-8-1

Maybe these links can help you to get to the problem. Moreover, in your MainHandler.java class, you can use this approach to fix the issue. Looking forward to hearing from you soon. Thanks

hassammughal commented 5 years ago

Did you find any solution? I need to use UDP communication using your library for sharing of files. Is it possible? Or should I start from scratch?

mikrosk commented 5 years ago

Hi there, I plan to look at this tonight or tomorrow. Basically you can do anything you could do in a TCP/IP based network environment (incl. UDP packets), as soon as the P2P channel has been established, it's the classic sockets as you know them.

hassammughal commented 5 years ago

Dear Miro, Yes, that's why I was thinking to use your library, as the main task I need to achieve through your library is the automatic connectivity of devices. I don't want the user to interact. But, I need to gather the information about the devices connected. So, the method onNearbyPeers can it provide me with the hardware-related information of the devices? As you are just using the key-value pair of the username and id.

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Monday, December 17, 2018 11:11 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

Hi there, I plan to look at this tonight or tomorrow. Basically you can do anything you could do in a TCP/IP based network environment (incl. UDP packets), as soon as the P2P channel has been established, it's the classic sockets as you know them.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-447859046, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOsp9xLFNwiMPaeq5v2f6UdcQSH38ks5u56YJgaJpZM4ZTaVo.

mikrosk commented 5 years ago

OK, I've taken a quick look. While I can confirm that the notification really doesn't work very well (and I need to look at it), it doesn't throw any exceptions on my Nexus 5X with Android 8.1.

Can you try to compile & run latest wifon-mini? It should work out of the box with latest Android studio and Gradle plugin. I also switched it to use cpt-lite, i.e. the internet-less version of CPT.

hassammughal commented 5 years ago

Ok let me check it.

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Tuesday, December 18, 2018 5:00 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

OK, I've taken a quick look. While I can confirm that the notification really doesn't work very well (and I need to look at it), it doesn't throw any exceptions on my Nexus 5X with Android 8.1.

Can you try to compile & run latest wifon-mini? It should work out of the box with latest Android studio and Gradle plugin. I also switched it to use cpt-lite, i.e. the internet-less version of CPT.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-448130164, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOg_mf5LrtwvDMmz-pkZVpcXaYdBEks5u6KCUgaJpZM4ZTaVo.

hassammughal commented 5 years ago

Dear Miro, The WifOnMini app is working fine. I am trying to include the classes of this app to my app and based on that I will share the issues. Bundle of thanks for your co-operation and prompt response.

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Tuesday, December 18, 2018 5:00 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

OK, I've taken a quick look. While I can confirm that the notification really doesn't work very well (and I need to look at it), it doesn't throw any exceptions on my Nexus 5X with Android 8.1.

Can you try to compile & run latest wifon-mini? It should work out of the box with latest Android studio and Gradle plugin. I also switched it to use cpt-lite, i.e. the internet-less version of CPT.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-448130164, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOg_mf5LrtwvDMmz-pkZVpcXaYdBEks5u6KCUgaJpZM4ZTaVo.

hassammughal commented 5 years ago

Dear Miro, I am still getting the same issue, on target sdk version 28.

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Tuesday, December 18, 2018 5:00 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

OK, I've taken a quick look. While I can confirm that the notification really doesn't work very well (and I need to look at it), it doesn't throw any exceptions on my Nexus 5X with Android 8.1.

Can you try to compile & run latest wifon-mini? It should work out of the box with latest Android studio and Gradle plugin. I also switched it to use cpt-lite, i.e. the internet-less version of CPT.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-448130164, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOg_mf5LrtwvDMmz-pkZVpcXaYdBEks5u6KCUgaJpZM4ZTaVo.

mikrosk commented 5 years ago

Ah OK, now I see what's the problem. Yes, it's targetSdk.

Officially, we shouldn't be using it because it has been deprecated. However the reason why we do (did) is that 22 is the last version which doesn't require dynamic permissions. At the time this feature had been more and more required, I didn't have enough time and motivation to change it to the dynamic model.

So if you insist on using targetSdk > 22, I'm afraid it's up to you to make the required changes. It's nothing complicated but as I said, my time and motivation for this project has faded away... (hence the source code release).

However I'm still able to help you and give some advice, should you accept this task.

hassammughal commented 5 years ago

Dear Miro, Yah, you are right indeed, but if we use the permissions only for selecting an item from the file chooser, then its fine. I am ok with that. The main thing that I want to achieve through your library is the automatic connection, which I think so doesn't need the dynamic permissions. But if you think, the dynamic permissions are required while creating the connection as well, then I am OK with the current implementation.

And I am really grateful for your offer and I do need some guidance. As I want to perform the send and receive using UDP instead of TCP, and you perform this in your OutgoingPayload class, through sockets, so is it ok if I don't use the outgoing payload class and instead simple UDP datagram for the file?

Moreover, I also want to know if you are converting the byte to an array or not? As I want to send and receive a file which will contain the piece of code (JAVA) which will be executed on another device.

And how can I get the device name instead of the MAC address that is shown in the nearby peers' list?

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Tuesday, December 18, 2018 8:11 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

Ah OK, now I see what's the problem. Yes, it's targetSdk.

Officially, we shouldn't be using it because it has been deprecated. However the reason why we do (did) is that 22 is the last version which doesn't require dynamic permissions. At the time this feature had been more and more required, I didn't have enough time and motivation to change it to the dynamic model.

So if you insist on using targetSdk > 22, I'm afraid it's up to you to make the required changes. It's nothing complicated but as I said, my time and motivation for this project has faded away... (hence the source code release).

However I'm still able to help you and give some advice, should you accept this task.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-448185052, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOlTrkBWXV2IuqiqJY67dfnubHlg3ks5u6M1IgaJpZM4ZTaVo.

hassammughal commented 5 years ago

In addition to this, as I am working on a research project, so I can acknowledge your library in my research paper. However, I will require your assistance to accomplish the remote task scheduling in mobile devices connected. So, if you have enough time, we can set some time for a meeting on skype to discuss the tasks which I want to perform using your library and you can guide me accordingly, as you are well aware of your code whereas, I will require more time to understand it and then do it.

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Tuesday, December 18, 2018 8:11 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

Ah OK, now I see what's the problem. Yes, it's targetSdk.

Officially, we shouldn't be using it because it has been deprecated. However the reason why we do (did) is that 22 is the last version which doesn't require dynamic permissions. At the time this feature had been more and more required, I didn't have enough time and motivation to change it to the dynamic model.

So if you insist on using targetSdk > 22, I'm afraid it's up to you to make the required changes. It's nothing complicated but as I said, my time and motivation for this project has faded away... (hence the source code release).

However I'm still able to help you and give some advice, should you accept this task.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-448185052, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOlTrkBWXV2IuqiqJY67dfnubHlg3ks5u6M1IgaJpZM4ZTaVo.

mikrosk commented 5 years ago

Let's go item by item :)

Yah, you are right indeed, but if we use the permissions only for selecting an item from the file chooser, then its fine. I am ok with that. The main thing that I want to achieve through your library is the automatic connection, which I think so doesn't need the dynamic permissions. But if you think, the dynamic permissions are required while creating the connection as well, then I am OK with the current implementation.

The permissions are more or less needed for system stuff (like the service invocation) and then for accessing storage and network facilities. So generally speaking, I'd recommend to pay attention to the permission problem - maybe it's enough just to ask for all permissions during the startup but perhaps you will bump into more issues when targeting sdk > 22. So all it boils down to the question whether you want your app on the play store or not. If not, my recommendation would be to keep it at 22.

And I am really grateful for your offer and I do need some guidance. As I want to perform the send and receive using UDP instead of TCP, and you perform this in your OutgoingPayload class, through sockets, so is it ok if I don't use the outgoing payload class and instead simple UDP datagram for the file?

I'm not sure if I understand -- OutgoingPayload is just a wrapper around a Serializable object which is then, well, serialized into the database and waiting to be transmitted. If you want to use UDP packets, then you don't need any of this (however it requires you to do more changes to CPT). What currently happens is this:

So if you want to use UDP packets and different payloads, you have to:

Moreover, I also want to know if you are converting the byte to an array or not? As I want to send and receive a file which will contain the piece of code (JAVA) which will be executed on another device.

Yes, everything is serialized, stored into the database and then deserialized over the network. When transmitting java code, perhaps you could implement a better (more efficient) way.

And how can I get the device name instead of the MAC address that is shown in the nearby peers' list?

If nearby doesn't supply you with the user name (previously set on the other device) then it is still not available. onNearbyPeers should definitely supply you with both the mac address and user name.

In addition to this, as I am working on a research project, so I can acknowledge your library in my research paper. However, I will require your assistance to accomplish the remote task scheduling in mobile devices connected.

That would be nice. :) You mean how to decide whether to connect to some device? In that case, see above. That loop in MainHandler.java is exactly that.

So, if you have enough time, we can set some time for a meeting on skype to discuss the tasks which I want to perform using your library and you can guide me accordingly, as you are well aware of your code whereas, I will require more time to understand it and then do it.

In addition to having a really shitty internet connectivity at home right now, I would prefer to minimise my time on this. It's totally OK to ask questions, post pull requests etc but if you are up to such big changes, it's inevitable you have to dig into the code anyway. So if anything is unclear - go ahead and ask but ideally, it should be code/project related questions.

hassammughal commented 5 years ago

Dear Miro, I really appreciate the way you answered to the queries and made things more clear. With the second last sentence I meant that I want to perform task scheduling, such that whenever I will submit a task by selecting a particular file from file chooser, a scheduler method in my code will decide whether that task can be executed on my mobile or some other device's mobile. If it is to be executed on another device, I need to send that file to that particular device and after execution, get the result on my device back. Yes, I will surely try to dig into your code and also query related to the code issues I will be facing.

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Tuesday, December 18, 2018 11:38 PM To: croconaut/cpt Cc: Hassam Mughal; Author Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

Let's go item by item :)

Yah, you are right indeed, but if we use the permissions only for selecting an item from the file chooser, then its fine. I am ok with that. The main thing that I want to achieve through your library is the automatic connection, which I think so doesn't need the dynamic permissions. But if you think, the dynamic permissions are required while creating the connection as well, then I am OK with the current implementation.

The permissions are more or less needed for system stuff (like the service invocation) and then for accessing storage and network facilities. So generally speaking, I'd recommend to pay attention to the permission problem - maybe it's enough just to ask for all permissions during the startup but perhaps you will bump into more issues when targeting sdk > 22. So all it boils down to the question whether you want your app on the play store or not. If not, my recommendation would be to keep it at 22.

And I am really grateful for your offer and I do need some guidance. As I want to perform the send and receive using UDP instead of TCP, and you perform this in your OutgoingPayload class, through sockets, so is it ok if I don't use the outgoing payload class and instead simple UDP datagram for the file?

I'm not sure if I understand -- OutgoingPayload is just a wrapper around a Serializable object which is then, well, serialized into the database and waiting to be transmitted. If you want to use UDP packets, then you don't need any of this (however it requires you to do more changes to CPT). What currently happens is this:

So if you want to use UDP packets and different payloads, you have to:

Moreover, I also want to know if you are converting the byte to an array or not? As I want to send and receive a file which will contain the piece of code (JAVA) which will be executed on another device.

Yes, everything is serialized, stored into the database and then deserialized over the network. When transmitting java code, perhaps you could implement a better (more efficient) way.

And how can I get the device name instead of the MAC address that is shown in the nearby peers' list?

If nearby doesn't supply you with the user name (previously set on the other device) then it is still not available. onNearbyPeers should definitely supply you with both the mac address and user name.

In addition to this, as I am working on a research project, so I can acknowledge your library in my research paper. However, I will require your assistance to accomplish the remote task scheduling in mobile devices connected.

That would be nice. :) You mean how to decide whether to connect to some device? In that case, see above. That loop in MainHandler.java is exactly that.

So, if you have enough time, we can set some time for a meeting on skype to discuss the tasks which I want to perform using your library and you can guide me accordingly, as you are well aware of your code whereas, I will require more time to understand it and then do it.

In addition to having a really shitty internet connectivity at home right now, I would prefer to minimise my time on this. It's totally OK to ask questions, post pull requests etc but if you are up to such big changes, it's inevitable you have to dig into the code anyway. So if anything is unclear - go ahead and ask but ideally, it should be code/project related questions.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-448241957, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOrYfNSzd-I0A7yai-TbgaS_FRqR6ks5u6P3ggaJpZM4ZTaVo.

mikrosk commented 5 years ago

Hey @hassammughal, have you made any progress? :)

hassammughal commented 5 years ago

Dear Miro, Thanks for getting in touch. I am working on my own library by using the UDP communication. And as I have less time, so we are for the time being not considering the P2P communication, rather the devices are connected with the Wi-Fi router and the packets are routed by the Wi-Fi router. However, for my thesis, I might get back to your library for implementing the P2P communication using UDP.

Thanks Best Regards,

Hassam Mughal Treasurer - IEEE Computer Society Karachi Section Co-Founder - Electronic Junkies Research Associate - Department of Information and Communication Engineering Hankuk University of Foreign Studies, Global Campus, South Korea

Email: hassam@hufs.ac.kr | hassam@computer.org | Mobile #: +821065030966


From: Miro Kropacek notifications@github.com Sent: Monday, January 21, 2019 11:10 PM To: croconaut/cpt Cc: Hassam Mughal; Mention Subject: Re: [croconaut/cpt] Bad Notification for startForeground (#15)

Hey @hassammughalhttps://github.com/hassammughal, have you made any progress? :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/croconaut/cpt/issues/15#issuecomment-456086697, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMhbOh6iggMHfvRjuOzq3GYeEh3wRYuGks5vFcpegaJpZM4ZTaVo.