-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android auto support #5880
Android auto support #5880
Conversation
This adds android auto support accordign to https://developer.android.com/training/auto/messaging/index.html#messaging However, since android auto is not officially supported in my country, the functionality is limited. Which means that I have not been able to fully test everything yet. What work is: * Message notification is shown. * When you click on it, the message is read.
I didn't notice any difference from before, but the developer documentation explicitly states that it should be set. https://developer.android.com/training/auto/messaging/index.html#messaging
import java.util.List; | ||
|
||
/** | ||
* Get the response text from the Wearable Device and sends an message as a reply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you copied this from the wearable receiver? Can you update the comment?
|
||
public static final String TAG = AndroidAutoHeardReceiver.class.getSimpleName(); | ||
public static final String HEARD_ACTION = "org.thoughtcrime.securesms.notifications.ANDROID_AUTO_HEARD"; | ||
public static final String THREAD_IDS_EXTRA = "car_heard_thread_ids"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align please
import java.util.List; | ||
|
||
/** | ||
* Get the response text from the Wearable Device and sends an message as a reply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update comment please
final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA); | ||
final long threadId = intent.getLongExtra(THREAD_ID_EXTRA, -1); | ||
final CharSequence responseText = getMessageText(intent); | ||
final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align please
return remoteInput.getCharSequence(VOICE_REPLY_KEY); | ||
} | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two space indents
|
||
private CharSequence getMessageText(Intent intent) { | ||
Bundle remoteInput = | ||
RemoteInput.getResultsFromIntent(intent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one line
@@ -233,6 +233,8 @@ private static void sendSingleThreadNotification(@NonNull Context context, | |||
notificationState.getMarkAsReadIntent(context), | |||
notificationState.getQuickReplyIntent(context, notifications.get(0).getRecipients()), | |||
notificationState.getWearableReplyIntent(context, notifications.get(0).getRecipients())); | |||
builder.addAndroidAutoAction(notificationState.getAndroidAutoReplyIntent(context, notifications.get(0).getRecipients()), | |||
notificationState.getAndroidAutoHeardIntent(context, notifications.get(0).getRecipients()), notifications.get(0).getTimestamp()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align please
return; | ||
|
||
RemoteInput remoteInput = new RemoteInput.Builder(AndroidAutoReplyReceiver.VOICE_REPLY_KEY) | ||
.setLabel("Reply").build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localize?
RemoteInput remoteInput = new RemoteInput.Builder(AndroidAutoReplyReceiver.VOICE_REPLY_KEY) | ||
.setLabel("Reply").build(); | ||
|
||
NotificationCompat.CarExtender.UnreadConversation.Builder unreadConvBuilder = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't abbreviate variable names
.addMessage(mContentText.toString()) | ||
.setLatestTimestamp(timestamp) | ||
.setReadPendingIntent(androidAutoHeardIntent) | ||
.setReplyAction(androidAutoReplyIntent, remoteInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align please
Thanks for the feedback! Since this was my first android, the lazy coder in me based it of the Ware code and forgot the comments :) However, I have fixed that, and the rest of your feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I request two indentation changes.
|
||
public static final String TAG = AndroidAutoHeardReceiver.class.getSimpleName(); | ||
public static final String HEARD_ACTION = "org.thoughtcrime.securesms.notifications.ANDROID_AUTO_HEARD"; | ||
public static final String THREAD_IDS_EXTRA = "car_heard_thread_ids"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are three unnecessary white spaces in front of each equal sign.
@@ -107,6 +107,9 @@ | |||
<meta-data android:name="org.thoughtcrime.securesms.mms.TextSecureGlideModule" | |||
android:value="GlideModule" /> | |||
|
|||
<meta-data android:name="com.google.android.gms.car.application" | |||
android:resource="@xml/automotive_app_desc" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
android:resource
and android:name
should start in the same column.
I have fixed the indentation changes. |
@@ -455,6 +458,19 @@ | |||
</intent-filter> | |||
</receiver> | |||
|
|||
<receiver android:name=".notifications.AndroidAutoHeardReceiver"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these need to be exported? (default true if you have an intent filter defined iirc)
wouldn't that allow any app on the device to send a signal message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested to set export=false for the ReplyReciever and that seems to work. So I have pushed a fix for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this one is still exported though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I didn't change that since is basically doing the same thing as the MarkReadReceiver that is explicitly set to exported=true. So setting AndroidAutoHeardReciever doesn't really change anything in regards to what external apps can do. But I can change and test this if you like it not to be exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a rule, no broadcast receivers should ever be exported unless they absolutely have to be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now tested this, and it worked fine. I have pushed a fix.
@@ -233,6 +233,8 @@ private static void sendSingleThreadNotification(@NonNull Context context, | |||
notificationState.getMarkAsReadIntent(context), | |||
notificationState.getQuickReplyIntent(context, notifications.get(0).getRecipients()), | |||
notificationState.getWearableReplyIntent(context, notifications.get(0).getRecipients())); | |||
builder.addAndroidAutoAction(notificationState.getAndroidAutoReplyIntent(context, notifications.get(0).getRecipients()), | |||
notificationState.getAndroidAutoHeardIntent(context, notifications.get(0).getRecipients()), notifications.get(0).getTimestamp()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please align this. notificationState needs to be below notificationState on the line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have pushed a fix for this.
This adds android auto support accordign to https://developer.android.com/training/auto/messaging/index.html#messaging However, since android auto is not officially supported in my country, the functionality is limited. Which means that I have not been able to fully test everything yet. What work is: * Message notification is shown. * When you click on it, the message is read. Closes #5880
in 3.24.0 |
One user is stating that with "SMS enabled, the notifications are doubling up. One from the Android system for SMS and the second from Signal." I suspect the SMS is being intercepted by the default messenger first. https://gist.github.com/fdc3e86e7ca5947959cef4235438c646 |
I have seen this too. But I fail to see how this is a bug in Signal, since that is the application selected to handle SMS.... which it does. I think this is a bug in either Android Auto, Android or Google Messanger, since they clearly sends out a SMS notification when they should not. And... if Signal doesn't send the android auto notification, the possibility of replying to messages from within Signal, and marking the Signal conversation as read/heard will not be available. In short, the application handling the SMS, must send the notification to be able to mark messages as read within the application and reply within the conversation. |
Have asked about this on the android auto forum |
One person from the Android Auto Team replied, and confirmed that Android Auto overrides the users preferences regarding SMS handling. To work around the issue with duplicate SMS notifications he proposed the following:
|
Is there some documentation on how this integration is supposed to work? Can we access Signal through the Android Auto app, or is this just to simply pass notifications and interact with Signal through there? Thanks! |
It is simply passing notifications and interacting through them. It is a
straight forward implementation of the Android auto messaging api linked in
the pull request. So take a look at that for info about how it works.
Den sön 18 dec. 2016 20:40Rubin Starset <[email protected]> skrev:
… Is there some documentation on how this integration is supposed to work?
Can we access Signal through the Android Auto app, or is this just to
simply pass notifications and interact with Signal through there? Thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#5880 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGH4ny5diEZI7AUTEQtqTy7IUwFHj59zks5rJYxAgaJpZM4K4We_>
.
|
@snaggen: Thank you for the response. I ended up using it today while driving a friend to the airport. I think this is a great feature and will hopefully keep some people from texting and driving (and if it does theni it's worth it). Thank you for implementing this. I searched around but couldn't find a good answer, is there any way to include Signal in the list of messaging apps Android Auto supports when you give it a voice commend to send a message to someone? Currently for me it only verbally lists Hangouts and SMS. |
@rubin110 I have not seen any Android Auto Api to define voice commands and things like that... what I currently have implemented seems to be what the api allows. But if you find out something about this that I have been missing, just let me know. |
@sneggen: I went searching again and you're correct, it doesn't seem like Google has exposed an API to do this yet. The behavior I'm talking about is when you issue the voice command "Send a message to Dana." The Android then verbal responds asking which messaging app to use and then lists them out, which for me is currently Hangouts and SMS. |
This adds android auto support accordign to https://developer.android.com/training/auto/messaging/index.html#messaging However, since android auto is not officially supported in my country, the functionality is limited. Which means that I have not been able to fully test everything yet. What work is: * Message notification is shown. * When you click on it, the message is read. Closes signalapp/Signal-Android#5880 Upstream commit: signalapp/Signal-Android@9148b7d
btw: #5619 should be closed (but it's locked, so I can't inform you there 😉 ) |
This pull request adds Android Auto support. I have implemented it according to the guidelines https://developer.android.com/training/auto/messaging/index.html
I have tested it using the Android Auto emulator and used it for two month in a car.
I didn't read the bit about the BitHub reward until i had done all my commits, but they are intended to be freebies.
Fixes #5619
//FREEBIE
First time contributor checklist
Contributor checklist
Fixes #1234
syntaxFREEBIE
in the commit message of my first commitDescription