Blog

Fixing "read: unexpected EOF!" error when using Logcat on Android 8.0

posted by Zhuowei Zhang

Android 8.0 Oreo's Logcat program often exits with the message "read: unexpected EOF!" when a large amount of logs is printed in a short amount of time. I found this StackOverflow post that fixed the problem by increasing the log's ring buffer size.

Run:

adb logcat -G 1m

to increase the log buffer size from the default of 256KB to 1MB, which prevents the problem from occuring.

Exploiting @nitayart's Broadpwn bug

posted Jul 16, 2017, 1:27 PM by Zhuowei Zhang

I started a second blog on information security: the first two posts are an analysis of Nitayart's Broadpwn exploit.




Researching how Xamarin Live Player works

posted May 12, 2017, 8:49 PM by Zhuowei Zhang

This week, Microsoft released the new Xamarin Live Player app for iOS and Android, which promises to allow Xamarin/MonoTouch development on a mobile device without cables, a Mac, or setting up Xcode/code signing. So I grabbed it and set out to find out how it works, so that I can use other IDEs for Xamarin Live development.

After starting the Android version of the app, running Netstat revealed a new listening port:

angler:/ $ netstat -l|grep LISTEN
tcp        0      0 0.0.0.0:37847           0.0.0.0:*               LISTEN     

Connecting to that port gives:

$ nc 192.168.1.2 37847
DWP-Handshake


A quick Google search showed that this is the Mono debugger protocol, so after downloading SDP, I was able to attach to the running process:

$ sdb
Welcome to the Mono soft debugger (sdb 1.2.5161.14879)
Type 'help' for a list of commands or 'quit' to exit

(sdb) remote 192.168.1.2 37847
Connecting to '192.168.1.2:37847'...
Inferior process '0' ('192.168.1.2:37847') started


And the Xamarin Live homescreen changed its status to "Connected".

The same port number and attach procedure worked on the iOS version as well.

Unfortunately, SDP does not support breaking on attach, so the debugger just hangs. To make my own loader for Xamarin Live, I'll have to find a debugger library that can break after attach, inject assemblies into the app, and launch them over the debugger protocol.

Researching the Google Trusted Contacts API

posted Dec 7, 2016, 7:31 PM by Zhuowei Zhang

Google released Trusted Contacts yesterday: a new application for sharing your location to friends and family in emergencies. However, it's available for Android only; I'm interested in viewing location on other platforms.

I downloaded an APK from APKMirror and disassembled it with apktool. Then I looked through the disassembled smali.

The application communicates to the server with gRPC at endpoint personalsafety-pa.googleapis.com:443. The requests must be authenticated with an OAuth2 token with scope https://www.googleapis.com/auth/personalsafety . The list of gRPC endpoints can be found at fmx.smali in the disassembled file.

I tried calling the google.internal.geo.personalsafety.v1.PersonalSafetyService/GetUserIncident method using the gRPC Polyglot tool and with an OAuth token obtained from the Google OAuth2 Playground tool; however, I immediately received an error:

PERMISSION_DENIED: Google Personal Safety Private API has not been used in project google.com:oauth-2-playground before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/personalsafety-pa.googleapis.com/overview?project=google.com:oauth-2-playground then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

Unfortunately, since this is a private API (it's right there in the name), I can't enable it from the Developers Console. I guess the next step would be to use GPSOAuth to spoof an Android device to obtain a valid OAuth token. However, unlike a normal OAuth flow, the user would have to provide their password to spoof an Android device, which seems insecure.

Even though I wasn't able to connect to the API yet, I learned how to talk to a gRPC service, which will come in handy when interacting with other Google services.

If you want to try it out yourself, my gRPC Polyglot command line is on GitHub Gist.

Adding a new syscall to Linux 3.10 for ARM64

posted Sep 24, 2016, 11:38 AM by Zhuowei Zhang

Today I learned to add a new syscall to the Linux kernel of my Nexus 6P.

I looked at other guides such as this guide by Shane Tully, but I could not find the syscall table for ARM64 in the kernel. Turns out the syscall table for ARM64 is shared between other architectures, and is located in include/uapi/asm-generic/unistd.h. Yay.

After adding my new syscall to the table, I added a declaration for it in include/linux/syscalls.h so other code can find it, and finally added an implementation for it in kernel/sys.c.

I wanted my syscall to give me root access and to disable SELinux. For root access, I did some research and found that most root exploits uses the pair of calls

commit_creds(prepare_kernel_cred(0));

to gain root, so I used the same. For disabling SELinux, I looked at the existing permissive mode SELinux code in security/selinux/selinuxfs.c and copied it over to my syscall.

Then, I followed the official AOSP instructions to build the kernel. Finally, I used bbootimg to replace the stock kernel with the new Image.gz-dtb file I built.

After rebooting with the new kernel, running the backdoor syscall made the process root and disabled SELinux, as planned. Success!

The patch can be found in this gist.

Summer Reading Report 2016

posted Aug 31, 2016, 9:38 PM by Zhuowei Zhang   [ updated Aug 31, 2016, 10:05 PM ]

One of my goals this summer was to read all the fiction, webcomics, and other works I’ve wanted to read. (I would’ve binge watched Netflix like a normal person, but I forgot my password, and my usual password of 123456 didn’t work). In these works, I’ve identified many shared themes, and enjoyed the different takes on these concepts by different authors in varied settings.

tldr:

Stuff I liked: Song of the Lioness, PrinceLess, the Jacky Faber series, Cucumber Quest, Good Omens, A Brother's Price, Mistborn, Protector of the Small, Un Lun Dun, Wax and Wayne, Tortall and Other Lands, Tunnel in the Sky, Dune, Warbreaker

Stuff I didn't quite like: Nine Princes in Amber, Monstrous Regiment.

(note: each entry is formatted as <title of book with link>: Author: Year Published. For most books on this list I linked to their TVTropes pages since they often have a good synopsis; exceptions are when the work is online only (I just link to their site) or if I don't like the TVTropes summary)

Song of the Lioness: Tamora Pierce, 1983-1988

This quartet for teens distinguishes itself in two areas: first, for a very interesting story structure. The first two books is a standard coming-of-age story about facing your fears and years of hardship to finally achieve a childhood dream. The next two books in the quartet deals with a rarely discussed area: what happens after you accomplish your life’s goal. The moral was that one must develop as a person while chasing a dream, as without mature values and relationships, one would flounder aimlessly after the goal’s reached. (This resonated with me since I achieved my dream of being a programmer at the cost of failing to develop self control, an issue I’m still trying to remedy.) This unusual plot did mean that the pacing and tone in the third and fourth books were quite different from the first two (dark, reflective instead of light and adventurous), but it’s an interesting take on the coming-of-age story.

This series isn’t perfect: it’s the author’s first book, and it shows in the way the main character behaved through the 2nd book: pretty much every action she took was justified by “I don’t know why I did that; I just did.” You’re not allowed to puppet your characters like that! In addition, I didn’t like the implication in one scene from the book: there was a group of legendary enemies that a famous warrior culture couldn’t defeat for over a thousand years - and then two newbie teenagers #yolo’d in and wiped the floor with them on the first try. That’s kinda insulting to the warrior culture’s abilities.

This series is important despite those shortcomings because it’s a proof by construction that fantasy can have prosaic names - if you make sure the author can’t get access to vocabulary other than a book of standard American baby names. Thanks to that boring name book, the main characters have “normal” names like George or Jonathan instead of the impossible to remember Galadriels and Gom Jabbars of other fantasy series.

Overall, despite the issues, the book was exciting, and the main character’s growth interested me. I felt it was worth reading.

PrinceLess (comic): Jeremy Whitley, 2011-present

There are two ways to write a story about the issues facing empowered strong female main characters: examining them in a subtle reflective manner, or confront ‘em head-on in an over the top way. PrinceLess chose the second approach, which fits in very well in the comic book medium. Tongue firmly in cheek, the series pokes fun at fairy tales, stupid armour, and -- yes -- even the phrase “not all men”, in a whimsical fashion that doesn’t distract from the well-written action-filled adventure. I really like it and am waiting excitedly for volume 5.

The Jacky Faber series: L. A. Meyer, 2002-2014

I read through all 12 books of this series because back in elementary school I never got to read all the juvenile adventure novels I wanted. I was very satisfied: the author wrote the series in the style of dime novels, and had fun with the genre. The main character gets into all sorts of crazy adventures, meets all the leaders of the Napoleonic Wars, and runs into random historical in-jokes that were sprinkled in, and there’s no harm to the suspension of disbelief ‘cause that’s the kind of awesomeness you expect in adventure novels.

I found the main character very interesting: like Alanna from Song of the Lioness, Jacky Faber is a girl with strong combat skills in a male dominated society (knights for Alanna, navy/shipping for Jacky), but they approach situations very differently: being raised as a noble with a sense of honour, Alanna solves problems independently with force (see the incident with Ralon in book 1), while Jacky, raised on the streets, prefers using wits and social manipulation to gain friends to solve problems together (in almost all 12 books Jacky befriends a captor to gain freedom - to the point where in one book she’s surprised that this strategy didn’t work). I find the contrast to be interesting: there are many ways to be an awesome adventurer. For a while I wondered what would happen if the two characters swapped places, then realized: if I’m able to imagine this, then both authors must be skilled at writing fleshed-out characters.

Fun fact: the author himself wrote a novel in the series that was never published because it was basically time-traveling fanfiction, taking these characters out of the 1810s and throwing them in the 1960s. I dunno what you’ll call fanfiction written by the original author… (fanfiction, of course; the author’s probably a fan of his own works after all)

Anyways, I enjoyed it - all the books in the series have thrilling plots, but don’t binge on all 12 of them like I did and come out of the coma to find a week has passed.

Cucumber Quest (webcomic): Gigi D.G. 2011-present

A enjoyable and funny story poking fun at adventure games’ tropes. I enjoyed it as I played Wind Waker last year, and could recognize the conventions of the trope being parodied. More importantly, I was fascinated by the character growth and unexpected depth in both the antagonists and protagonists. It’s a heartwarming tale about growing up with witty dialogue and beautiful art, and I recommend it.

Lady of the Shard (short webcomic): Gigi D.G. 2016

I also read a short (less family friendly) comic by the same author, and no, Zhuowei, you’re not allowed to say it’s the best adaptation of Jane Eyre.

Good Omens: Neil Gaiman and Terry Pratchett: 1990

With names like Gaiman and Pratchett on the cover, you know it’ll be funny. Good Omens is a lighthearted take on the Apocalypse in the guise of a coming-of-age story, a romance, and a buddy film, all tied together with a string of witty jokes and hilarious running gags. Unfortunately, I’m not smart enough for this book to make me think, but I laughed a lot, so I recommend it.

Nine Princes in Amber: Roger Zalazny, 1970

I had to read this one since everybody was recommending it: first, Stack Overflow of all places told me to read this series, then Penny Arcade praised it, stating that this series influenced much subsequent fiction.

Well, I picked it up and didn’t like it. I like the framing device of an amnesiac main character, allowing him to find out about the world at the same time as the readers, but I never felt excited or cared about the characters. In this book, traveling to a fantasy realm, marshalling a navy and an army, or getting eyes burnt out had as much excitement as autoreleasing a pointer in the Objective-C Programming Language Guide. (In fairness, Objective-C is interesting, but…) Maybe it was boring because the other characters didn’t show much depth, or because the protagonist never was subjected to character development: as I remember it, he just… did things. I guess being genre defining comes at the cost of making missteps that later books avoid.

A Brother’s Price: Wen Spencer, 2005

I picked this book up because I kept seeing it mentioned on TVTropes: it’s a speculative fantasy novel about a society where males are rare and thus considered the weaker gender. Because of this, it shows up as a genderflipped example in many tropes pages, and so I had to read it to find out what it was about.

After reading it, though, I noticed an unexpected theme in the story: that human nature is constant no matter how society is organized. The story has a very normal plot of coming-of-age and of trust/betrayal despite the changed society. I wonder if the writer’s bad and was too lazy to come up with a plot to take advantage of the strange matriarchy, or if the writer’s very good, and recognized that what makes us human is our love, our devotion, our trust in our families - even our greed and intrigue, and that these human values would be important in any society. Since I enjoyed the book, I’m going to have to say it’s the latter.

Mistborn: Brandon Sanderson, 2006-2008

I first heard about Brandon Sanderson from the podcast he hosts with his friend Howard Tayler, the author of one of my favourite webcomics, so I had high expectations for the series - and it meets it, successfully mixing insightful discussion with cool action scenes. The book covers topics such as the noble/commoner divide, inequality, and the loss of idealism in the face of difficulty (democratic values vs dictatorship), the nature of trust, and the births of religions, but never forgets to show off the well-designed magic system in well-choreographed training and battle scenes. In particular, the author values his religious faith, and (as he noted in his annotations) explores the nature of religious trust and faith through his characters, with each character coming to their own conclusions.

Sanderson also knows how to keep the audience’s attention. Kelsier, one of the main characters in Mistborn, famously stated: “There’s always another secret”, and Sanderson follows this principle in his writing. He would often provide the answer to a mystery before the audience tires of it, but introduce two more unanswered questions to pique the audience’s curiosity again. I found myself binge-reading Mistborn half-a-book at a time to satisfy that curiosity.

Finally, Mistborn contains a variety of interesting characters. Indeed, one character in Mistborn explicitly pointed out a common theme between all the books I enjoyed so far: that magic/weaponry/societal organization isn’t important: human emotions, relationships, and values are the most interesting aspect. Mistborn, of course, takes this lesson to heart, with well-written growth arcs for all the main characters as they learn to trust, to balance idealism and realism, and to take on responsibility. In addition, it shares a theme with Song of the Lioness and PrinceLess: that heroes come in many forms - one can be feminine, idealistic, a scholar, an outcast, or even be corrupted by evil, yet still be a hero in their own way.

Overall, I quite recommend this series: don’t be daunted by the trilogy’s length; the pages will fly by quickly.

Protector of the Small (in progress): Tamora Pierce, 1999

I only read the first book of this quartet, since I wanted to write down my first impressions before picking up the later volumes.

With twenty-five more years of wisdom, Tamora Pierce decided to create a character that’s the anti-Alanna: Keladry is calm, hides her emotion, and fights for everyone instead of just for herself. This last trait is why Keladry becomes the first girl to openly train as a knight, to pave the way for all future girls, unlike Alanna, who only cared that she herself succeeds in her goal. Because of the pressure to represent her gender, Kel has to consider every action politically: for example, wearing a dress to remind everyone that femininity isn’t a weakness, even though she prefers wearing pants. This meant that she is less able to be herself while training as a girl than Alanna was when hiding as a boy, which is very ironic.

Keladry’s challenges reminds me more of gender representation in the modern online age than of Alanna’s story. Her decision to remind others of her femininity echoes the recent #VisibleWomen campaign to remind others of female creators in comics, and the harassment she got for being a girl reminded me of the issues Twitter has with harassment. More worryingly, I believe that a book is usually commentary of society at the time it was written, so if a book character in 1999 encounters more challenges than a character from 1983, what does that say about 16 years of progress in our society?

But wait, it’s not all about challenges and struggles: there’s also SCIENCE! Take a look at this passage from the first book.

“It was[...]so sharp it would slice a hair. Kel knew that because the first thing she did was to pluck one from her head and draw it lightly over the edge.”

Impromptu experiments with your own hair? Wow, that’s dedication to SCIENCE.

My only complaint is that the first book’s pacing isn’t too good: the climax of the book wasn’t spectacular enough compared to the ending of Alanna: the First Adventure. While the third book of the Alanna series was less exciting than the others, that quartet was written as one book and split into four. This series was planned as four books, so there’s no excuse.

Lest the discussion on society scare you away from this book: like the Alanna quartet, this series has plenty of spectacular adventures in a fun fantasy setting, and I can’t wait to read the next 3 books in the series.

Un Lun Dun: China Miévelle, 2007

As before, I picked this one up because of TVTropes: specifically, it was the trope namer for “The Unchosen”. Given this, the book inverts surprisingly few conventions in the “chosen one” tale. It makes up for its average world-saving defeat-the-evil quest with a very imaginative environment containing clever worldplay and fantastic architecture. Oh, and the author managed to get a gun into the climax, even though this book is both a children’s book and a fantasy novel, two genres in which you usually don’t see modern lethal weapons. So there’s at least enough subversion of tradition here, right?

I liked it, though perhaps not as much as the other novels I read this summer, but I will check out the adult sci-fi/fantasy books by the same author when I have time.

Monstrous Regiment: Terry Pratchett, 2003

By now you can probably guess why I picked this book up based on my previous reading choices (girl knight, princess knight, girl sailor… notice a pattern), and I had very high expectations on Pratchett’s take on the topic, due to his reputation as a comedic genius, and because I very much enjoyed the wit of Good Omens. Unfortunately, I did not enjoy this book as much, as it wasn’t filled with humour like Good Omens, and I had already spoiled the plot for myself, not expecting to ever read it. You will like it more than I did if you don’t expect it to be as whimsical as Good Omens, and if you don’t open up every spoiler on its TVTropes page before finally reading it.

Wax and Wayne: Brandon Sanderson, 2011-2016

As I mentioned before, I heard of Sanderson from Howard Tayler: both creators explores themes more sophisticated than expected of their genre of choice. Howard Tayler brought into his gag-a-day space opera comic discussions on immortality, military ethics, the morality of a godlike being, and the consequences of one’s actions. Meanwhile, Sanderson, in Wax and Wayne, added to a detective/crimefighting novel the Mistborn themes of trust, duality of one’s personality, responsibility, faith, and free will. This worked very well: indeed, after the obligatory ending foreshadow occurs halfway in the first book, I thought that there’s no way that the foreshadowed thing could be used in the ending - but I had forgotten that the book’s not a normal detective/crime story, and was pleasantly surprised when the ending unfolded exactly as hinted according to the themes of Mistborn.

As with any story, this series provides a variety of characters: I’m jealous of Wayne’s comedic abilities. Moreover, I was very impressed when the author revealed that some characters have much more depth than the reader’s first impression would suggest.

I wasn’t expecting the sequel series to be as enjoyable due to the genre and settings change, but this series tackles the same topics as Mistborn, so I found myself praising this series as a worthy followup to the original Mistborn trilogy.

The Immortals: Tamora Pierce, 1992-1996

You can tell Tamora Pierce got plenty of books on exotic names and linguistics after the success of Song of the Lioness: the main character is named Veralidaine Sarrasri! The names were so fancy in this book that even the author screwed up a character’s name.

It’s not just names that I want to grumble on: I don’t like how cameos are handled in this series. As I mentioned before, characters are the most interesting part of a story, and I’m starting to think the most interesting part of a character is their growth, Old characters already went through their growth arc, so they’re not very interesting anymore; plus, legacy characters often become caricatures of themselves because there’s no space to establish their full personality again, so Alanna, for example, goes from subtly headstrong to exaggeratedly angry in this new series. Given these limitations, I think giving the protagonists from Song of the Lioness significant screentime as secondary characters was a mistake. The Wax and Wayne series and the author’s subsequent Protector of the Small series both handled cameos better: they placed the characters as legends with very small roles, thus adding background flavour without compromising the main story.

I’m also disappointed at Pierce’s reluctance to delve into deeper topics: the Wax and Wayne series’s plot discusses free will by showing characters question the control their deity (or even their ideals) has on the character’s own actions, and then taking steps to gain control over oneself. This drives the entire conflict in the first two Wax and Wayne books, yet when Daine encountered the same issue in this series, she decides in a single paragraph that fighting divinity is futile, and no more is said on the topic. Similarly, in the original Mistborn trilogy, the separation of the noble and worker class is a core part of their society, and the main characters deliver their most powerful lines when they confronted their role in supporting the system they’re rebelling against. However, when Daine the commoner meets nobles, she’s only impressed by their benevolence towards commoners like herself, and doesn’t give any more consideration to this societal division.

Not delving too deep into a topic can also be a boon: in one scene in the book, to master a magic spell, Daine must remember and visualize her own identity. I was expecting some sort of arc of self-discovery as Daine tries to define herself in the turbulent teenage years… but nope. Her mentor taps her on the shoulder, and the spell starts working. I’ve never seen a book Keep It Simple before, but I like it.

Despite all my criticisms on the series, I enjoyed it a lot. Indeed, this sequel series has more worldbuilding and introduces many new magic creatures, each with their own beliefs and values. The author has learned to pace a quartet: unlike the Alanna series, all four books were exciting. If one liked the Alanna series, one would find this series a solid follow-up.

Tortall and Other Lands: A Collection of Tales: Tamora Pierce, 2011

This collection of short stories shows Pierce has matured as an author since the Daine quartet: these stories cover a wide selection of topics, from peer pressure to trust, innocence, and even the Protestant Reformation (one story was about teaching everyone to read the holy texts of their religion - sounds familiar?) In addition, the collection provides two stories as point and counterpoint for saving oneself versus fighting for your entire group’s rights, paralleling the contrast between Alanna and Keladry’s stories.

But I’m guessing you’re just here for that one story with the tree, like I was! Well, after I found the rest of the stories to be just as enjoyable, I’m recommend it for those who liked Pierce’s other works.

Tunnel in the Sky: Robert Heinlein, 1955

Tunnel in the Sky is basically the anti-Lord of the Flies - the similarity in the setup was significant enough that the foreword had to point out that it’s not a ripoff: the two books were published weeks apart. Like Lord of the Flies, rules and order were important to the group as they try to stay civilized, but unlike that book, the usurper of power was also working to make the society better, and eventually changed his ideals to suit their situation, giving back some power to the original leader. This willingness to adapt reminded me of the second book of Mistborn, and I found it interesting that Mistborn, Tunnel in the Sky, and even Protector of the Small is linked by the common theme of politics.

If you do read it (and I found it worth the time), don’t forget to read the foreword, which pointed out two well-hidden secrets by Heinlein that I missed (as he intended).

Dune (in progress): Frank Herbert, 1965

Dune is another early landmark in the science fiction/fantasy genre: unlike a Sanderson novel, its pacing is slow, but unlike Nine Princes in Amber, it’s engaging, with mysteries and action complementing a troubled coming of age story on a well-thought out world. This book made me care about the characters, which Amber never did. Plus, this book also touches on the themes of religious saviours that Mistborn covered, but from a different angle (Paul’s goal is very unlike Kelsier’s).

I mentioned before that all books reflect the society of the time when it was written. There’s an addictive spice in Dune that opens the mind: does this remind you of any stereotypes of the ‘60s?

Anyways, I’m not sure why this is such a bestseller: it’s a good story of political intrigue and survival, and the worldbuilding is very well done, but I was expecting something mind-blowing from the best selling SF story of all time. I haven’t finished it yet, so maybe the last third will be unexpectedly amazing. Still, I like it, and it’s well worth a read if you need something slower-paced.

Warbreaker: Brandon Sanderson, 2009

I was surprised after reading the author annotations for Warbreaker that Sanderson intended this series to be the anti-Mistborn. I’m not sure if I agree: for example, in the matters of religion, one person questions faith but ultimately affirms it, like Mistborn, and another believer loses belief due to events and eventually comes to terms again with the religion - also explored in Mistborn. Still, similar doesn’t mean stale. I don’t like this book’s magic system as much as the ones in Mistborn as these are harder to understand intuitively (colors/commands/abilities versus pushing and pulling), but I do like the questionable moral implications of its use, which none of the systems in Mistborn had. In Mistborn, one system was clearly Good, one system was Neutral, and one system was Evil: no arguments needed. Due to how magic is fuelled in Warbreaker’s world, Sanderson was able to have in-world discussion about whether practicing this magic is inherently immoral.

I was also interested in this book for its interesting publishing history: the book was published in 2009, in the early days of eBooks, and Sanderson conducted an experiment with this book to test this new medium: he posted chapters online for free as he completed them in exchange for proofreading and critiques from readers: the book’s quite polished, and I was reading a library copy, not the free online one, so I guess crowdsourcing works.

I recommend this book: despite the less spectacular magic system, this is still a Sanderson book with the usual themes of self-discovery, faith, and responsibility, and it was interesting enough that I finished reading this instead of Dune, which I wanted to read first so I can write its review. Ah well.

There’s just one problem with this book though: I ranted about the strange names in fantasy, and I can’t believe Sanderson named a main character with the most obscure name ever: “Siri”! I mean, have you ever heard of this name? Does he expect anyone to be able to pronounce it? It’s so unusual! (Well, this did come out before 2011 and the iPhone 4S.)

Summary

In summary, though the worlds in these books cover different time periods and different lands, I can see that character growth and understanding others is just as important aboard a ship, in a noble’s keep, or in the training yard for pages and squires. I’ve quite enjoyed the books I’ve read; in the future, I’ll maybe try to broaden my selection to other genres and probably more non-fiction.

If there’s any comments/interpretations/corrections, please reply them to my Twitter account. Enjoy reading.

ps: I learned that writing blog posts is hard. I now have more respect for people like Talen who can post long well-researched opinions every month. I guess I need more practice writing posts: so expect more reviews in the future.

How Telerik NativeScript's LiveSync works

posted Aug 16, 2016, 6:34 PM by Zhuowei Zhang

- Developer scans QR code
- QR code encodes the LiveSync download address: e.g.  nativescript://http%3A%2F%2F192.168.1.10?LiveSyncToken=asdf
- a web connection is made to the address specified in the LiveSync address: e.g. for the above, it's  "GET /Mist/MobilePackage/files/iOS?token=asdf&configuration=%20 HTTP/1.1"
- this endpoint returns a .zip
- this .zip is extracted
- NativeScript restarts by calling Telerik Companion then quitting itself; companion invokes NativeScript again through openURL
- when NativeScript restarts, the app.js from the .zip is loaded and run

So with a bit of work, you can use NativeScript's LiveSync to develop NativeScript applications without the Telerik SDK by serving the .zip file at the correct location.

Nintendo NX Theory: The Only Game Console That Won't Use Electricity?

posted Apr 10, 2016, 9:30 PM by Zhuowei Zhang

I'm very excited by the Nintendo NX, but I'm saddened by the lack of rumours, speculations, and hype. I believe that the truth of the Nintendo NX's out there, and once you pick up the hints, it becomes obvious.

We know that consumers of Nintendo's traditional casual games are increasingly choosing smartphone games instead, and that Nintendo will have to differentiate their future console offerings to offer a unique experience compared to smartphones and tablets. So one obvious way to improve from power-hungry smartphones is to create a gaming device without batteries or wires, and that allows limitless play without worrying about charge.

The president of Nintendo, Tatsumi Kimishima, noted in a recent Time interview that Nintendo wants people to encounter their IP more frequently, citing his desire to "increase the population of those people who have access to our IP". Currently, electricity supplies in Sub-Saharan Africa is decreasing due to population growth faster than infrastructure development, so a game device that does not use electricity will be able to capture an audience that could not interact with Nintendo's IP in the usual way. This is the same approach taken by the Wii and DS - both amazing successes for Nintendo. Those consoles targetted people who would "otherwise not come into contact with a form of entertainment like gaming" by using novel motion controls and casual games; the NX can do the same by allowing people who can't even turn on a light or charge a phone to become gamers.

So how would a device without power operate? Recent Nintendo rebranding efforts - replacing the gray Nintendo logo with the traditional red-and-white - signals that Nintendo wants to go back to its roots. Nintendo was founded as a Hanafuda playing cards company, and its first success in toys came in the form of the Ultra Hand, a simple mechanical toy that sold a million units. This suggests that Nintendo's new console will be suitably retro and use the technologies that made Nintendo what it is today - cards and ingenious mechanical contraptions.

But how would Nintendo IP integrate with mechanisms and cards? In the same Time interview, Kimishima notes that "Amiibo are being picked up more as a collection item than, say, as an interactive item with software", and promises new ways to interact with Amiibos to "enhance the play activity". This strongly hints that the new console will offer novel ways to engage the Amiibo in the play experience. As we noted before, the new console's roots in cards and mechanical toys is perfectly suited to Amiibo - Nintendo already has Amiibo cards and devices that hold Amiibo! Thus, the electricity-free console will use Amiibo directly in games, removing the barrier between the virtual world and the real one.

So what types of games can we expect on the electricity-free Nintendo NX?

- Super Mario Maker

This continues the idea of asymmetric multiplayer first introduced on the Wii U: one player draws a square grid, and adds pipes that connects squares together. Other players roll dice to see how many places to advance their Mario, Luigi, Toad, or Peach Amiibo; if they land on a square with a pipe, they travel through the pipe to the connected square. The first player to reach the last square wins. Online play is accomplished by sharing your best grid layouts on Miiverse.

- Super Smash Bros

Each player chooses their Amiibo, place it on a spinning top, and launch it into a stage (a concave bowl) where each Amiibo's top will bump against the other Amiibos. Knocking a top over counts as taking a stock. Testers found that the Fox Amiibo, due to its even weight distribution, is currently the most suitable for this game, but that Nintendo is considering balance changes and patches in the form of small lead stickers that can be applied to Amiibos to make them harder to knock over, and polishing cloth to buff your Amiibos. According to an industry insider, many stages will be produced with a novel feature where the bowl can be replaced with a flat surface for an Omega version of the stage.

- Hearthstone

Yes, that's right: there's unprecidented third-party support at launch. A source at Blizzard confirms that the Activation-owned studio behind the blockbuster World of Warcraft and Hearthstone franchises will launch an iteration of Hearthstone for the NX. The gameplay will consist of drawing cards, each with an action such as "open the Hearthstone app", "tap the Buy Card Pack button", and "Get hit with an unexpected IAP bill". Blizzard is confident that this is the first card game faithfully reproducing the experience of a mobile app faithfully reproducing the experience of a card game.

- Splatoon

A leaked version of Splatoon for NX was found in Korea. Sources do not confirm whether it's in the best Korea.

- Zelda NX

Each player will try to guess the release date of Zelda NX. The fun comes from watching another Nintendo Direct and finding that it's delayed again.

Thus, it's plainly obvious that an electricity free console will return Nintendo to its roots as a cards and mechanical toys maker, introduce new demographics to gaming, and integrate Amiibos as a core part of the game experience. All signs point to Nintendo successfully bringing this concept to market, and even third-parties are pledging support. Because, really: the most powerful gaming device... is you.

tldr: No electricity needed for NX. Your imagination is the only limit.

tldrtldr: literally this

New location of last_kmsg on Android 6.0 and above: /sys/fs/pstore/console-ramoops

posted Dec 26, 2015, 12:47 PM by Zhuowei Zhang   [ updated Dec 26, 2015, 12:47 PM ]

On Android, diagnosing kernel crashes often requires a developer to read the /proc/last_kmsg file, which stores previous kernel logs after a reboot. Unfortunately it went missing in Android 6.0.

It turns out that it was moved to /sys/fs/pstore/console-ramoops . It still works the same way as before (cat /sys/fs/pstore/console-ramoops will display the previous kernel log)

Restore Nandroid backup as secondary ROM in MultiROM

posted Nov 24, 2015, 11:06 PM by Zhuowei Zhang

Because a lot of people couldn't find it:

Boot into Multirom TWRP Recovery

Select Advanced -> MultiROM -> Add ROM -> (set ROM type to Android) -> Next -> Backup

1-10 of 97