How to fix Nexus 9 stuck at Google logo

I have a Nexus 9 tablet I bought a few years ago. One day a software update caused the tablet to become unusable. It was stuck in a loop showing the Google logo and restarting. I few weeks ago I was able to revive it after searching various posts on the Web.

  1. Install ADB. I have a Mac, so I used Homebrew to install this tool:brew cask install android-platform-tools
  2. Hold down Volume Down + Power Button. This gets you into HBOOT. It can be tricky to accomplish.
  3. Press Volume Down to highlight Recovery, then press the Power Button to enter it.
  4. Wait until the Google logo goes away, and you should see a picture of an Android laying on it’s back. Hold down the Power Button + Volume Up (very important to hold Power FIRST).
  5. On the Recovery page it lists a few details about your version at the top. Note down the 6 character identifier for your device (which is in the format of 3 text characters, 2 numeric, and another text char). My identifier was n4f26q.
  6. Go to https://developers.google.com/android/ota and find the OTA image that contains the identifier. Download the image.
  7. On your device use Volume down to get to “Wipe Cache Partition”, and press the Power Button to activate it. This takes a long time.
  8. Plug your tablet into your Mac.
  9. On your device, use Volume up button to go to “Apply update from ADB”, and press the Power Button to enter it.
  10. On tour Mac, type adb sideload <file-downloaded-in-step-5>.  
  11. Wait. Mine took about 40 minutes.

The bulk of the above instructions came from https://forum.xda-developers.com/nexus-9/help/failed-marshmallow-update-stock-android-t3226704.

Testing legacy Perl code – part 2

When Perl loads a module, it looks for the module in the subdirectories listed in the special Perl variable @INC. The first module it finds, it uses. Using this knowledge, a programmer can craft his own implementation of a module to substitute for the real module. In a test, the @INC can be manipulated by setting the environment variable PERL5LIB or by using the -I parameter when using prove.

jeffs-mbp:aws-npk jeff$ perl -V
Summary of my perl5 (revision 5 version 30 subversion 0) configuration:
...
  @INC:
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/site_perl/5.30.0/darwin-2level
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/site_perl/5.30.0
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/5.30.0/darwin-2level
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/5.30.0

jeffs-mbp:aws-npk jeff$ PERL5LIB=$PWD/lib perl -V
...
  @INC:
    /Users/jeff/projects/aws-npk/lib
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/site_perl/5.30.0/darwin-2level
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/site_perl/5.30.0
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/5.30.0/darwin-2level
    /Users/jeff/perl5/perlbrew/perls/perl-5.30.0-mojo/lib/5.30.0

By setting PERL5LIB to $PWD/lib, any modules found in the directory /Users/jeff/projects/aws-npk/lib will be used before any other modules.

Overriding a module that has lots of methods would be tedious and probably error prone. Perl has a solution for that, called AUTOLOAD. If a module has this method, then Perl will call it when a method does not exist in the module. Here is my implementation of DBD::mysql using this feature:

package DBD::mysql;

use Data::Dumper;
use strict;

sub new {
    my $class = shift;
    my %args = @_;

    return bless { LOG     => undef,
                   VERSION => "test DBD::mysql 1.0", 
                   %args}, $class;
}

sub display {
    my $self = shift;
    my $function = shift;
    my $content = shift;

    push(@{$self->{LOG}}, "$function: $content");

    if($self->{debug} == 1) {
        print("# $function:\n", "# $content\n");
    }
}

sub prepare {
    my $self = shift;
    my @args = @_;

    $self->display(Dumper(\@args));
    return $self;
}

sub fetchrow_arrayref {
    my $self = shift;
    my @args = @_;

    $self->display(Dumper(\@args));
    return [];
}

sub AUTOLOAD {
    my $self = shift;
    my @args = @_;

    our $AUTOLOAD;

    $self->display($AUTOLOAD, "@args");
}

1;

This module only defines two methods that are part of DBI::DBD, prepare and fetchrow_arrayref. Some code may require more to be defined, but in this case, the program I was testing only needed these two. prepare needed to return a reference to the object itself, because prepare normally returns a statement handle object, but Perl does not care as long as the object has the needed methods that are called upon it. fetchrow_arrayref returns an empty reference. All other methods are handled by the AUTOLOAD function. Most of the methods call the display function, which prints out the method and its arguments if the object was initialized with debug = 1.