All posts in Development

This tutorial – especially Step 3 – has changed considerably. Please work through it carefully and report any issues to me immediately so I can help others.

We are rooting the Shield Android TV (2017; 16GB SKU) running Android 8.0 (aka Oreo) on v7.2.2. Note: This uses a special patched bootloader and will not work in future updates. You’ll need to apply FULL OTA upgrades to restore the bootloader, then repeat this tutorial with the proper version bootloader.  Looking for the Shield TV (2015; 16GB SKU) tutorial?  Click here.  Looking for the 500GB SKU tutorial?  Click here.

Step 1: Pre-Requisites and Warnings

Download the following items – Make sure you get the RIGHT patched bootloader for your Shield TV version:

Ensure you have the following items:

  • USB Mouse – optional
  • Shield Controller with USB Cable
  • Male to Male USB 3.0 Cable (Amazon; verified working) or possibly this gender change from Monoprice (if anyone tries it, please let us know success or failure)  Note: Many users have reported a USB 2.0 cable may work.  It probably depends on the cable quality, etc.

There is a chance you may need a USB hub to complete this tutorial. If you do not have one on hand, here is one from Amazon that is one day Prime shipping and should do the trick. Probably should have this on-hand before starting – just in case.  Take a look around your desk; many monitors have USB hubs built in.  Many keyboards act as a USB hub.If for some reason you have to pull the Male to Male Cable during the Fastboot process, you may avoid using a USB hub IF you haven’t used Adoptive Storage.

Data Destruction Notice

Unlocking the bootloader will ERASE EVERYTHING internally (not on your external SD card if present; adopted storage users may want to make a backup of their SD card contents).  Make sure you have everything saved off and backed up.  You’ll have to resign into Google – so if you use two-step authentication, be sure to have your Google Authenticator app ready.

The process of rooting will not destroy any data.You will need to be able to see your PC AND the Shield TV’s HDMI out in order to perform this.  I used one monitor with two inputs and flipped back and forth as needed.TWRP doesn’t currently work on 4k displays!  Use a 1080p display to complete this tutorial.

Step 2: Preparation

  1. Install Minimal ADB and Fastboot (if you do not already have it installed).
  2. Ensure the Shield Family drivers are extracted somewhere on your system and you know where they are.
  3. Make sure you know how to get to Device Manager on your PC.
  4. Extract TWRP Recovery image from the ZIP file (and do yourself a favor and rename it to something easy like twrprecovery.img). Put this in your Minimal ADB and Fastboot folder (usually c:program files(x86)Minimal ADB and Fastboot).
  5. Copy supersu.zip (it may be named differently; you downloaded it above) into your Minimal ADB and Fastboot folder. Do not extract it.
  6. Plug your Shield TV into the PC with a Male to Male USB 3.0 Cable (Amazon; verified working).Note: Not all USB cables are created equally!  The linked cable above we have verified works.  Not all USB ports are the same.  Some on the back of the PC may work better than those on the front.  Use a USB 3.0 port (you can tell if it is blue inside) – that is what we used.  USB 2.0 may work but that is untested.
  7. Plug your Shield Controller into the USB port right next to the HDMI cable.  The other port will NOT work.  Note: If your bootloader is unlocked already, you don’t need to do this.
  8. Confirm drivers for ADB are installed:
    1. On your PC, go to Device Manager.  Find the yellow (!) ADB device (depending on your version of Windows, it may read differently).  If none exist, you probably already have drivers.  Skip to step 9.
    2. Right click the device and select Update Driver.
    3. When offered, browse your computer for the driver and point it to the Shield Family Drivers folder you extracted in Preparation Step 2 above.
    4. When finished with the driver install, the (!) yellow device should be gone.
  9. Enable Developer mode on Shield TV
    1. On the Shield TV, go to Settings->About->Build (click 7 times on BUILD to unlock developer mode)
  10. Enable USB Debugging on Shield TV
    1. Settings -> Developer -> Debugging; set to On
    2. A popup should appear asking for this PC’s authorization.  Check the Don’t ask again for this PC box and select Allow.  If it doesn’t show up now, it will later.
  11. Enable PC connection to Shield TV
    1. Go to Settings -> Storage & reset
    2. Under SHIELD storage access, turn on Using USB

Step 3: Root Procedure

  1. Install Magisk Manager and Sideload Launcher
    1. Make sure you have the Magisk Manager apk (Magisk-Manager700.apk or whatever you named it when you downloaded it above) in your Minimal ADB and Fastboot folder.
    2. Make sure you have the Sideload Launcher apk (sideload-launcher-android-tv.apk or whatever you named it when you downloaded it above) in your Minimal ADB and Fastboot folder.
    3. Launch Minimal ADB and Fastboot from the Start Menu or icon.  This puts you in a black DOS box.
    4. Type “adb devices” and make sure your Shield TV appears.  Note: If you didn’t have a popup on your screen in Step 10.2 above, it probably will appear now.  You’ll have to authorize the PC before it will show up under adb devices.
    5. Type “adb install magisk-manager700.apk” (or whatever you named it) and hit enter. You will get a success message in the DOS box window.
    6. Type “adb install sideload-launcher-android-tv.apk” (or whatever you named it) and hit enter. You will get a success message in the DOS box window. If you already have Sideload Launcher previously installed, this won’t work – nor is this step necessary.
  2. Reboot into Bootloader on Shield TV
    1. Type “adb reboot bootloader” and hit enter.  The Shield TV should reboot into the bootloader screen.   Note: This can take several seconds on a black screen.  Bootloader won’t show on a 4K display.  Use a 1080p display.
    2. If you are sure Fastboot drivers work and you do not need to unlock the bootloader, jump to Step 9.
  3. Verify Fastboot Drivers are installedNote: If Windows complains about the USB port (Driver Descriptor, etc.) under Universal Serial Bus Controllers and your device doesn’t show up with “fastboot devices” – change ports.  I’ve NEVER seen this happen before now.  Switching USB ports solved the issue.
    1. On your PC, go to Device Manager.
    2. See if a yellow (!) exists that mentions FASTBOOT.  If not, continue to Step 4 to unlock bootloader.
    3. Right click the device and select Update Driver.
    4. When offered, browse your computer for the driver and point it to the Shield Family Drivers folder you extracted in Preparation Step 2 above.
    5. When finished with the driver install, the (!) yellow device should be gone.
    6. Type “fastboot devices” and make sure your Shield TV is visible.
  4. Unlock Bootloader (skip if you already unlocked your bootloader)
    1. Type in “fastboot oem unlock” and hit enter.  EVERYTHING ON THE SHIELD TV WILL BE LOST (other than portable storage)
    2. You will see a prompt on the screen.
    3. Confirm to unlock the bootloader by pressing A on the Shield Controller. Do not be impatient!  Let it finish.
  5. Reboot to Shield TV Interface
    1. Once the bootloader is unlocked, reboot the Shield TV (unplug/plug in) and return to the Shield TV main interface (you will have to go through setup again).
  6. Repeat Preparation: Steps 9 and 10 above to re-enable Developer/USB Debugging.  Note: at some point you will have to re-authorize your PC again; if an ADB command fails, be sure to look at your screen for the authorization prompt.
  7. Unplug the Shield Controller and plug your mouse into the same port.From this point forward you will receive a warning screen on boot, saying that the software cannot be checked for corruption.  You can ignore this; it will boot the system in 5-10 seconds.
  8. Reboot to Bootloader
    1. Type “adb reboot bootloader” and hit enter. The Shield TV should reboot into the bootloader screen.
  9. Install the Magisk Patched Bootloader
    1. Type “fastboot devices” and make sure your Shield TV is visible.
    2. If your Shield TV is listed, type “fastboot flash boot patched_boot_722.img” (or whatever you named it) and hit enter.
    3. Type: “fastboot reboot” and hit enter. Your Shield TV will reboot into the operating system.
  10. Run and update Magisk
    1. Navigate to your Apps on the Shield TV and run Sideload Launcher.
    2. Look for the Magisk Manger app (looks like an Anonymous mask of multi-colors) and run it.
    3. If all is well, you should see that Magisk and Magisk Manager are both installed and up to date. If Magisk doesn’t show installed, you may need to repeat this block of instructions.
    4. Update Magisk and the Manager if prompted to do so.
    5. Exit Magisk Manager
  11. You are now rooted!  Test your root apps now.
  12. Optional: If you want to be able to take OTA versions in the future (you’ll lose root), then go to Settings, Developer options, scroll to the very bottom and turn on Provide full system upgrades.

If Something Goes Wrong

First, don’t panic.  It is pretty hard to permanently “brick” the Shield Android TV just by trying to root it.

No matter what may go wrong, flashing a stock image should put you back in working order.

Follow our tutorial: Tutorial: Restore to Stock Image (Shield TV)

Obviously if your Shield Android TV is stuck in an infinite boot – you cannot reboot to Fastboot from your PC.  You have to do it the “hardware way”.

  1. Unplug your power cable
  2. Plug in your New Shield game controller with the included USB cable into the USB port closest to the HDMI cable
  3. Hold down buttons A & B.
  4. While holding down the two buttons, plug in your power cable (Keep holding down the buttons)
  5. If all went well, the Fastboot menu will show up.

Changelog and Credits

This process originally comes from this XDA thread.  I take no credit for the act; all I’m doing is documenting an easy way to do it.  This tutorial assumes you are running a Shield TV (2017; 16GB) and you have the OTA installed that upgrades you to Oreo.

  • 2019-03-13: Added a patched 7.2.3 bootloader. Make some changes to reflect turning on FULL OTA updates.
  • 2019-03-09: The root process now uses Magisk instead of SuperSU. Tutorial updated to reflect changes.

How to invoke the Android “Fastboot” Menu on SHIELD TV

Answer ID 4359 Updated 03/23/2018 03:10 PM

HOW TO INVOKE THE ANDROID “FASTBOOT” MENU ON SHIELD TV


The new SHIELD TV (16GB):

If you own a SHIELD Controller

  • Unplug SHIELD TV.
  • Connect SHIELD controller to SHIELD TV with a USB cable (use port closest to HDMI).
  • While holding the A and B buttons at the same time, connect power to SHIELD TV.  

If you do not own a SHIELD controller 

  • Unplug SHIELD TV.
  • Connect a USB keyboard directly to SHIELD TV (use port closest to HDMI)
  • While holding the “A” and “B” keys down at the same time, connect power to SHIELD TV.
  • Once you enter Fast Boot mode, on the keyboard use the “X” and “Y” keys to navigate the menu and “A” to select 
     

SHIELD TV Pro or SHIELD TV (2015)

  • Unplug SHIELD TV.
  • Connect a Micro USB cable from the Micro USB port on SATV to a PC.
  • Connect power back to SHIELD TV.
  • Wait 2 seconds, and then hold the NVIDIA power button on SHIELD TV for 5-6s until you see the fastboot menu on the display.

Although, having migrated to .net Core for the most part,we all have to support our older applications using .net Framework. As a part of routine, you may tend to update the .net framework in your application only to find out that your test or even prod (yikes!) do not have the latest framework installed. 

One way to find the version is using microsoft’s documentation here:

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

You, look at the complexity, and may just give up. I’ve found an easier place to check the same. And it positively has worked for me every time.

All you need is to browse to a folder path:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework

Here’s the structure:

And That’s it. You will see all the framework’s installed on this machine, even a minor version has a different folder as well. Easy on the eye indeed.

When you create and restore a TWRP backup (as example because you tried out a custom ROM and saw that it’s not good) you’ll be greeted with:

a) A “enter PIN before boot” screen
b) A wrong lockscreen code (either PIN or Pattern) when booted to Android

————————
HOW TO FIX
————————

  1. Simply boot into TWRP and enter your PIN (if you’ve set one) to decrypt the stroage. If you don’t have TWRP (for whatever reason) you can do so via ADB too but ONLY if you’ve connected your phone to your PC beforehand and also accepted it’s fingerprint on the phone itself.
  2. Delete (or rename) the following files inside /data/system (note that probably not all of them exist for you, simply delete those you can find):
    • password.key
    • pattern.key
    • locksettings.db-wal
    • locksettings.db-shm
    • locksettings.db
  3. Reboot the phone and (if you’ve set a PIN) enter it to decrypt the storage one more time. After that you can simply unlock your phone with a swipe.
  4. Go into Settings > Security and set your preferred unlock method again, Android will ask you if you want to set a boot-time code too. Select whatever you want here, it’s a nice security addition but can be annoying sometimes.
  5. Enjoy your phone again!

I hope this helps some people here since I was searching on how to fix this for almost an hour after restoring a backup. This is probably due to another ROM overwriting existing lockdata when you set a code there, then again you’d wipe the /data partition anyways so I have no clue why it’s still acting up like this…

Imagine you have a set of microservices or applications that you want to publish to the world. There are several alternatives out there that you can choose from. Most of the reverse proxies were created when container technology was not around, so you have to jump through some loops to get going. As a broadly used example we will have a peek at how to configure nginx and some of its downsides. To get our hands dirty, we will have a more detailed walk-through of the modern, dynamic Traefik reverse proxy which we will use to deploy some services.

Best in class before Docker: Nginx

There is quite a number of container deployments out there that use nginx as a front end. The configuration is easy to read and write and the C style syntax gives you a cozy feeling. A simple config to deploy a service might look like this:

With this config we created a simple HTTP reverse proxy on port 80. Nginx will answer the requests by forwarding these to the upstream servers. The container with the least number of active connections will be chosen from the pool. Nice configuration. Plain and easy to read.

One thing you will encounter when you deploy nginx in a mutable container enviroment is that you can’t replace containers without at least reloading the nginx configuration although the container DNS name is still the same. Nginx will cache the IP address to the container and you have to manually take care of it. You can work around this problem in many ways but still you have to take care of it.

Don’t get me wrong: I don’t want to pick on nginx. I like it and used it a lot before I switched to Traefik as my go to solution.

Traefik

There’s a more modern reverse proxy around that is able to handle dynamic container environments: Traefik. It is a small application written in GO tailored to the new challenges. You can use it as a frontend in a variety of environments. The simpler ones are Docker and Docker Swarm, the more complex ones are Apache Mesos or Kubernetes. You can even read metadata from directory services like etcdor Consul.

Back to our application we want to deploy. Let’s imagine we have a set of services that are described in a Docker Compose file. We can wire up our services and deploy these. Here we can have a look at a simple configuration:

This configuration will start the whoami test image that will allow us to see our requests in a kind of echo chamber. You can start it with docker-compose up and call it with your browser. How can we deploy it on a specific virtual host? Let’s extend the configuration a bit by adding Docker labels.

This is the configuration needed for Traefik to deploy our service at http://whoami.server.test . Pretty straightforward.

When you followed the example closely you might ask where Traefik is involved and you are right. Next we need to spin Traefik itself up:

The config above takes care of starting Traefik and will connect to the hosting Docker daemon to retrieve the needed metadata. It will scan for Docker containers that are marked with labels and will publish the services accordingly. The connection is kept so that changes will be reflected without any delay.

Both services are wired together using a Docker network called call webgateway that is prefixed by the project name. If no project name is specified, the name is inferred from the directory name where the compose file is located.

You can find more configuration options on the documentation site: https://docs.traefik.io/toml/#docker-backend. This takes you straight to a backend configuration part. Below that there is a list of Docker labels that can be used to further configure the publishing of the services. Currently we just used traefik.backend and traefik.frontend.rule in the sample above but you can find more.

Once Traefik and the service are up you can connect to the service and test the deployment. Make sure you first start Traefik in this example because the config provides the network the services can connect to.

Have a look at the built in dashboard by pointing your browser to: http://localhost:8080/

Here you can see what services are deployed and how these are configured. You see that our service is available as whoami.server.test. But since we don’t have a DNS record pointing from this name to our localhost, we need to manually set the Host header and call the localhost.

Once you have entered the command, you can see the request that is being sent to Traefik and the response that will be returned. The result will look similar to:

DNS

To fully enjoy the power of Traefik, you need to take care of the DNS records of your deployments. But this is a one time setup, so don’t worry about it too much. One deployment we run at a customer consists of two DNS records per host. One is an A record pointing to the IP Address of the host. And the other is a CNAME record that catches all virtual hosts below this one and forwards it to the A entry. This is a simple way to locate our services.

Just a little example to show you the setup:

This will allow us to reach our server as server.test and whatever.server.test, youwant.server.test. When you access the site with your favorite tool like a REST service, httpie or a browser, the client will forward the target host in an HTTP header called Host. Traefik will find the right container based on this header to forward the request to.

One advantage of using virtual hosts is that you don’t need to take extra care of redirects in your web application. We ran into problems when using relative paths for deployments because nobody thought about that being an option. Once you have your environment set up, you can deploy the services as you like.

Scaling out

Deploying a single container is easy and we could achieve it without any great effort. But what about scaling out? What part of the config do I have to change? The simple answer is: You don’t have to change your config. Just spin up more containers and that’s it. In our simple example:

This command will spin up four containers that will get added to the load balancer instantly. You can verify it by hitting the endpoint repeatedly and see the container name change and by having a look at the dashboard that is located on port 8080.

Sticky Sessions

Clearly I would strive for a stateless application backend that can be scaled independently and without any restrictions regarding the service endpoint.

Sometimes you don’t have the freedom because you are running a session-based application that doesn’t distribute the sessions in a cluster of servers. Or – if you think more of REST services – you heavily use caching of resources and you want your sessions pinned to a specific container. No matter why you want your clients to be pinned to a specific Docker container, there is an easy configuration switch to handle it:

This will check for a session cookie with a specific backend as a value. If the cookie is present and the backend is up, the request will be forwarded there. If the backend is down, another is chosen.

Be sure to use the upcoming 1.4 version for this feature or my patched Docker image (marcopaga/traefik:1.3.5.2) if you want to use this feature. Before these versions, the cookie path wasn’t specified so that clients tended to drop the cookie once in a while depending on the request path.

Post originally appeared at:

https://visualstudiomagazine.com/articles/2017/09/06/free-xamarin-book.aspx?m=1

 

Microsoft has been publishing a series of free eBooks and accompanying blog posts providing guidance about .NET application architecture best practices, with the latest focusing on Xamarin.Forms patterns.

Previous guidance addressed microservices architecture, containerized Docker apps and modern Web apps with ASP.NET and Microsoft Azure. The guidance consists of detailed eBooks, end-to-end reference architecture applications used as examples and blog posts that can help developers get a gist of the guidance and decide if they want to dig deeper with an eBook and reference application.

The new guide, “Enterprise Application Patterns Using Xamarin.Forms,” includes source code for a container-based eShop that extends the previous microservice/containers scenario. It includes the following functionality:

  • Authenticating and authorizing with a back-end service.
  • Browsing a catalog of shirts, coffee mugs and other marketing items.
  • Filtering the catalog.
  • Ordering items from the catalog.
  • Viewing the user’s order history.
  • Configuring settings.

“Guidance is provided on how to implement MVVM, dependency injection, navigation, validation and configuration management while maintaining loose coupling,” Microsoft said in a blog post. “In addition, there’s also guidance on performing authentication and authorization with IdentityServer, accessing remote data from containerized microservices, and unit testing.”

Developers don’t have to create the full-blown implementation that consumes back-end services from containerized microservices, however. They can just consume mock data services if they aren’t interested in how to deploy fully functional back-end services.

Written by David Britch, the 91-page book reportedly provides a comprehensive solution for Business-to-Employee (B2E), Business-to-Business (B2B) and Business-to-Consumer (B2C) apps that can share code across all target platforms — iOS, Android and the Universal Windows Platform (UWP) — and help lower the total cost of ownership (TCO).

 

The entire series of eBook guides are available on Microsoft’s .NET Application Architecture site. The new Xamarin.Forms offering can be downloaded here (note that this link triggers an automatic download).

While primarily targeting an audience of developers interested in learning how to design and create cross-platform enterprise apps, the book says it can also serve to help technical decision-makers choose an appropriate approach for creating such apps.