Hints Library

Thursday, October 6, 2016

You can install Android N (AOSP) build on your Nexus 5 and use the functionality such as multi windows support, quick notification reply on your Nexus 5 as well. Before going ahead, I would remind you that by following this method will void your device warranty/guaranty. There are chances that your device may get bricked (unusable). So make sure you follow the steps correctly and do not stop the process in between.Requirements:

Download latest Android N (AOSP) image from xda-dev forum, you can choose any other image shared on forum.

Unlocking Bootloader

Once you have enabled USB debugging on device and connected device to computer execute below command on command prompt or terminal

adb reboot bootloader

Once your device restarted, check if the device is in fastboot by executing below command

fastboot devices

Above command should show your device serial number. If the device serial number is displayed then execute below command

fastboot oem unlock

A disclaimer will display on the device that must be accepted. Use the volume keys to cycle through the options. Pressing the power button should confirm your selection.

Reboot the device from menu if device does not rebooted automatically. Now the bootloader should be unlocked. After reboot if you see the unlocked icon on the bottom of boot screen menu.

Installing TWRP recovery

Connect your device to computer via USB.

On command prompt or terminal execute below command

adb reboot bootloader

Check if the device is on fastboot mode like above.

Make sure the recovery image is in the directory from where you are executing commands.

If the device is in fastboot mode, flash recovery entering below command

fastboot flash recovery recovery_image_file_name.img

Once the flash completes successfully, make sure you reboot the device.

To check if the recovery completed successfully, reboot device in recovery mode, you should see the TWRP recovery menu.

In order to manually go to recovery mode -> Powered down the device. Now hold the Volume Down and Volume Up buttons. Then press and hold the Power button until a boot menu appears. Navigate using the volume keys and select RECOVERY using the Power key.

Installing Android N(AOSP)

Copy the Android image zip to SD card, you can use the below command to do the same after connecting your device to computer via USB. ( USB debugging is still on)

adb push android_image_file_name.zip /sdcard/

Reboot your device to recovery mode

In TWRP there is an option to backup. You should create a backup before installing custom ROM so that you can go back if anything goes wrong.

Once you have taken a backup:

Select Wipe and then Factory Reset.

Select Install.

Navigate to /sdcard and select the android_image_file_name.zip package.

Follow the on-screen notices to install the package.

Once installation has finished, return to the main menu and select Reboot, then System. The device will now boot into Android N.

USB debugging has a number of uses on Android devices. To enable USB debugging you should first enable Developer options. Developer options have some setting relevant ro advanced users and developers.Developer options is hidden by default, and can be activated with the following steps:

From Settings, select About phone (or About tablet).

Tap the Build number entry seven times. On the seventh tap, you will be notified that "You are now a developer."

Return to Settings. Developer options should now be visible just above the About phone ( or About tablet).

Now to enable USB debugging click on the Developer options -> USB debugging (Android debugging). Some devices might require Developer options to be on before clicking on USB debugging.

Tuesday, October 4, 2016

Let's consider below
are the requirements for parking lot. Based on these requirements we will have
to design a parking lot.

Requirements

The parking lot has multiple
slots.

The parking lot can park
motorcycles, cars, and buses.

The parking lot has small
slots, compact slots, and large slots.

A motorcycle can park in any
slot.

A car can park in either a
single compact slot or a single large slot.

A bus can park only in a
single large slot.

We can devise below
use cases from above requirement.

Use cases

Any vehicle enters and asks
for free parking slot ID.

If any appropriate parking
slot is available, vehicle will get assigned parking slot and that parking
slot will be blocked for parking till vehicle leaves the slot.

Any vehicle when leaves the
parking slot, the same slot will be free for parking other vehicles.

If appropriate parking slot
(to fit the vehicle) is not available, parking lot will return parking
full message.

Lets break up the
use cases in different module of functionality.

Parking Lot

Parking lot has multiple
slots.

Parking lot can display is
parking is full.

Parking lot can tell if given
vehicle can be parked or not.

Parking lot can allot slot
for vehicle.

Parking lot can clear
allotted slot for vehicle.

Parking lot has Parking slot
allotter.

Parking slot allotter

Parking slot allotter allots
the parking slot basedon below
algorithm

motorcycle can park in any
slot

car can park in either a
single compact slot or a single large slot.

bus can park only in a
single large slot.

If no slot is free for
vehicle return, Parking Full message.

Parking Slot

Parking slot has type.

Parking slot has status.

Parking slot has ID.

Parking slot can tell if
given vehicle can be fit in the slot.

Vehicle

Vehicle has a size (small,
compact, large), which states how much space required to park

Vehicle has type.

Vehicle has park and leave parking functionality.

Slot Type

Small

Compact

Large

Vehicle Type

Motorcycle

Car

Bus

Slot Status

Free

Occupied

We need to take care
that we should not derive individual vehicle type from vehicle, like Car, Bus
etc.. Because tomorrow if slot is supporting 10 additional types of vehicle
there will be class explosion and we are not much interested in vehicle types here
but we are only interested in size of vehicle. Same analogy applies for the
parking slot.