yashsingh1/xdaforums huggingface dataset:
[Android Software Development] robotoHero:
UserAgent - MacAddress

Hey,

I've been trying to get my new Gear 360 running on my Nexus 5X with Android 7.1.1 and ran into what I think are the same issues.

I can connect via bluethooth and look at the settings of the cam, see the battery status and so on, but trying to access the live view or the gallery ends in a never ending 'Loading...' screen.

Now, I'm fairly new to 'instrumenting' existing APKs but I found out that a problem seems to be that the UPNP services can't connect to the camera.

At one point I got a log entry of:

12-29 01:11:58.106 21066 21498 D ACM_CYBERGARAGE: [UPNPController.java : 396] bStarted : false userAgent : SEC_RVF_ML_02:00:00:00:00:00 accessMethod : manual

Which looks a bit strange to me as this is not my wifi card MAC address.

When I got the phone connected to the camera access point, I also tried to connect to 192.168.107.1:7676/smp_2_ with wget (that url comes from another log entry, when the BT service connects.

This did not work, or rather wget timed out. That looked suspiciously like the errors I could see from the Samsung app.

Next step: I tried to send the above UserAgent to the camera with my wget command which still did not work.

Next step: Using my phone Wifi MAC address with the prefix 'SC_RVF_ML_' with wget and, TADA, I get a response!

wget -U "SEC_RVF_ML_MY:MAC:IN:UPPER:CASE" 192.168.107.1:7676/smp_2_ -O -

So, figuring out where that wrong MAC address comes from. turns out to be:

com\samsung\android\samsunggear360manager\app\pullservice\util/PUtils->getAgent

Now, it's fairly late and I'm gona go to sleep.

But maybe someone can make some use of this information.

- Dom

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

So, it looks like you have to get the mac address in a different way on Marshmallow and above.

http://stackoverflow.com/questions/33103798/how-to-get-wi-fi-mac-address-in-android-marshmallow
[Android Software Development] Thenetstriker:
I think I found the error that is crashing the settings:

12-24 13:54:24.862 10034 10034 E AndroidRuntime: FATAL EXCEPTION: main
12-24 13:54:24.862 10034 10034 E AndroidRuntime: Process: com.samsung.android.samsunggear360manager, PID: 10034
12-24 13:54:24.862 10034 10034 E AndroidRuntime: java.lang.NoSuchMethodError: No virtual method getSubSystem()Ljava/lang/String; in class Landroid/os/storage/StorageVolume; or its super classes (declaration of 'android.os.storage.StorageVolume' appears in /system/framework/framework.jar)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at com.samsung.android.samsunggear360manager.util.SDCardUtils.setStorageVolume(SDCardUtils.java:109)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at com.samsung.android.samsunggear360manager.app.btm.BTSettingsActivity.onCreate(BTSettingsActivity.java:408)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.app.Activity.performCreate(Activity.java:6285)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.app.ActivityThread.access$900(ActivityThread.java:154)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.os.Handler.dispatchMessage(Handler.java:102)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.os.Looper.loop(Looper.java:234)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at android.app.ActivityThread.main(ActivityThread.java:5526)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at java.lang.reflect.Method.invoke(Native Method)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-24 13:54:24.862 10034 10034 E AndroidRuntime:	at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)

It seams as the app is accessing a method that does not exist on my device. I've decompiled the app and here is the code for this "setStorageVolume":

@SuppressLint({"NewApi"})
public static void setStorageVolume(Context paramContext)
{
mStorageManager = (StorageManager)paramContext.getSystemService("storage");
int j;
int i;
if (mStorageManager != null)
{
paramContext = mStorageManager.getVolumeList();
j = paramContext.length;
i = 0;
}
for (;;)
{
if (i >= j) {
return;
}
if ((paramContext[i].isRemovable()) && (paramContext[i].getSubSystem().equals("sd"))) {
mSDStorageVolume = paramContext[i];
}
i += 1;
}
}

For the other problems I will also provide logs as soon as I find the time to test this.
[Android Software Development] Quinny899:
That's exactly what I was finding yesterday, but you found where it's failing to get the MAC. I think I can smali edit the method with a bit of luck

EDIT: Modified it to it always returns my phone's real MAC (just using a string of the MAC), made no difference, still fails. The userAgent is right though:

(It shows my MAC but I blurred it)
[Android Software Development] robotoHero:
I've used code from StackOverflow to get the mac address the right way, compiled it and put the smali file to the APK.

There are two parts. A class with a static function to get the mac address and a changed PUtils.

Heres the code to get the mac address:

https://gist.github.com/codewithpassion/2a741a170d96d54912dc11c10b58f98f

And here is the new getAgent method for PUtils:

https://gist.github.com/codewithpassion/a480fde6a77de057c495f0db97e18d21

Having said that, I'm at the same point. The connection still doesn't work.

From the log I can see that it fails with the HttpServerList now.

org/cybergarage/http/HTTPServerList

Gona look into that later.

-Dom
[Android Software Development] Quinny899:
It fails to find the device on the network I think, HTTPServerList is empty in ControlPoint (which is the calling class)
[Android Software Development] robotoHero:
Ok, so accroding to https://github.com/cybergarage/cybe...a/org/cybergarage/upnp/ControlPoint.java#L852

it tries to open a HttpServer (on the phone) and bind a port for it.

I got logging in place that shows that it get a port number (line 850) and then call to httpServerList.open(bindPort) returns false, what put's it in a loop until the retry counter is full.
[Android Software Development] Quinny899:
I've been trying to work out what port it SHOULD be binding, it loops starting at 8059 (the default eventsub port from ControlPoint.java) and increases by 1 to 8159. Might have to use both the semi-working Nexus 5 to see what's supposed to happen and the 5X to see what isn't I think

Below is the replacement method for getHTTPPort that logs the http port value to the logcat. I also highly recommend PidCat for this, as it can ignore all the other apps' messages when WiFi/Bluetooth state changes

.method public getHTTPPort()I
.locals 3

.prologue
.line 231

const-string v1, "DEBUG"
iget v0, p0, Lorg/cybergarage/upnp/ControlPoint;->httpPort:I
invoke-static {v0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;
move-result-object v2

invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

return v0
.end method

---------- Post added at 04:54 PM ---------- Previous post was at 04:39 PM ----------

The correct port is 8059, according to my N5. Something interesting though, the MAC address reported in that device's userAgent is NOT the MAC from the phone (as expected, it's running 6.0), but is in fact the phone number from the SIM which is no longer in the phone. That's this bit then:

Question is, why does it try to connect to 8059 and fail on 7.x
[Android Software Development] Thenetstriker:
Here is now also the log when I try to download an image on my Xperia Z3: http://pastebin.com/Vxma4b93

And here is the log when I'm opening LiveView: http://pastebin.com/DkqHa2ma

I hope you find a way to get to work on older Xperia phones.
[Android Software Development] robotoHero:
Have some issues with my laptop, so I can't give too many details right now.

The last thing was that I found out that it could not start the http server. In that method (sorry, forgot the name) it tries over the network addresses and bind to ports on them. The problem is that it doesn't get any network addresses. It's all in that cybergarage code. Haven't had time to look at the code that iterates the network addresses. The function was called something like "getNNetworkAddresses" returning an integer.

That function returned 0 in my test.

That would cause the whole startup to fail and then it tries with a different port.
[Android Software Development] Quinny899:
This bit here is the problem, I think. On 6.x ((NetworkInterface)v4).toString() returns

[wlan0][21][/fe80::(snip):a2ba%wlan0%21][/192.168.107.105]

Whereas on 7.x it returns

name:wlan0 (wlan0)

(as far as I can tell, it's either that or a list of interfaces)

org/cybergarage/net/HostInterface/getNHostAddresses()

Basically it looks like NetworkInterface has changed and we need to fix that. It's late here so I'm stopping for the day though

EDIT: I didn't see your post before posting this but yes it's the same method I found. Definitely the problem, I'll work on it tomorrow
[Android Software Development] Edwinj40:
Can this work on a samsung s5 with android marshmallow installed ?
[Android Software Development] Quinny899:
Right, I changed /192. to wlan0 and it now opens to Live View. Or it starts to.

With or without libhardware.so/the gralloc.so mentioned in the log, this error prevents it working. Chances are it would work with the patched APK without live image, but who wants that?

This is what's causing the issue
[Android Software Development] robotoHero:
Great work man!

My laptop is back in action and I could verify your work.

Now crashing with gralloc :)

---------- Post added at 01:46 PM ---------- Previous post was at 01:28 PM ----------

Hum, that worked exactly once.

Now when I try again I get:

12-30 13:37:31.432 30758 31635 D ACM_CYBERGARAGE: [UPNPController.java : 396] bStarted : true userAgent : SEC_RVF_ML_2C:___________ accessMethod : manual
12-30 13:37:31.432 30758 31635 I System.out: ======================= SSDPSearchRequest ===============================
12-30 13:37:31.432 30758 31635 W System.err: java.net.MalformedURLException: no protocol: *
12-30 13:37:31.432 30758 31635 W System.err:	at java.net.URL.<init>(URL.java:589)
12-30 13:37:31.432 30758 31635 W System.err:	at java.net.URL.<init>(URL.java:486)
12-30 13:37:31.433 30758 31635 W System.err:	at java.net.URL.<init>(URL.java:435)
12-30 13:37:31.433 30758 31635 W System.err:	at org.cybergarage.http.HTTPRequest.getFirstLineString(HTTPRequest.java:326)
12-30 13:37:31.433 30758 31635 W System.err:	at org.cybergarage.http.HTTPRequest.getHeader(HTTPRequest.java:345)
12-30 13:37:31.433 30758 31635 W System.err:	at org.cybergarage.http.HTTPRequest.toString(HTTPRequest.java:670)
12-30 13:37:31.433 30758 31635 W System.err:	at org.cybergarage.upnp.ControlPoint.search(ControlPoint.java:785)
12-30 13:37:31.433 30758 31635 W System.err:	at org.cybergarage.upnp.ControlPoint.search(ControlPoint.java:793)
12-30 13:37:31.433 30758 31635 W System.err:	at com.samsung.android.samsunggear360manager.app.pullservice.controller.UPNPController$2.run(UPNPController.java:408)
12-30 13:37:31.433 30758 31635 W System.err:	at java.lang.Thread.run(Thread.java:761)
12-30 13:37:31.433 30758 31635 I System.out: M-SEARCH * HTTP/1.1

12-30 13:37:31.433 30758 31635 I System.out: ST: ssdp:all

12-30 13:37:31.433 30758 31635 I System.out: MX: 3

12-30 13:37:31.433 30758 31635 I System.out: MAN: "ssdp:discover"

12-30 13:37:31.433 30758 31635 I System.out:
[Android Software Development] Quinny899:
Gralloc is fixed by making it a system app - this modification is going to need root now.

Maybe the wlan0 patch doesn't fix it then
[Android Software Development] robotoHero:
Can you please make that apk available somewhere? or get me the gralloc so file?

Thanks!
[Android Software Development] Quinny899:
Different signature on these APKs because I'm using Virtuous 10 Studio for Smali editing and it's using its own signature

https://drive.google.com/file/d/0BwduK1C1PXjxQ1A1Z2JOb0cyOU0/view?usp=sharing

You'll probably need to push it to the system & then install normally after a reboot because of the libs

I'm using Magisk so I made a quick module too

https://drive.google.com/file/d/0BwduK1C1PXjxMFBPWDJ5Ym9QcnM/view?usp=sharing

(Install module, reboot, install APK from above or it will just crash)

THESE ARE NOT WORKING APKS, IT DOES NOT FULLY WORK ON 7.0 YET
[Android Software Development] robotoHero:
According to http://www.upnp-hacks.org/upnp.html

M-SEARCH * HTTP/1.1

is valid. I'll be looking into it later.

- Dom

---------- Post added at 02:43 PM ---------- Previous post was at 02:41 PM ----------

Thanks!

---------- Post added at 02:54 PM ---------- Previous post was at 02:43 PM ----------

Can we not add the missing lib in the apk directory? Like with the other libs that were missing before?

The library loader should find it there too, shouldn't it?
[Android Software Development] Quinny899:
I tried, it didn't work

gralloc is device dependent as well so it would be pointless

EDIT: never mind it apparently doesn't work from system after attempting a few times. It's broken there too
[Android Software Development] Quinny899:
If anyone is interested, by adding the libs & modifying the Smali (/192. -> wlan0) of the no-liveview mod, it DOES work on 7.x, with the following caveats:

- Stitching fails when viewing a 360 image on the phone (gralloc error) - 180 photos and all videos work though

- Sometimes crashes when trying to delete an image/video, but the image/video is still deleted (just restart)

- The Camera UI will often stop responding, open & close recents and it will respond again (most notable when starting a video or switching modes)

Screenshots: http://imgur.com/a/mk7TP

APK (has V10 Studio signature so you may need to reinstall): https://drive.google.com/file/d/0BwduK1C1PXjxTW9jSW5OVDFITms/view?usp=sharing
[Android Software Development] tobiume:
the password of the gear 360 wifi network that is AP_Gear 360

You can easyly find your password of the gear 360 wifi direct password.:laugh:

1 Press and hold the Menu button until you see "Gear 360 Manager".

2 Press the Menu button twice until until you see "Google Street View".

3 Press the button on the top of the camera to select this mode and turn on Wi-Fi.

4 Make sure your phone is fully charged.

5 On your phone, open the Settings app.

6 Connect your phone to the 360 camera's wifi network (which will end in ".OSC"). The default password is the set of 8 numbers shown on the second line of the camera display.
[Android Software Development] noXi89:
Just want to mention that this password seems to be also the password used in the "Gear App Mode" when the App switches from Bluetooth to Wifi.

---------- Post added at 03:40 PM ---------- Previous post was at 03:13 PM ----------

At first: thanks!!! At least I can use my unrooted 6P now with my gear 360. Awesome work! :good:

Sorry I'm new to the android apk hacking thingy, but do you have any idea why it does not use the existing device specific gralloc lib in 7.x? Also if you change the matching string to "wlan0" wouldn't it select interfaces which are not ready (have no ip)?

Edit: didn't see the link in your post. Thats bad news.
[Android Software Development] Quinny899:
There's no way for us to fix the live view/stitching on 7.x. The good news is that it's an issue ALL 7.x devices should have, so Samsung will have to fix it or it won't work on the S7 when it gets nougat. When they fix it, we can patch that version and be on our way

On the subject of wlan0, it only actually triggers that code when you connect to a network, so yes it would probably crash or fail in another way if you connected to the wrong network manually when it was loading, but wlan0 is almost always the right network, and so should work just fine
[Android Software Development] Twiga78000:
Hello, I've the same problem than Biilford 2, on my Galaxy Notes 3 : Freeze with black screen when i try to view the live view... could you please try to understand that ? Thanks a lot by advance for your quick answer...
[Android Software Development] Quinny899:
Use the mod without live view, your device isn't powerful enough to handle it
[Android Software Development] pandapewpew:
Love the work, thanks! After installing both items, being able to connect with Bluetooth and Wifi, Gear Manager gets stuck on loading. Then dies. Any suggestions?
[Android Software Development] Quinny899:
Using Android 7.x? Use the APK I posted a few posts back, it's the liveview-disabled mod patched to work on 7.x
[Android Software Development] Quinny899:
http://www.apkmirror.com/apk/samsun...gear-360-manager-1-0-13-android-apk-download/

TARGETS ANDROID 7.0, THIS MAY FIX THE PROBLEMS

When ported of course, which I'll do tomorrow
[Android Software Development] Quinny899:
Galaxy S8 anyone?
[Android Software Development] herwigk21:
since the upgrade to cm 14.1 / android 7.1 the app doesn´t start at all.

logcat:
[Android Software Development] Bearcameron:
Hi People,

I just try the new update app for 7.0 on my Pixel it will load the app when I don't have Samsung accessory service install, but without it the app just say enable Samsung accessory service.

I'm missing a step on installing the apk.

Cheers
[Android Software Development] Quinny899:
You can install the accessory service but without the APK being patched it will crash because of a missing Samsung feature
[Android Software Development] Quinny899:
On the subject of the small image files, I've looked at [MENTION=1346722]Bin4ry[/MENTION] 's code for dumping them using a samsung device (and borrowed my brother's S5), and tweaked the code:

Rather than setting the image and then decoding the bitmap using BitmapFactory, set the image and get the drawable from the image using ImageView.getDrawable. Convert this to a Bitmap, and save that to file at 512x512 (rather than getIntrinsicWidth/getIntrinsicHeight). Has to be done in an AsyncTask to stop ANRs and wrong images

Entire project is attached, as well as the larger PNGs, credit goes to Bin4ry as I only modified the code a little. As the MinSDK for Gear360 is 5.0, I'll probably batch convert these images to vectors for a smaller image size before release

--------

After upgrading the icons:

Just spent some time making sure that all the icons are correct from the conversion from Samsung's format to PNG (some of mine were not), you can really see the difference between the two icon sets here
[Android Software Development] Quinny899:
- Blanked, see OP now -
[Android Software Development] Thenetstriker:
I'am looking for a new phone that is affordable and easy to root. I've looked at a few Motorola phones and I'am wondering if this app would run with all features on those phones. Are there any known minimal requirements to get every feature (Stich, Gallery, LiveView) to work? (e.g. minimal Ram, Cpu requirements)

At the moment I prefer the Moto G4 Plus with 64 GB memory and 4 GB ram. Would this be enough for this app to work?
[Android Software Development] Quinny899:
Just updated the APKs to fix it crashing when viewing a stitched image, seems to work 100% now
[Android Software Development] Bearcameron:
Great work Quinny899, I have try both apps they both open and can use liveview works well.

I just can't save picture or video to my phone, I'm using a pixel XL
[Android Software Development] Quinny899:
Anything with a fairly decent CPU should be able to handle the full version, anything with a lower power CPU can use the liveview-less mod

The G4 Plus should definitely work with the full version

---------- Post added at 07:58 PM ---------- Previous post was at 07:56 PM ----------

I think that might have been fixed in the APK I just uploaded
[Android Software Development] Bearcameron:
wow Quinny899 you are a god, thank you very much for your hard work.

All working now!
[Android Software Development] maxpd:
My galaxy s5 cant open 360 images or live view

Gesendet von meinem SM-G900F mit Tapatalk
[Android Software Development] japeswarsingh:
gear's wifi does not connect to my one plus3 phone

i have even tried manual settings as told by you in previous posts but still it is not connecting. the wifi of gear is only visible sometimes so i cannot connect them to my phone.

i have one plus 3
[Android Software Development] Quinny899:
Make sure you're manually connecting to the camera's WiFi, it doesn't always automatically connect
[Android Software Development] maxpd:
Connecting isnt a problem

Gesendet von meinem SM-G900F mit Tapatalk
[Android Software Development] Quinny899:
Then what is the problem?
[Android Software Development] maxpd:
When i am connected and try to open a 360 image its saying the the image will be prepared and then nothing happens anymore. So the 2 images from the camera arent getting merged.

If i try to open live view its saying that live view will be prepared and after a minute the complete screen turns black. But doesnt switchs off

Gesendet von meinem SM-G900F mit Tapatalk
[Android Software Development] Quinny899:
Your device isn't powerful enough, use the version without live view linked in the OP
[Android Software Development] davidguiza:
Awesome! Thank you so much [MENTION=3563640]Quinny899[/MENTION], it works like a charm!

Having the Gear 360 Viewer running on my Nexus 5x would also be awesome if you have the time. :D
[Android Software Development] Quinny899:
I'd kind of like to see if it works on my 5X with a cardboard headset actually, so may try later today
[Android Software Development] Quinny899:
Done, see linked APK. It appears to literally just be the same video and photo viewer as the one in the Manager, but if someone has a Gear 360 headset and no camera I suppose this is a smaller alternative

https://drive.google.com/file/d/0BwduK1C1PXjxNF94ZTNSaFBUWkE/view?usp=sharing
[Android Software Development] sambartle:
Thanks for the awesome work on this, this is the closest to working for me so far.

I'm a but stumped by why it works fine on your Nexus 5X, with what I assume is a UK model camera, when with mine (Nexus 5X (7.1.1), and a UK Model Gear 360) it almost works, but never ever gets past the "loading..." popup when trying to go to live view or the Gear 360 tab.

I've tried manually connecting to the Gear 360's WiFi signal after pressing the live view button in the app to send the bluetooth command to turn on the Access Point.. but it still never gets past loading.. (same if i try to view the photos on the Gear 360 tab of the app)

Is there some trick to it?
[Android Software Development] Quinny899:
I've just had this on my 5X, no idea what caused it but reinstalling the same APK fixed it. It may be random though, rebooting both devices may or may not help also
[Android Software Development] sambartle:
Thanks, I did try a reinstall and a reboot, but ill keep fiddling see what I can do.
[Android Software Development] sambartle:
Do you use a Stock android release on your 5X [MENTION=3563640]Quinny899[/MENTION] ?

I've tried so many times and not managed to get connected once so far! I even reset my phone and re-flashed the latest 5X factory image to see if that helps last night with no luck.. I cant figure out how to reset the Gear 360, but if I can do that, that is the next thing (I've currently got the battery out for a few hours as the manual does mention leaving the battery out may reset it)..

The closest I have got to it working is occasionally I can use the lock screen shutter notification to take a photo, but live view, and viewing content has eluded me for hours now.