Before you go, check out these stories!

0
Hackernoon logoHow I Programmed A Huawei GT-2 Watch To Display Net-Aggregate Crypto-Yields by@jare

How I Programmed A Huawei GT-2 Watch To Display Net-Aggregate Crypto-Yields

Author profile picture

@jareJarett Dunn

https://hacks.substack.com Accelerating by Design, Dropout Now Entrepreneur, Mental Health Advocate!

Well, after 2 weeks of waiting I received my Huawei GT-2. Sure, Chinawatch watches you and all, but that was fine with me.

My two seconds of research told me it was the superior watch. A 2-week battery life? I had a Samsung watch years ago I returned 2 days later because, after hacking it to interact with every app I had on my phone - including voice replies - the battery life sank to under 2 hours.

2 weeks should translate into.. maybe a day??

I had received a Huawei Watch 2 in a deal with my Huawei P30. Yes, I am Chinese. No, not really. They just know everything about me.

Anywho, I created a watch face to track the net yields of my aggregate Coindex trading bots that are live - three of them. I was going to re-learn even more Java to get these values into % average/projected Daily Percentage Returns but wanted to wait for my way-better watch first.

Really, no lie.

For you code rats out there I had to separate the web request into an async task and load my data there, saving to the object's instances of the variables. I also had to do some network configuration magic in an .xml.

class RetrieveFeedTask extends AsyncTask<Void, Void, String[]> {
    public String title = "Return %";
    public String btc = "";
    public String usd = "";
    private Exception exception;
    public String[] onPostExecute() {

            return new String[] {title, btc, usd};


    }

        private  String readAll(Reader rd) throws IOException {
            StringBuilder sb = new StringBuilder();
            int cp;
            while ((cp = rd.read()) != -1) {
                sb.append((char) cp);
            }
            return sb.toString();
        }

        public  JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
            InputStream is = new URL(url).openStream();
            try {
                BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
                String jsonText = readAll(rd);
                JSONObject json = new JSONObject(jsonText);
                return json;
            } finally {
                is.close();
            }
        }


        protected String[] doInBackground(Void... voids) {

        //do stuff
        try {
            // Day of week
            int responseCode = 0;
            JSONObject json = readJsonFromUrl("http://jare.cloud:8080/urls");
            System.out.println(json.toString());
            JSONArray arr = json.getJSONArray("urls");
            int count = 0;
            Double total = 0.9;
            int countb = 0;
            Double totalb = 0.9;
            for (int i = 0; i< arr.length(); i++){

                    Double btcstart = (arr.getJSONObject(i).getJSONObject(("subobj")).getDouble("btcstart"));
                    Double btca = (arr.getJSONObject(i).getJSONObject(("subobj")).getDouble("btc"));

                    Double usdstart = (arr.getJSONObject(i).getJSONObject(("subobj")).getDouble("usdstart"));
                    Double usda = (arr.getJSONObject(i).getJSONObject(("subobj")).getDouble("usd"));
                    Double usdp = ((usda / usdstart) - 1) * 100;
                    Double btcp = ((btca / btcstart) - 1) * 100;
                    total = total + usdp;
                    count = count + 1;
                    countb = countb + 1;
                    totalb = totalb + btcp;
            }
            btc = "%" + (totalb / countb);
            usd = "%" + (total / count);

            return new String[] {title, btc, usd };

        } catch (Exception e) {
            new RetrieveFeedTask().execute();

            e.printStackTrace();
        }
        return new String[] {"", "", ""};
    }


}

And, look how pretty the damn thing is. Leather strap and all.

Alright, it's on and updated. Next, we go inside to connect it to PC and enable USB debugging.

Right?

Right.

Wrong!

Turns out there is no build number in about to turn on dev options. Uncool, let's google how to do it.

Lo and behold folks, there is no USB debugging. There is no Play Store.

The damned Chinese made a non-Android watch that syncs with Android devices.

Woe is me, folks!

It's not real!

Alright, now to explain a wee bit better. For my entire adult life I've been assuming everything 90% of the time and being right 75% of the time - leading some CEOs to call me incompetent, this actually saves me a sh#tton of time and I just make up the difference by correcting myself when I'm wrong.

Most people have a hard time even admitting they are wrong (ever). I feel this is a redeeming quality of mine. Some don't.

In this case, it bit me.

I skipped over reviews titled along the lines of 'Huawei GT-2 - Pretty Watch, Not So Smart?'

I assumed nobody - not even Huawei spies - would remove Android from Android watches.

At this point, I was still wearing my watch out of spite and as a self-loathing exercise. Nay, I wouldn't even return it. I would keep wearing it to punish myself.

I realized that as soon as COVID is done I'm shipping to Atlanta, to be an executive and real member of society (on vacation in the USA mind you). I realized that - in high tech and high finance - I couldn't wear this watch. It's embarrassing.

Then I realized: F**k 'em.

I can recreate the watchface using whatever the heck Huawei uses.

And the damn thing has 2wk battery life.

Moreover, it displays notifications from whatever damn app I want it to - not just the ones that have bought into Android Wear and made an app.

This thing does what I need it to. And better. And longer between annoying recharges. And I can still do my custom ridiculous stuff on it.

So screw it.

It's an edgelord fashion statement.

I don't need Android in me watch.

Tags

The Noonification banner

Subscribe to get your daily round-up of top tech stories!