FORUMS
Remove All Ads from XDA
Honor 7x
Win an Honor 7X!

[MOD] Working Samsung Gear App for non (also rooted) Samsung devices.

14,881 posts
Thanks Meter: 44,236
 
By j to the 4n, Recognized Developer on 29th January 2017, 11:27 AM
Thread Closed Email Thread
Update 12.10.2017

Quote:
Originally Posted by MehStrongBadMeh


Quote:
Originally Posted by Maik268

UPDATE
There is a new Gear S Plugin update available in PlayStore. They fixed the crashes, everything is working now.

Looks like even the modded gear app is not needed anymore. But I will check this later.

Sent from my HTC 10 using XDA Labs

Can confirm, updated to the latest Gear S Plugin and latest unmodded Gear App and everything is working properly on my HTC 10.

Gear App 2.2.17022862
Gear S Plugin 2.2.03.17101142N


In our Viper10 Thread we had multiple reports, that the Samsung Gear app force closes when trying to connect their device.

Seemed not just the HTC10 is affected though. From my google research I found also some logcats from other roms and devices posted with the same issue.
@Toni10 linked me to that thread today, opened by @kajos in the Samsung Gear S3 Forum..so it seems it's really a general issue.

Okay, so what is the issue:

Code:
-27 21:10:15.357 E/AndroidRuntime(6044): FATAL EXCEPTION: main
11-27 21:10:15.357 E/AndroidRuntime(6044): Process: com.samsung.android.app.watchmanager, PID: 6044
11-27 21:10:15.357 E/AndroidRuntime(6044): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/samsung/android/feature/FloatingFeature;
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.samsung.android.app.watchmanager.sdllibrary.FloatingFeature.getEnableStatus(FloatingFeature.java:11)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.samsung.android.app.twatchmanager.log.LoggerUtil$Builder.<clinit>(LoggerUtil.java:95)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.samsung.android.app.twatchmanager.util.HostManagerUtils.startPluginActivity(HostManagerUtils.java:551)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.samsung.android.app.watchmanager.setupwizard.HMConnectFragment.callPluginActivity(HMConnectFragment.java:377)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.samsung.android.app.watchmanager.setupwizard.HMConnectFragment.callPluginActivityWithDelay(HMConnectFragment.java:365)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.samsung.android.app.watchmanager.setupwizard.HMConnectFragment.access$200(HMConnectFragment.java:67)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.samsung.android.app.watchmanager.setupwizard.HMConnectFragment$1.handleMessage(HMConnectFragment.java:315)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at android.os.Handler.dispatchMessage(Handler.java)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at android.os.Looper.loop(Looper.java)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at android.app.ActivityThread.main(ActivityThread.java)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at java.lang.reflect.Method.invoke(Native Method)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
11-27 21:10:15.357 E/AndroidRuntime(6044): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.samsung.android.feature.FloatingFeature" on path: DexPathList[[zip file "/data/app/com.samsung.android.app.watchmanager-1/base.apk"],nativeLibraryDirectories=[/data/app/com.samsung.android.app.watchmanager-1/lib/arm64, /system/fake-libs64, /data/app/com.samsung.android.app.watchmanager-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
11-27 21:10:15.357 E/AndroidRuntime(6044): 	... 13 more
Bad coding, or intended, no idea.

A framework class com.samsung.android.feature.FloatingFeature is not found on none samsung devices.
I took the effort to decompile the sams h i t app and digged in the code and backtraced the issue.

The source of the bug (or intended behavior) is the samsung device detection:

Code:
.method public static isSamsungDevice()Z
    .locals 1

    invoke-static {}, Lcom/samsung/android/app/twatchmanager/TWatchManagerApplication;->getAppContext()Landroid/content/Context;

    move-result-object v0

    invoke-static {v0}, Lcom/samsung/android/app/twatchmanager/util/InstallationUtils;->hasInstallPermission(Landroid/content/Context;)Z

    move-result v0

    return v0
.end method
It also returns true even on none samsung devices.
Not sure why that fails. it checks if it can get android.permission.INSTALL_PACKAGES...that perm can be just granted to apps in /system.
So moving the app to /system should work too, to fix the issue for rooted users...still it should return falls and not true on none samsung devices that dont't have it on /system

The result of it is that causes the app to crash in LoggerUtil$Builder:

Code:
.method static constructor <clinit>()V
    .locals 2

    invoke-static {}, Lcom/samsung/android/app/twatchmanager/util/HostManagerUtils;->isSamsungDevice()Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-static {}, Lcom/samsung/android/app/twatchmanager/util/FloatingFeatureFactory;->get()Lcom/samsung/android/app/watchmanager/libinterface/FloatingFeatureInterface;

    move-result-object v0

    const-string v1, "SEC_FLOATING_FEATURE_CONTEXTSERVICE_ENABLE_SURVEY_MODE"

    invoke-interface {v0, v1}, Lcom/samsung/android/app/watchmanager/libinterface/FloatingFeatureInterface;->getEnableStatus(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_0

    const/4 v0, 0x1

    :goto_0
    sput-boolean v0, Lcom/samsung/android/app/twatchmanager/log/LoggerUtil$Builder;->SUPPORT_LOGGING:Z

    return-void

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method
that tries to access an method in a class just available on a samsung device and its framework:

Code:
.method public getEnableStatus(Ljava/lang/String;)Z
    .locals 1

    invoke-static {}, Lcom/samsung/android/feature/FloatingFeature;->getInstance()Lcom/samsung/android/feature/FloatingFeature;

    move-result-object v0

    invoke-virtual {v0, p1}, Lcom/samsung/android/feature/FloatingFeature;->getEnableStatus(Ljava/lang/String;)Z

    move-result v0

    return v0
.end method
It's the only location where a call requires the samsung framework.

So how to fix it:

We just modify the device detection method to return always false:

Code:
.method public static isSamsungDevice()Z
    .locals 1

    const/4 v0, 0x0

    return v0
.end method
...recompile, resign and it's done.

So far I got 4 reports that it indeed works...so it should also for others.
Since I had to resign the app, ensure you uninstall the original one before installing the fixed version.

When an update in playstore drops for the gear app, and it still force closes, uninstall it and install my fixed version again.
Since I won't monitor that thread...someone should shoot me a PM, so I can merge my fix to the new version from playstore.



Code:
Update 06.09.17 
Samsung Gear to fix custom binary message on samsung devices
Gear S Plugin 2.2.03.17061361
Samsung Health 5.12.0.025

Update 30.06.17 
Accessory Service 3.1.51.70612
Gear S Plugin 2.2.03.17041441N
Samsung Health 5.9.1.003

Update 02.04.17 
Accessory Service 3.1.39_170322

Update 01.04.17 
Samsung Gear 2.2.17022862
Gear S Plugin v2.2.03.17032442N

Update 08.02.17 
Added modifications to new Gear App 2.2.16121661

Update 03.02.17
The installation issue some people were having seems to got resolved by signing the Gear S Plugin and Samsung Accessory Service with the same signature as the resigned Gear App.
All three files are uploaded on Google Drive now (xda does not allow zips > 20mb, and no single apks > 8MB)

Downloads:
Samsung Gear Apps

The Following 58 Users Say Thank You to j to the 4n For This Useful Post: [ View ]
 
 
30th January 2017, 05:31 AM |#2  
Account currently disabled
Flag Gotham
Thanks Meter: 918
 
More
Great I was looking for this gear thing since a long time
Thanks buddy
30th January 2017, 06:30 AM |#3  
Mkkt Bkkt's Avatar
Senior Member
Thanks Meter: 167
 
More
Thank you so much man , was waiting for this
30th January 2017, 09:04 AM |#4  
Junior Member
Thanks Meter: 1
 
More
Thank you so much !!!, I was waiting for months this solution !!
30th January 2017, 11:05 AM |#5  
j to the 4n's Avatar
OP Recognized Developer
Flag apktool d -b -f Freetime.apk xda
Thanks Meter: 44,236
 
Donate to Me
More
66 downloads, seems a a few waited for that fix :P
The Following 8 Users Say Thank You to j to the 4n For This Useful Post: [ View ]
31st January 2017, 01:03 AM |#7  
Quinny899's Avatar
Recognized Contributor
Flag Ormskirk, Lancashire, UK
Thanks Meter: 5,124
 
Donate to Me
More
Looks like a similar method used to fix an almost identical crash with the Gear 360/Gear VR apps: https://forum.xda-developers.com/and...evice-t3400383
31st January 2017, 08:04 AM |#8  
Senior Member
Thanks Meter: 73
 
More
Quote:
Originally Posted by Quinny899

Looks like a similar method used to fix an almost identical crash with the Gear 360/Gear VR apps: https://forum.xda-developers.com/and...evice-t3400383

Do you think will this method also fix the FC in the Galaxy S7 ported camera app on non-samsund ROMs/devices?
31st January 2017, 10:45 AM |#9  
Junior Member
Thanks Meter: 8
 
More
Thank you very much for your work on this, I was looking for this for almost a month.

I can confirm its working on Xiamoi MI 4S with xiaomi.eu ROM (8.1.3)
31st January 2017, 01:04 PM |#10  
Quinny899's Avatar
Recognized Contributor
Flag Ormskirk, Lancashire, UK
Thanks Meter: 5,124
 
Donate to Me
More
Quote:
Originally Posted by Kikill3r

Do you think will this method also fix the FC in the Galaxy S7 ported camera app on non-samsund ROMs/devices?

Depends what the force close is, do you have a logcat?
The Following 2 Users Say Thank You to Quinny899 For This Useful Post: [ View ] Gift Quinny899 Ad-Free
31st January 2017, 01:30 PM |#11  
Senior Member
Thanks Meter: 73
 
More
Quote:
Originally Posted by Quinny899

Depends what the force close is, do you have a logcat?

I can make one
I'll flash the app and report back
If you manage to do this, the entire AOSP community will love you, I guarantee it. I have a Galaxy S7 on AOSP and the camera quality in the stock AOSP camera app is horrible. I've been looking everywhere for a S7 TouchWiz camera app port that works on AOSP, but none of them work

Oh yes I forgot to say, the app is a flashable zip that also contains frameworks and libraries and so on. Will this be a problem?
Thread Closed Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes