[Samsung Gear Fit] LeJay:
Intro

This howto will explain how to sideload *.tpk and *.wgt applications on your Gear Fit2. It'll also cover how to re-sign the application with your own certificates. This can be required if the application does not include a signature that's valid for your particular Gear Fit2. For example, this would be the case for applications that haven't been accepted to the Galaxy Apps store.

Warning

Unless we get people to develop and share their applications for the Gear Fit2, essentially all applications will have been developed for a different device. This means you'll run into varying degrees of incompatibility. Even if the application installs, there's no guarantee it will run. And even if it does run, it may be a terrible experience. And please show some caution regarding what you attempt to install, I don't take responsibility if you break anything following the guide.

Getting your own author and distributor certificates for your Gear Fit2

In order to sign applications, you need an author and distributor certificate for our Gear Fit2 device. For applications on the Galaxy Apps store, Samsung would be the one who signs applications with a distributor certificate. Since you will be sideloading applications, there's no guarantee they contain a valid signature from Samsung. You there need your own distributor certificate. This certificate will only be valid for signing applications for your particular Gear Fit2, which is why I can't make one for you. However you'll only have to do this once and can uninstall Tizen Studio after you're done. Unless you want to develop applications for the Gear Fit2, of course.

Things to download

Java SE Development Kit 8

Tizen Studio 1.2 with IDE installer

Tizen Studio setup

To install, simply accept the software licence agreement and install both the Tizen SDK and data in their default locations.

After installation, Tizen Studio Package Manager should automatically launch. If not, launch Tizen Studio and choose Tools->Package Manager. In the Package Manager you choose the Extension SDK tab and install Samsung Certificate Extension. When it has been installed, close the window and launch Tizen Studio. Press OK for default workspace location.

Connect Gear Fit2 to Tizen Studio

On your Gear Fit2: Got to Settings->Gear info and turn on Debugging. Then go to Settings->Connections. Here you make sure Wi-Fi is turned on and logged on to the same Wi-Fi network as your Windows computer and that Bluetooth is turned off. The Gear Fit2 tend to automatically log off Wi-Fi networks if its connected through Bluetooth. While you can have both on if you're quick, simply turning off Bluetooth leads to much less frustration. You may have to restart your Gear Fit2 at this point to get everything working.

In Tizen Studio, you should see a drop-down list in the tool bar saying No Target. Open the drop-down list and choose Launch remote device manager. Here you press Scan and wait for your device's IP address to appear. You'll only see Tizen devices, so unless you have multiple, there will only be one result. If it doesn't appear, repeat the process above. On the toggle under Connect, turn it from off to on. On your Gear Fit2 it should say RSA key fingerprint: .... You accept on the device and should now be connected. Close down the Remote Device Manager window. The drop-down list should now say SM-R360 ....

Now you choose the menu item Tools->Certificate Manager. Add a new certificate profile by pressing the "+" sign up to the right and then select SAMSUNG as the type for your certificate profile. Go through the 4 tabs as follows

Device Type

Choose Mobile/Wearable and press next.

Certificate Profile

Choose Create a new certificate profile and type any name you want. Press next.

Author Certificate

Choose Create a new author certificate and press next.

Type in an author name and password. Make sure you remember the password as it will be needed for signing applications later on.

You'll now be asked to sign in to your Samsung account. If you don't have one, choose Create new account and follow instructions.

After you've signed in you should get a Congratulations! notice. Take note of the location of the author certificate and press next

Distributor Certificate

Choose Create new distributor certificate and press next.

For Privilege choose Partner. This defines how much of the Tizen API the applications you'll be signing are allowed to access. The three levels are Public, Partner and Platform with Platform being the highest level of access. Unfortunately that's not available to us, so we choose Partner.

IMPORTANT: Leave the password as it is.

Under the section Add individual DUIDs you should find the first entry contains something that starts with 2.0#.... That's your Gear Fit2's DUID. If you don't see it, press cancel (sorry) and go back to the Connect Gear Fit2 to Tizen Studio section above. If you do see, it press next. Make a note of the location of the distributor certificate. This should be the same as the author certificate from above. Then press Finish and you're done.

Signing and installing applications on your Gear Fit2

Things to download (See attachments to the post)

Fit2Installer

PacMan

We'll use PacMan as an example. It's a modified version of the PacMan application found in this xda post. Some of the other applications in that link work on the Gear Fit2, some don't.

Using Fit2Installer

Download and extract the Fit2Installer. The folder contains the following.

sdb.exe: Smart Development Bridge for Tizen devices. This allows us to connect to the device and install applications. See tizen.developer.org's sdb section for more information on what you can do with it.

7zipcli: The open source a command-line archiver from 7-zip. Used to package applications.

tizen: A very stripped down version of Tizen Studio that only contains the required files for signing and packaging applications.

cert: Empty folder where you're supposed to place your own certificates.

sign_me: Empty folder where you place applications you want to be signed.

install_me: Empty folder where you place applications you want to be installed on your device.

sign.bat: Batch script that will sign the applications put in sign_me

sign.bat: Batch script that will connect your Gear Fit2 to your computer, allowing you to install applications.

install.bat: Batch script that will install the applications put in install_me

connect.bat: Batch script that will connect to your Gear Fit2.

disconnect.bat: Batch script that will disconnect from your Gear Fit2.

Setting up your certificates

Go to the location of the certificates you generated with the Certificate Manager. The standard location is in your user folder under ~\SamsungCertificate\<name of cert profile>. The folder should contain 9 files. Copy all those directly into the .\Fit2Installer\cert\ folder. Eg, distributor.p12 should be placed as .\Fit2Installer\cert\distributor.p12.

Signing applications

There are two ways of using the sign.bat script.

Place a *.tpk or *.wgt file directly in the sign_me folder. Run the sign.bat script and type in the password you chose for your certificate earlier. If successful, this will produce a *.tpk or *.wgt file in the install_me folder.

If you don't have the package file, but rather just a folder containing the files for the application you'll have to place that folder in sign_me. For *.tpk files, this means the path will be .\Fit2Installer\sign_me\<application_folder>\tizen-manifest.xml. For *wgt files it will be .\Fit2Installer\sign_me\<application_folder>\config.xml. Now, run the sign.bat script and type in your certificate password.

As an example, I've attached PacMan. PacMan is a web-app that was packaged for the Gear S2. In order to get it to fit the Gear Fit2 screen, I had to extract the PacMan.wgt file and make a few changes to the code. Changes to the files invalidates the signature, so I had to resign it using my own certificates. If you've everything set up correctly, this should be fairly simple for you to do too.

Extract the PacMan.zip archive and place the content in the folder .\Fit2Installer\sign_me\PacMan\ and run the sign.bat script. Look in the install_me folder to check there's a *.wgt file for PacMan.

Installing applications

As in the earlier section Connect Gear Fit2 to Tizen Studio, make sure you're on Wi-Fi, bluetooth is off and debugging in turned on. Also, make sure you only have one Tizen device connected to your computer (this includes Tizen emulators).

Run the connect.bat script and type in the IP address of your Gear Fit2. If you do not know the IP address, you can find it on the device under Settings->Connections->Wi-Fi->Wi-Fi networks-><wifi_name> and at the bottom of the list. Make sure you allow sdb.exe through your firewall.

Important responses are:

error: failed to connect to remote target <ip address>

Make sure you've set up your device correctly. Try turning Wi-Fi off and on. Or even a reboot of the device.

device unauthorized. Please approve on your device.

This may mean you have to accept the RSA key fingerprint on your Gear Fit2. However, there appears to be a bug in the sdb that causes this to happen regardless. Try to run the script twice and see if you get the message below:

<ip address>:26101 is already connected

Now you know for sure your device is connected.

After you've connected, you can safely turn Bluetooth back on. Remember to run disconnect.bat when you're done installing applications. Your Gear Fit2 will otherwise stay connected and drain a lot of battery.

Similarly to using the sign.bat script, there are two ways of using the install.bat script. Both of them require the application to already have a valid signature.

Place a *.tpk or *.wgt file directly in the install_me folder. Run the install.bat script.

If you don't have the package file, but rather just a folder containing the application you'll have to place that folder in install_me. For *.tpk files, this means the path will be .\Fit2Installer\install_me\<application_folder>\tizen-manifest.xml. For *wgt files it will be .\Fit2Installer\install_me\<application_folder>\config.xml.. Run the install.bat script.

Since PacMan should already be signed and placed correctly in the install_me folder, you can now run the install.bat script to install it on your Gear Fit2.