yashsingh1/xdaforums huggingface dataset:
[Samsung Galaxy Gear] xManMythLegend:
Interesting. Is it the phone that decides what to send..or is it the watch that decides what to show ?

Yeah I agree about a Dev section but if the other smartwatches dont have one this one probably wont either. Maybe stickies once some progress is made.
[Samsung Galaxy Gear] sepiroth887:
it seems to be a mix of both, the phone app does the broadcast and the Notifications app receives it and displays it. From what I can gather from the Evernote app, this includes sending data over the SASocket connection. This however is preceded by the app registering itself with the GearManager app as well during installation. (Hence the gear app in the store which handles this)
[Samsung Galaxy Gear] LuffarJoh:
Interesting intens are these:

com.samsung.accessory.intent.action.ALERT_NOTIFICATION_ITEM

com.samsung.accessory.intent.action.UPDATE_NOTIFICATION_ITEM

com.samsung.accessory.intent.action.CHECK_NOTIFICATION_ITEM

with the following extras

NOTIFICATION_PACKAGE_NAME

NOTIFICATION_ID

NOTIFICATION_ITEM_IDENTIFIER

NOTIFICATION_ITEM_URI

NOTIFICATION_TIME

NOTIFICATION_MAIN_TEXT

NOTIFICATION_TEXT_MESSAGE

NOTIFICATION_CONTACT_NAME

NOTIFICATION_MSG_PHONENUM

NOTIFICATION_APP_ICON

NOTIFICATION_LAUNCH_INTENT

NOTIFICATION_LAUNCH_TOACC_INTENT

NOTIFICATION_CUSTOM_FIELD1

NOTIFICATION_CUSTOM_FIELD2

The notification is then made as a json string and sent via a socket to the watch (I think) using Samsung Accessory API (class SASocket), which is not available yet but bundled in Gear Manager. The intent was also intercepted by a service that added it to a database.

The email, sms, missed calls are taken from contentprovider. The rest, Facebook, Twitter, Hangout is hardcoded by their app package and the notification is parsed when received. The intent that is receieved to get this info is com.system.action.NOTIFICATION

Notification localNotification = (Notification)localBundle.getParcelable("notification");
m = localBundle.getInt("notification_id", 0);

I haven got it to work yet though. I only get it to update the database, not firing the notification. Maybe some else is able?
[Samsung Galaxy Gear] gtxaspec:
na
[Samsung Galaxy Gear] sepiroth887:
Awesome! that kinda confirms what I have been seeing ( not too far of target phew ;) ) where is the actual intent from Facebook et al handled and converted to the json payload? Must be inside GearManager no? Or is there another service running which handles pushing the data to the Gear?

---------- Post added at 01:49 AM ---------- Previous post was at 01:47 AM ----------

There is a post here in the Gear forum.. just search for it.

And make sure you use Windows.... on Osx i failed a few times.
[Samsung Galaxy Gear] LuffarJoh:
Its in SANotiProvider_signed.apk inside of gearmanager.apk in the folder preInstallApks. I actually managed to get a notification :) But it only works if you use a valid package name, i.e one of the hardcoded. There must be a way of adding packages without having to modify the code.

Every app pushes the data itself via the SSASocket. I havent looked that deep into that yet.
[Samsung Galaxy Gear] sepiroth887:
Cool, nice work :D i wonder are you using facebook or com.facebook.(cantRememberWhatTheFacebookAppWasCalled) ?

The evernote app uses this in the manifest:

<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver">

<intent-filter>

<action android:name="android.accessory.device.action.REGISTER_AFTER_INSTALL" />

</intent-filter>

</receiver>

<receiver android:name="com.samsung.android.sdk.accessory.IncomingFTRequestReceiver">

<intent-filter>

<action android:name="com.samsung.accessory.ftconnection" />

</intent-filter>

</receiver>

which i guess could mean the app is known to the gear. It also declares a SAAgent and SASocket subclass. The SAAgent i assume is what creates the payload in the first place while the SASocket receives it?
[Samsung Galaxy Gear] LuffarJoh:
I used com.facebook.katana which is the complete package name of the app. I think those manifest rows is just declaring that it's using the API where IncomingFTRequestReceiver is for incoming FileTransfers. All apks that are using the API/SDK are having REGISTER_AFTER_INSTALL. But that probably adds the app to the list.

I dont know exectely how the payoad is created more than that SASocket have a send method that writes to a ByteStream (which is how bluetooth communicates). The SAAgent I belive handles the state of the connection. So what I can tell every app that want to send anything writes a JSON objet to a socket on their own link to the Gear.
[Samsung Galaxy Gear] sepiroth887:
Slowly it's coming together ^^

So I would assume that the phone is running an app which is probably implementing an SASocket and sends json payloads ( obviously as simple as payload.toString().asBytes() on a specific channel. The phone app counterpart will receive the payload, parse it into the JsonObject and extract whatever info was sent. This then can trigger an intent on the phone by broadcasting it to the com.samsung.accessory.intent.action.ALERT_NOTIFICATION_ITEM which should handle it from there.

I shall start testing this hypothesis ^^

followup:

on a gear app you could probably do something like this :

[MENTION=439709]override[/MENTION]

public void onReceive(int i, byte[] abyte0) {

try {

JSONObject jsonObject = new JSONObject(new String(abyte0));

Intent intent1 = new Intent("com.samsung.accessory.intent.action.ALERT_NOTIFICATION_ITEM");

intent1.putExtra("NOTIFICATION_PACKAGE_NAME", jsonObject.getString("packageName"));

intent1.putExtra("NOTIFICATION_TIME", jsonObject.getLong("time"));

intent1.putExtra("NOTIFICATION_MAIN_TEXT", jsonObject.getString("text"));

intent1.putExtra("NOTIFICATION_LAUNCH_TOACC_INTENT", jsonObject.getString("toaccIntent"));

broadcast.sendBroadcast(intent1);

} catch (JSONException e) {

Log.e("ATN.Socket","Failed to parse json", e);

}

}
[Samsung Galaxy Gear] LuffarJoh:
yeah, that would be my guess to :) Let me know if you manage to get something to work
[Samsung Galaxy Gear] sepiroth887:
will do. I might have some trouble getting the tools to work, this is a first on the android sdk for me... and yea well the emulator is not really helpful so all testing needs to be on the device.... Ill probably troll around here and pester people with questions as they arise ^^

---------- Post added at 03:37 AM ---------- Previous post was at 03:13 AM ----------

Damn i hit a roadblock... is there a way to get the decompiled samsung package java files to compile again without having to rewrite them?

I now have an agent, socket and broadcastreceiver together which should respond to an intent I defined and will fire from an app i build for the phone. HOWEVER... it will not compile because the samsung package was decompiled and is not native java... more like a hybrid between bytecode. anyone got the following packages as jars? com.samsung.accessory.api, com.samsung.accessory.safiletransfer and com.samsung.android.sdk.accessory ? Compilable source files would work too....

NEVERMIND I AM JUST GETTING TIRED!
[Samsung Galaxy Gear] LuffarJoh:
great to hear!

but what are you sending to the watch exactly?

---------- Post added at 01:14 PM ---------- Previous post was at 01:13 PM ----------

great to hear!

but what are you sending to the watch exactly? becasue I guess you need something hat responds and makes the notification'?
[Samsung Galaxy Gear] sepiroth887:
At this time I only try sending a custome notification with madeup content.

Once this works however I will start building a coompanion service on the phone that for the first iteration will send all notifications to the gear.
[Samsung Galaxy Gear] sepiroth887:
Btw feel free to keep all the spelling mistakes....
[Samsung Galaxy Gear] LuffarJoh:
But the problem as I see it is that that there is no service on the gear that will pick up the custom notification, or have I got this wrong? My tests show that it only accepts the pre-defined packages. Or did you figure out how to register a new application with the notification service, because that's what Evernote do right?

I tried to add that reciever in the manifest of an app that I installed on the gear but the app did not appear on the notification list in the manager on the phone.

Can you please share the Evernote apk so I can take a look at how they do it.

Skickat från min GT-I9500 med Tapatalk
[Samsung Galaxy Gear] sepiroth887:
The evernote apk is on the gear, just pull it via adb. Its in /data/app

And yes, I managed to register a custom made app with the gear manager. Turns out there are a couple things required.

a) the manifest needs a few entries that I will post/ have posted.

b) there needs to be an xml present that defines the channel on which to receive/send data

Oh and the watch app is installed on the phone rather fhan via adb push

Ill be on my mac shortly and will post a few snippets. Also I might create a git repo with what I have so far.

---------- Post added at 07:00 PM ---------- Previous post was at 06:44 PM ----------

following up:

in the AndroidManifest.xml these two entries seem to be required:

<application .... >

<receiver android:name="com.samsung.android.sdk.accessory.ServiceConnectionIndicationBroadcastReceiver">

<intent-filter>

<action android:name="android.accessory.service.action.ACCESSORY_SERVICE_CONNECTION_IND" />

</intent-filter>

</receiver>

<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver">

<intent-filter>

<action android:name="android.accessory.device.action.REGISTER_AFTER_INSTALL" />

</intent-filter>

</receiver>

..... more stuff here.

</application>

it also requires a few permissions to be set, namely :

<uses-permission android:name="android.permission.BLUETOOTH" />

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />

<uses-permission android:name="com.samsung.wmanager.WATCH_WAPP" />

<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FILE_TRANSFER" />

what I'm not sure about are read/write permissions and the FILE_TRANSFER one. Could be app specific.

in the accessoryservices.xml file (from what I have seen usually in /res/xml these entries need to be set:

<?xml version="1.0" encoding="utf-<resources>

<application name="YourApp">

<serviceProfile name="YourApp" role="consumer" serviceImpl="consumerServiceImplementation.class" id="someId" version="1.0"

xmlns:android="http://schemas.android.com/apk/res/android">

<supportedTransports>

<transport type="TRANSPORT_BT" />

</supportedTransports>

<serviceChannel id="538" qosDataRate="Low" qosPriority="High" qosType="UnrestrictedDatagramInOrder"

xmlns:android="http://schemas.android.com/apk/res/android" />

</serviceProfile>

</application>

</resources>

now what I'm not quite sure about is the id in the service profile, whether that is the id on the phone or on the gear or can be random.

The serviceImpl class also seems to be extending the SAAgent. So I guess it serves as an entry point to the watch app when the gearmanager establishes a connection.
[Samsung Galaxy Gear] LuffarJoh:
Great work! I missed to add the accessoryservice file. :-\

To get this working you also need to include the accessory sdk right? Which is not available yet, but can be taken from any other app that uses it.

A git repo would be great, maybe I can help if I get some time over.

Skickat från min GT-I9500 med Tapatalk
[Samsung Galaxy Gear] sepiroth887:
Thanks, yea, the sdk is required, basically for all the SA named things. SASocket / SAAgent etc. I pulled that out off either the gear manager apk or the evernote one, basically I build a jar from the classes.dex which I add as a library.
[Samsung Galaxy Gear] sepiroth887:
FYI, create two github repos :

https://github.com/sepiroth887/AllTheNotifications

https://github.com/sepiroth887/NotificationManager

the first is the gear app, the second is the first iteration on a service that handles incoming Notifications using the new NotificationListenerService

from Android 4.3

I had notifications on the gear working once at some point, however I fiddled so much I have yet to reproduce how. There must be some service hook missing.

The notification manager actually receives all notifications the phone shows right now (confirmed via logs) but it fails to actually broadcast the intent.

I'm running out of time this weekend but feel free to check it out, push improvements or ask questions.

Cheers
[Samsung Galaxy Gear] sepiroth887:
BAM SUCCESS! The first notification i have received! :D It seems the Gear Manager Notification service is very picky. But at least it seems to work. Installing the watch app via the phone, then the NotificationManager which is set to start a service on launch and doesn't do much

There is still the issue of getting the notification content. maybe that's why samsung didn't support all.... it's a real pain just now. Also not able so far to display more than the gmail or similar notifications show (i.e read more on device rather then some extended text)

But hey, not shabby for a first weekend with the gear :D

(PS if you try it make sure the allow Notifications for the app after installing it under Settings > Security > Notifications .... took me an hour to realize why i didn't get anything ... )

---------- Post added at 05:03 AM ---------- Previous post was at 04:54 AM ----------

Also its really simple to open the app the notification came frim which is also working.

Might not have time to continue much during the week so if anyone can feel free to build on it.
[Samsung Galaxy Gear] jorge.aragon:
Hi,

tried to install this via a S4 and it does not work. "App was not installed." That´s it.

Any ideas?

I was able to install evernote, runkeeper and any other app from the other thread. But not these.

Cheers, Jorge
[Samsung Galaxy Gear] mhoepfin:
This is great and exactly what the gear needs! So short on time these days but I will take a look and help if I can.
[Samsung Galaxy Gear] sepiroth887:
Not tested on s4 but will not work unless u run 4.3
[Samsung Galaxy Gear] LuffarJoh:
Any idea how to make the notification to contain more data, as an email? I haven't got that or a icon to work. Any idea?
[Samsung Galaxy Gear] sepiroth887:
No, it's quite frustrating. EasilyDo also is able to design the layout of the notification, e.g. giving it a nice blue border... I wonder if that is something only possible by circumventing the GearManager for notifications or at least producing the actual design and content on the watch.

The icon is another weird thing. it seems to expect an int, which I hoped was the res id for the drawable but that didn't work. So it might be an absolute path on the device, or a relative one. Somewhere in the /data/data folder on either the watch or the phone i spotted a couple of icon pngs which might be the ones being used.

Oh, did you try putting text into the NOTIFICATIONS_TEXT_MESSAGE extra?

---------- Post added at 05:22 PM ---------- Previous post was at 05:13 PM ----------

Actually Easily do doesn't design the notification, on click it just immediately starts the gear app and connects to the phone to get the notification

Hence they are able to style it.

The icon seems to be hardcoded into the NotificationConsumerService on the watch. :(
[Samsung Galaxy Gear] LuffarJoh:
Ok. It's really stupid to have hardcoded icons, why even bother to add that extra in the first place then. I guess that will be hard to get around, so making as EasilyDo I would think is the best alternative. The problem I'm facing is that I can't seem to get any activity launched om either the phone or the gear. I have tried adding the package name and custom intents but with ni luck. I must have missed something important here.

I tried the TEXT_MESSAGE but that text didn't appear anywhere. Have found out where the custom field 1 and 2 are going? Could it be intent extras? That would be a great way of delivering extra data to an activity.

I'm also trying to grab other applications notification but without using the NotificationListener. I'll let you know how it goes as soon I have something running. It's about using AccessibilityService.

Skickat från min GT-I9500 med Tapatalk
[Samsung Galaxy Gear] sepiroth887:
Yea, stupid sums it up, the more I look at the code the more it feels like a very rushed and poorly thought through app. It shows whats possible with the new Samsung SDK once it is finally released, but thats about it.

I have not found out what the custom field does, but my guess would be that same, extra intent data. I was able to launch pretty much any package that i passed into the NOTIFICATION_INTENT thing, so that seems to be what's used to set the action. AccessibilityService sounds like a good alternative to NotificationListener.... but from my quick glance I didn't see a way to pull sensible text data from AccessibilityEvents. But hey the week is still young !

It might be sensible to take a two pronged approach on this. Focusing on the phone app side, developing a way to establish a connection using the BT LE protocols and getting notification content. The other side would be the gear app which parses, interacts with the data, and fires the events locally. Basically it seems it's easier to write a new app rather then rely on a crap implementation from Samsung which is likely to change soon anyways.

Also it would mean designing the sent payload which gives greater flexibility and the possibility to leverage FasterXML for json ;) (something i'm rather familiar with at last :D)
[Samsung Galaxy Gear] nusul:
hello

i have installed:

- https://github.com/sepiroth887/AllTheNotifications/blob/master/gear_notifications.apk

- https://github.com/sepiroth887/Noti...tionManager/notificationManager.unaligned.apk

all appear in gear manager, and touchwiz

i have check notification in gear manager and in settings.

Now what else? :)
[Samsung Galaxy Gear] sepiroth887:
Enabled the app in security settings? That should be it... at that point you should get allll the notifications.... its pre pre alpha though, dont get your hopes up too high
[Samsung Galaxy Gear] americo85:
Do i install both application on the phone?or one on the phone and one on the gear?

Thanks
[Samsung Galaxy Gear] sepiroth887:
Should both be on phone. Are you using stock rom note ?

Can you check in application manager if the noticationManager service is running? If not run the notificationManager app once to start it.

Sorry first app I wrote, plenty of things unknown, so every bit of info helps. If you have adb, you can also send me the output from adb logcat which could help.
[Samsung Galaxy Gear] americo85:
Ok I already installed both on the phone and I'm running android 4.3

I did run the notificationmanager but it doesn't show in the application running.

On the gear under the notification setting it shows and allthenotification box is already checked.

Sorry I don't have ADB but if you want to ask me something else go ahead.

Regards
[Samsung Galaxy Gear] sepiroth887:
That sounds like the service has not the permissions yet or is not supported.

Do you have a menu entry in settings > general > security called Notifications?

If so there should be the notificationManager app name and a tickbox. Make sure its checked. Then try running the app again and check its running via applicationmanager.

if its not there I assume you are either not running android 4.3 or something else is buggered.
[Samsung Galaxy Gear] americo85:
Please check the screenshot.

I'm running 4.3 for sure but even when i run the applicationmanager it doesn't show on the running application.
[Samsung Galaxy Gear] humzat:
its coming along nicely, thanks for all the work, i tried as well and still no notifications pushed...will keep pre alpha testing...thx again.
[Samsung Galaxy Gear] sepiroth887:
Hmm that is odd. Ill recompile my code tomorrow and try to undo everything I did and go through the steps again. Sorry its not working for you. Though there is not much benefit to it yet really.

Good feedback though, jeep it coming :)
[Samsung Galaxy Gear] americo85:
No problem buddy I'm happy to help.
[Samsung Galaxy Gear] sepiroth887:
Actually I just realized that the AllTheNotifications app is running a service on the phone. Maybe there lies the problem.

Iirc I pushed the app at some point via adb... ill investigate...
[Samsung Galaxy Gear] swattie:
mmmmh also for me no pushig :)

but i'll be interested on the updates :o

@ dev:do you need something? a beer or two?:angel:
[Samsung Galaxy Gear] xManMythLegend:
Seriously if these guys get this to work properly for us they all deserve a few beers.
[Samsung Galaxy Gear] LuffarJoh:
Where you using the package name or a action intent when launching other applications?

Before we found out how to use the Samsung notifications I had a try establishing a bluetooth connection on my own. I didn't get it to work very well, but I think the problem was that I started a service that was bound to an application context, and not separate process. Also the watch needs to be doing the pairing.

To launch some kind of notification you can use an alarm which can trigger the screen and an activity with a custom look. That part worked very well actually.

But I think all this pairing and keeping the bluetooth connection alive is just too unstable. I think Samsung did a great job on that part. But please make a go for it. Hopefully you'll get it working better than me :) another pros for this way is that you can install it on any device, not just Samsung. :)

The biggest issue is still to get the notification content from the phone, or somehow make a receiver that other developers can use to broadcast their notification. But the chance of making big players like Twitter or Facebook do that is probably slim.

For you other who are having problems with the notifications, are you sure you have looked in the Android settings and enabled notifications, not in gear manager.

Skickat från min GT-I9500 med Tapatalk
[Samsung Galaxy Gear] mhoepfin:
Would you mind posting the jar files needed from the SDK to compile?
[Samsung Galaxy Gear] Jeshter2000:
As far as I know there is no SDK available!
[Samsung Galaxy Gear] mhoepfin:
There's not but they pulled the needed jar files from some other apps apk.
[Samsung Galaxy Gear] sepiroth887:
So. I tried again. Got it working, made a small improvement to what is displayed, no what works is the App name gets displayed and the intent will take you directly to it. It's far from being practical but a good start.

Now... there seems to be a bit of confusion on how to get it running. I attached a few screenshots on how it should look and what steps are needed.

also on the git repo, the notificationManager.apk file is up to date, feel free to pull and install.

Once install is finished, launch once, you should see just the name of the app and a black / white screen. That is good! The activity is only there to launch the service...

next go to settings > security and find this:

(if the image doesn't show look at the first attachment)

then make sure the box is ticked for the notificationManager

next got to the ApplicationManager under running and check that it looks somewhat similar to the last attachment

Either before or after this go ahead and install the gear_notifications.apk from your phone.

This should also push it to the watch.

Now try with your screen off to get a notification and hopefully it appears on the watch.

If that doesn't work, i will start looking into manually pushing the app to the phone. This however will require adb and possibly root access, so really last resort,
[Samsung Galaxy Gear] sepiroth887:
And as a short preview of what you should see on the gear:

A new notification received:

Archive view:

Cheerio, im off to work... :P
[Samsung Galaxy Gear] mhoepfin:
Great work so far, but I don't think the apk is getting pushed to the watch when I install it from the phone. Anyone get that to work?