Tuesday, July 14, 2015

PHP cURL Guzzle mbstring apache extension - crap of the day

My day's woes were something like so.. Working on the OAuth driver was throwing some stuff I hadn't seen before. It had a short fix.

Short fix: PHPIniDir directive in Apache, configured alongside PHP extension, should point to the php.ini file, not the php.ini directory!

Platform: Windows 7 / Apache 2.4 / PHP 5.6.11 Thread-safe / Laravel 5.1 / MySQL 5.6

I had set my path variables right, and phpinfo() was showing that it could pick php.ini from its directory just fine. Apache sometimes has a separate php.ini that comes with XAMPP-type installations, but that wasn't the case. I went through all documentation of guzzle and checking out the Middleware and its Promises and dd-ing in my libraries... which was basically pointless.

Finally it was established that cURL wasn't loading because it wasn't being picked up by PHP. I started getting a mbstring error now; while the extension was enabled. Disabling other extensions didn't affect the output. That's when I tried checking all ways php.ini could be popped in, and wallah, editing the PHPIniDir in httpd.conf, worked.

[2015-07-14 15:33:10] local.INFO: Authenticating user with provider: twitter
[2015-07-14 15:33:10] local.INFO: redirecting to twitter
[2015-07-14 15:33:10] local.ERROR: exception 'Guzzle\Common\Exception\RuntimeException' with message 'The PHP cURL extension must be installed to use Guzzle.' in G:\passionstreet\framework\laravel\vendor\guzzle\guzzle\src\Guzzle\Http\Client.php:72
Stack trace:
#0 G:\passionstreet\framework\laravel\vendor\league\oauth1-client\src\Client\Server\Server.php(307): Guzzle\Http\Client->__construct()


And before that a Guzzle Client 400 Error

[2015-07-14 15:13:25] local.INFO: Authenticating user with provider: facebook
[2015-07-14 15:13:25] local.INFO: retrieving social login user, with provider facebook
[2015-07-14 15:13:26] local.ERROR: exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: 400' in G:\passionstreet\framework\laravel\vendor\guzzlehttp\guzzle\src\Middleware.php:69
Stack trace:
#0 G:\passionstreet\framework\laravel\vendor\guzzlehttp\promises\src\Promise.php(198): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#1 G:\passionstreet\framework\laravel\vendor\guzzlehttp\promises\src\Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)

And before that a Guzzle 403

[2015-07-14 14:41:54] local.INFO: retrieving social login user, with provider google
[2015-07-14 14:41:56] local.ERROR: exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: 403' in G:\passionstreet\framework\laravel\vendor\guzzlehttp\guzzle\src\Middleware.php:69
Stack trace:
#0 G:\passionstreet\framework\laravel\vendor\guzzlehttp\promises\src\Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#1 G:\passionstreet\framework\laravel\vendor\guzzlehttp\promises\src\Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)

And before that doing something weird redirecting with a provider 'Rahul'

[2015-07-14 14:41:39] local.INFO: Authenticating user with provider: rahul
[2015-07-14 14:41:39] local.INFO: redirecting to rahul
[2015-07-14 14:41:39] local.ERROR: exception 'InvalidArgumentException' with message 'Driver [rahul] not supported.' in G:\passionstreet\framework\laravel\vendor\laravel\framework\src\Illuminate\Support\Manager.php:90
Stack trace:
#0 G:\passionstreet\framework\laravel\vendor\laravel\framework\src\Illuminate\Support\Manager.php(63): Illuminate\Support\Manager->createDriver('rahul')

Then back to the cURL

Then I got back to the first error to start my day, that in one of the views
[2015-07-14 13:10:06] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Method Illuminate\View\View::__toString() must not throw an exception' in G:\passionstreet\framework\laravel\storage\framework\views\f404135fc8f0d4d388888d2a371ebe1d:0
Stack trace:
#0 {main}
[2015-07-14 13:23:54] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Method Illuminate\View\View::__toString() must not throw an exception' in
 



Sunday, April 19, 2015

Crazy KitKat upgrading Gionee M2

The past weekend I wasted a lot of time, over what seemed an innocuous software update after getting fixed a broken USB/power port on the Gionee M2. 
The original issue that put this phone out of service was a bad USB port. It had been a dead phone for the longest time. Thanks to Delhi's Nehru Place, that what Mumbai's repairmen couldn't do, was done, which is fixing that minor issue. Once the a new jack was soldered onboard, then phone sprang back to life. It was great to know that the battery wasn't screwed up, since that is one component impossible to find as its not a standard "Chinaphone" feature to include 4200mAh brick batteries.

Riding on this success, I then thought of doing a software fix. The Gionee M2 came a JellyBean 4.2.0 phone, and apparently Gionee had been not-so-useless by coming out with a KitKat 4.4.2 upgrade. The instructions were clear and straightforward enough on Gionee (India's) website.

Here's the phone specs.
Hardware : MT6582
Model : M2
Build number : M2
Build date UTC : 20140719-110128
Android  v : 4.2.2
Baseband v: MOLY.WR8.W1315.MD.WG.MP.V11, 2013/11/27 10:34
Kernel v : 3.4.5 (android@android-6) (gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #1 SMP  Sat Jul 19 18:59:30 CST 2014

It seemed there would be no apparent harm. But being me, keeping out of the harm's way is impossible. Hence, I initially screwed up on the image I'd downloaded for my phone.
Thanks to girlfriend, it was a 4G phone and not 8G as she had remembered. It was her phone, initially, so she'd better remembered. I chose a wrong scatter file (8G), and hesitantly started the firmware upgrade process. The KK upgrade would finally have the BLE working on this phone, which I had been wanting for energy-efficient BT chips found in newer 'lifestyle' devices.

It was a relief to see everything progressing smoothly. The image file started loading one by one, and reached 99%.. that's when the error struck. I was devastated.

After a lot of 'not-getting-it', and confusion between the ADB/Preloader/VCOM drivers, and technique to boot in preloader (with the Power+Volume Up buttons), the 4G KitKat finally got the phone working. Oh, in the meantime, it was considered a brick. Thankfully, it was an incident of 'soft brick'. I am trusting enough that 9 in 10 'bricked' phones would probably be bricked this way, and can be rescued.



Mine, though was unleashing a new story of rescue. On booting the phone to KitKat, it gave an error about "Invalid IMEI". Since I'd forgot to put the SIM card inside, I tried doing that, but it still said the same. The SIM was detected and carrier was displayed on the screen, bu the phone would show no signal or no connection for the carrier (Airtel, Vodafone, tried on both, in this case). 



The phone, it turned out, was more than devastated. It lost its two children, to put it metaphorically. Being a dual-sim phone, it had two SIM slots. That means, two IMEI numbers as well. Both those IMEI numbers had been erased during the fiasco. Some technology. Some neck!
It showed 'null' for both the IMEIs just like the screenie below. 


 I retried doing the same stuff but to no good.


Learnt that it happens to phones. Didn't know IMEI could be accidentally erased. Then learnt that it's easy to reset and change IMEI on MTK chipsets, the types (MT65xx) that the Gionee M2 has. If it is accidental, it should be well within legality as well, I presume, as long as it's being done. I could make a good business out of it.

Anyways that depends on whether I manage to fix this phone or not.
  Lately, I've been traveling a lot.

I took this phone on travel with me and my laptop, as we had to zip through Delhi then zip back and slingshoot ahead to the Airport come back again and slingshoot to Noida. There are ways to reset the IMEI even without rooting, but that involves modifying image files and reapplying scatter files, which is tedious, and besides the phone is outta warranty. 
This Gionee M2 was successfully rooted using this link on XDA-developers . 


Then I installed MTK Engineering Mode, an app that opens you to backdoor stuff. There, you enter the commands to reapply the IMEIs. The instructions are all over. This experience left me a bit disillusioned with MTK chipsets, enamored by the hacker/modification community, and also scared about the ease with which changing IMEI is possible - thought they were the last resort to tracking stolen phones, but it is SO EASY to trust that you have some last-resort security on your device, which turns to be an illusion.

Considerations aside, this Gionee M2 is a working phone now. Its battery is seriously impressive, and I hope that future battery technology will make it reasonable to expect 3 days of active use of our mobile devices with a slow draining battery that will not die so soon as in these days.