I have a good old nexus 4 still trying to keep up with the big boys in the market. After google ditched the plans of releasing the latest android 6.0 - Marshmallow for nexus 4, things didn't look so great. But with the release of CM 13 (mako), even nexus 4 has android 6.0! Previously, I was running CM 12.1 and I dirty flashed CM 13 on top of it. Although it doesn't have all the features that CM 12 had, with time, the awesome guys in XDA and cyanogen will port all the features to CM 13.
After dirty flashing CM 13 on top of CM 12.1, I faced some problems. First of all, things were kinda slow. So I went to Developer options in Settings and set all the Animation scaling to .5x. This considerable made things faster. Secondly and more importantly, my sim card was not getting detected and I was getting a ton loads of popups saying "Unfortunately the process com.android.phone has stopped".
I looked at the logcat to see what is going wrong and I found that this was appearing a lot of times.
Clearly, the problem was with com.android.providers.telephony. Upon looking closely, the problem was related to CursorWindow and Cursor. Hence, the problem was not with CM 13 but with the old database left behind by CM 12.1.
Solution
Just delete the folders /data/data/com.android.providers.telephony and /data/data/com.android.phone using some tool like Root Explorer or you can do this in adb shell.
Like I told you few days back in this post, I made a widget for android to toggle USB Debugging - ADB (Android Debug Bridge). Today, I will tell you more about it.
There are many alternatives to this. However they either require you to make the app a system app or they simply open the settings page. As this was not exactly what I wanted, I made one myself that allows me to enable/ disable USB debugging on click. You can get the app from here.
I happen to frequently use an app that doesn't work if USB Debugging - ADB (Android Debug Bridge) is enabled. It is very cumbersome to go to settings and enable or disable the setting every time I need to use the app.
I checked if there are any widgets that could do this in a click and returned empty handed. So, I did what every developer would do - build it myself!
In order to change the adb settings, I had to use WRITE_SECURE_SETTINGS permission. But there was one major problem! This permission is not available for non system apps!!
The easiest solution to this was to move the apk to /system partition. Except that I didn't want to do this as I frequently keep flashing /system partition.
Another solution was to use pm and grant permission to the app like this:
adb pm grant <package name> android.permission.WRITE_SECURE_SETTINGS
This was great! However I didn't want users who were gonna use the app to go through all this pain. I had to figure out a way to do the same programmatically. So I did the next best thing! To run the command after opening a root shell in the code.
Here is how I did it.
This requires root. But that's ok.
For the past few days, whenever I tried to access any site with HTTPS, I used to get this error.
"This webpage is not available
ERR_TUNNEL_CONNECTION_FAILED"
This used to occur only on mobile network (airtel) and not on WiFi. At first it seemed to be a problem with chrome. But the same problem was there in other browsers. After breaking my head for a while I read somewhere that android doesn't support SSL over any port other than 443 (too weird to be true). But this couldn't be the issue because https://google.com , https://twitter.com etc use 443.
Upon investigating further, I realized that it is a very silly issue. It is because the default Access Point (Airtel Live) that came with my carrier (airtel) had a proxy that was not allowing SSL Tunneling.
After setting Proxy and Port to nothing, the problem was solved!
I am sure many of you are excited about the return of DragonBall after 18 years as DragonBall Super! Although I saw the original series much after it ended, I am a great fan of it and the fact that it gave birth to a new generation of anime is just amazing. Hats off to you Akira Toriyama!
To celebrate the return of DragonBall, I made a video of me performing the classic Kamehameha attack and made it my phone's boot animation. Here is the Vine of the video I made:
.
Grab the Adobe After Effects project of this video from here.
Here is how it looks while phone is booting:
Boot animation in android comes from the file called bootanimation.zip which is at /system/media. This file essentially consists of sets of sequences of images which have to be shown one after the other. Here we need to generate bootanimation.zip with just one sequence of images (extracted from the video) which runs in a loop. As there is no tool which can do this, I wrote a simple shell script.
Here we have to generate two things.
1. Folder with sequence of images.
2. Description of bootanimation.zip, which tells what to do with the images.
After running this script, bootanimation.zip is generated. Now move it to /system/media and set the permissions to 0644 (rw-r--r--)
I recently wrote an article called "Magneto = Gyroscope + Accelerometer + Geomagnetometer" where in I explained how to use Gyroscope, Accelerometer and Geomagnetometer to map your movements to mouse movements. In this article I will show you how to use Magneto 2.0 to play computer games using your android wear or phone.
Here is a video of me playing few computer games using my android wear
How to use it?
Setup
Unfortunately, I haven't made a simple way to do this YET. And this is available only for Linux and Mac. If you wan't to give a try you will have to follow all these steps. I am assuming that you have ADT setup.
Hold your device in front of the computer screen. This will be your initial position.
Rotate your hand to left position and click on L. So, this will mark the region beyond it as Left. Then rotate your hand to the right and click on R. This will mark the region beyond it as Right. Similarly, do the same for Top (T) and Bottom(B)
If you feel that you have to redo it, press RESET button and click on the letter. When the letter becomes L (capital L), redo Step 2.
There is a lot of scope for improvement. For instance, I haven't written the navigation script for windows. Pull requests are welcome.
You might have noticed the COMMAND button. It takes voice commands from the user and sends it to the computer. I will talk about that in another article.
I recently participated in a 24hr hackathon where I built a system called Magneto using which people with physical disabilities will be able to control a computer with arm movementsandvoice commands. This sort of gives the power of Magneto (from Xmen), hence the name!
Magneto runs on both android phone and wear. Here is a quick view of its working:
If you are interested to view the source. Github: Magneto
The intention of this article is not to showcase Magneto, but to explain the physics behind how I was able to map the sensors on android device to mouse movement. While making it, I had used a lot of builtin functions and some help from FusedGyroscopeSensor. Later, I did a lot of research (mainly on linear algebra and rotation physics) to get a clear understanding of the logic. In this article I will clearly explain the learnings.
Sensors
I have used 3 sensors available on android device
Accelerometer - measures the acceleration applied to the device, including the force of gravity.
Geo magnetic sensor - lets you monitor changes in the earth's magnetic field.
Gyroscope - measures the rate or rotation in rad/s around a device's x, y, and z axis.
Getting the initial rotation matrix
The initial rotation matrix describes the initial orientation of the device. It is found using accelerometer (for gravity) and geomagnetic sensor. Any vector when multiplied with this rotation matrix should transform it to world coordinate system. This is an identity matrix if the device is aligned with world's coordinate system, that is, when the device's X axis points toward East, the Y axis points to the North Pole and the device is facing the sky.
Step 3 Rotate A over H using Rodrigues' rotation formula
Step 4 The rotation matrix R is represented in terms of H, M and A
Get current orientations using gyroscope
Now that we have the initial rotation matrix we can proceed processing the rotations of the device. The gyroscope measures the rate or rotation (not normalized) around a device's x, y, and z axis i.e angular velocity. Also, we keep track of time taken for the device to rotate from its previous position to current position.
Given that gyroscope works very fast, we can divide one action into several smaller samples in a sequence. Now let us consider one such smaller sample.
Say the rates(angular velocity) and time taken are:
"In three-dimensional space, any displacement of a rigid body such that a point on the rigid body remains fixed, is equivalent to a single rotation about some axis that runs through the fixed point."
It means that any rotation can be expressed as a single rotation about some axis. The axis is the unit vector which remains unchanged by the rotation. Let us determine this angle.
Angular speed is calculated. It is just the magnitude of angular velocity.
Angular velocity is normalized. The resultant vector gives us the unit vector in the direction of angular velocity. This is called Euler axis.
Now that we have magnitude of angular velocity we can calculate Euler angle.
Rotation Vector is a 4 dimensional vector called quaternion represented in terms of Euler axis and angle[2] as follows:
The delta rotation vector is converted to delta rotation matrix. Now, In order to get the resultant rotation matrix, the current rotation matrix is multiplied with the delta rotation matrix.
Now actual angles i.e angles made by the device with respect to device's coordinates (NOT world coordinates) are determined. See Conversion formulae between formalisms.
Mapping angles with mouse's coordinates
Now that we have the required angles, we can determine the desired mouse coordinates. If D is the approximate distance of the device from monitor, D tan θ will give its component on the monitor. Using this concept we can find out the desired X and Y coordinates of the mouse.
Repeat this process (except finding initial rotation matrix of course) every time the device moves to determine mouse coordinates.
NOTE: All formulae were made using Latex and are sharedherefor your use :)
There are hundreds of apps on Google Play which claim to download youtube videos. However most of them are either fake or not functional. Youtube recently added a feature using which it is possible to download youtube videos. But it stores it only for two days.
We all know that youtube-dl provides us a 100% effective way to download videos from youtube. In this post I will show you how to do this:
Executables with PIE (Position Independent Execution) have been supported since Android 4.1. It is a security feature involving address space layout randomization(ASLR) to prevent attacks such as buffer overflow. In Android's latest release Lollipop, PIE has been made a requirement. Similar to the way the shift from Dalvik to ART has crippled so many applications, this move has caused a lot of problems to developers. Even some of the binaries shipped with android itself were broken because of this.
I will be showing you how to install RunPythonFromShell. If you have already installed it and want to see how to bypass PIE go to the section Bypassing PIE.
Install the apk and open it. Click the install button in the app to install all the modules and binaries.
Step 2
If you don't want to run python from everywhere, skip this step.
Open adb shell
Download the following gist. Move it to /system/bin and change set executable permission.
If you are running an android version older than lollipop then you are done! Lollipop users have to bypass PIE.
Bypassing PIE
Due to the PIE restrictions you get the following error when you run python:
error: only position independent executables (PIE) are supported.
The idea here is to replace the default linker with a custom linker (You need a rooted device. duh!). First mount /system in write mode and backup the default linker.
I installed unofficial CM 12 with Android 5.0.2 today. Earlier I was using stock Android Lollipop and it had the option of adding Microsoft Exchange account. Unfortunately CM12 didn't seem to have it.
After doing some research I figured out that only devices running stock Android 5.0+ are capable of having exchange accounts. And CM12 although runs on Android 5.0, doesn't have this feature. On doing further research I found out that Android 5.0+ have something called Exchange services which enables gmail 5.0 to handle exchange accounts.
I was playing around with framework-res.apk and SystemUI.apk to get Ambient Display on my Nexus 4. When I restarted my phone, it seemed to have stuck in a bootloop. I knew that factory reset might've worked. But I didn't want to lose any data.
Fortunately adb was working. When I did adb logcat , it was logging an error saying: /system/framework/framework-res.apk is neither a file nor a folder (type=0)
I realized that there was some problem with permissions of that file. I used adb shell and changed the permission of framework-res.apk and SystemUI.apk to 0644. But this was of no use. However I came to know that if I could somehow reset /system partition the problem would be solved.
So I downloaded the factory image of my phone. For nexus devices it is available here.
Extract the contents of the image-xxxx-xxxx.zipto get the file system.img.
Then ran the following: adb reboot bootloader fastboot flash system system.img
This will wipe the /system partition and reset it without touching any other partitions. Hence you will not lose any data.
Restart. It took a while to start the phone completely. But it solved the problem!
This is how I was able to reset my framework-res.apk and SystemUI.apk!
Deleting .nomedia file not enough to make a folder visible in androidgallery
TL;DR: After removing .nomedia file, add/delete some file in that folder.
You might probably know that if you want to hide a folder from gallery all you have to do is create an empty file called .nomedia. This will make sure that the media scanner will skip that folder.
Sometime back I did this when I wanted to hide the Whatsapp folder from gallery. Now I changed my mind and want Whatsapp folder to show up in the gallery. So I did like any other guy would do -- I deleted .nomedia file from that folder. But this didn't work.
If I had any android version prior to Kitkat, I could've just run media scanner from some app. Unfortunately after Kitkat this wouldn't work (They changed how media scanner works to save battery).
Then I tried renaming the folder (after deleting .nomedia file). Magically, all the images started displaying in the gallery. However, I couldn't afford changing the name of the folder.
I realized that post jellybean, media scanner updates the media index only when there is a change in the folder. So, I just added a new image to that folder manually. It worked like a charm!
NOTE: If the folder is on sdcard, you can just remove the sdcard and put it back (after removing .nomedia file) to run media scanner.
After Google announced that the new Material Design is going to be adopted on Android's next release, currently codenamed Android L; lot of us have wanted to try it. Unfortunately it (dev version) is available only for nexus 5 and 7. Thankfully there is Android L theme by tung91 on google play which brings near Android L experience to other users.
I installed CM11 on my Nexus 4. After I installed Google Calendar, I thought deleting stock AOSP calendar app and few other depending apps wont hurt. Unfortunately Google calendar sync stopped working after that. "Calendars to display" was empty and "Calendars to sync" never completed loading. When I searched for solution for this online, people suggested to do a reset; which I didn't want to do. So I tried reinstalling the default AOSP calendar app. It fixed the problem!!!
Download the following apks and install them on your phone.
Update
Some people say that they face the following error while signing in.
"Couldn't sign in. There was a problem communicating with Google servers. Try again later"
After installing the above apks, if you open the calendar app directly you will get this error. You have to restart the phone to fix it.
I have seen people struggling to install apps on their android due to the fact that they have less internal memory. Today i will show you how to increase your internal memory i.e i will show you how to use your SD card as your internal memory
There are two ways of doing it one the noob way(easy and safe) and the other geek way(difficult and risky).
Anyway for either of them you have to do this
BACKUP YOUR SD CARD as all contents on the SD card will be lost.
Download clockwork mod for your phone. Just Google it :P . And then place it in your SD card (don't unzip it).
Reboot to recovery mode. It is different in different phones. In my phone (Samsung Galaxy Y) while starting the phone i have to hold the power up+home button+power button to go to recovery mode.
Click on install zip from SD card. Note that volume buttons must be used to go up and down in the menu and home button to select.
Select cwm.zip (clockworkmod file which you downloaded)
Now CWM will open. Go to advanced.
Select Partition your SD card
Select how much you memory you want to allocate to your phone. Don't select more than 2048.
If you don't want swap select 0 for swap( swap will speedup your phone to some extent but not necessary ).
Reboot phone
Download Link2SD from Google play and select the format to ext4. If it shows some error retry selecting ext3. If that also doesnt work try ext2. If that also doesn't work go to Mt. Everest and throw your phone. Just kidding :P
Noob way
Simply use Link2SD to create links to your apk, dex(dalvik-cache) and cache files. And enjoy with more apps :P
Geek way
Do something like this (creating softlinks part) on your phone!! This will make your phone hard to manage but much much efficient than simply using Link2SD.