Saturday, November 4, 2017

Getting on to a different bandwagon

In the previous blog the efforts of rooting and removing bloat-ware was reflected. Now the next lines of discussion on XDA was to install a custom ROM.

Now the deliberation was to find the best one for the purpose. So the search started for the best fit with google searches like "Best ROM for rooted android phones". So there was AOKP, Dirty Unicorn, OmniROM, SlimROMs, Ressurection Remix, Pac-Man ROM, Paranoid Android and several others. Each of these looked very much promising with several different features. Some of them like Dirty Unicorn, Ressurection Remix and Paranoid Android did not support OnePlus One, others like SlimROMs had the build created a long time ago and no update on it so far.

On the list provided on several different websites that are found on the search, the top one is almost always CynogenMod. It is really sad story to hear of the end such a happening ROM that dates  back as old as Android itself. So then next contender in line seems naturally LineageOS.

But from there a digression occurred when it was informed that Ubuntu OS has been migrated for OnePlus One. Now this is called Ubuntu Touch with all its resources available online.  After Ubuntu stopped support for the mobile OS UBPorts took it up. One can see that here that OnePlus One is a core device for this OS. Now with a purpose to try tinkering with mobile OS, this offer was enough tempting.

So from there started the quest to get the perfect installer. The first problem was to get the mobile detected on the mobile. For this tried different cables & different drivers (including the one from OnePlus website). After finding the perfect combination the efforts started to get Touch using the installer from here.

Now because my current machine was windows attempt was to use the installer to get it installed. Now this installer seemed not to detect the mobile when connected in fastboot mode as instructed by the installer even though. fastboot command itself was able to detect the device but not the installer. Multiple machines, multiple drivers and multiple cables all yielded to similar results.

Then used the CPT-Installer which was able to detect the device. That was a relief after all the efforts but the exuberance was short lived. The installer did detect the mobile and started the process. It formatted the data on the phone and then started the download-install process that was stuck for hours without any progress. At the end all that was left was a half-baked phone that would not boot as it had no OS in it. After checking that fastboot is still working it was ascertained that it was a soft-brick.

Ubuntu boot screenSo the last option was to follow the steps provided for the devices from the project site itself either by the magic-tool or by the system-image server. On finding the machine with Ubuntu installed the process went very smooth and the process completed in minutes. In case of any issues the Wiki too could be consulted. So very soon the colorful screen of Touch OS launched on OnePlus One
successfully.

Monday, October 2, 2017

They are the same but different



alcatel Flash 2Wanting to try to break out from the imposed dependence by mobile vendors wanted to try experimenting with rooting. I currently owned Alcatel Flash 2 device which had a screen problem. As you can see from the image, the screen was a little broken. 😊

So then started the quest for the perfect mobile that could be used for my experimentation. For that started using OLX. The process was simple. Find a sale post within budget (10K), then find the original cost of the mobile to see if the deal is realistic, then find the features are to be satisfying, and finally browse XDA-Forum to find if there is enough support for this model so as to be able to root and flavor it differently.

People on OLX are sometimes very unrealistic. They ask an amount close to the new one when it is clear that on OLX one is always looking for seconds. Sometimes it feels like a shop guy is selling a new mobile as "box-piece" on OLX. Anyways after lots of scouting, messaging, negotiating, calling and rejecting (reducing in number in that order) finally decided to visit one of the seller. It was OnePlus One. Though the cost was a little more than what was in my mind but still decided to give a visit. Several factors, including the fact that I was tired of further looking etc. I decided to get it.

After initial usage figured that there was hell lot of bloatware in this mobile. There was Cortona installed as a personal assistant, which was not corresponding with OnePlus. A Chinese company with Google OS adding Microsoft software as personal assistant!

So the first task that I embarked upon is to root it using this. Now the installation of custom recovery went smooth, but from there when choosen to install the SuperSu inbuilt in the TWRP the mobile would boot no-more. Only recently discovered that if we unroot things will move back to working state and then we can go ahead and root again with a different software. But at that time \ thought it had gone into a boot-loop and tried different solutions like running makefs command, which actually sent it into a boot-loop. After lots of failed experimentation of trying get recover it back decided to install stock-ROM got from OnePlus website. Directly working with TWRP did not work and hence had to run the script given with the bundle and ended up loosing the custom recovery.

More than loosing custom recovery the fact that the original OS of the mobile was lost was a little disheartening. Mainly because the stock-ROM  got from OnePlus website was nothing like the first original one. It had none of those huge bloatwares and no Cortona. It looked like the stripped-down version of original software made consciously for those who tinker with their mobile OS.

Thursday, November 12, 2015

StringTokenizer to split using multiple tokens in java

When trying to split a string over multiple tokens, the best thing available was thought to be the split. That way if we have to split over a string multiple times then we can split and then split over the splits, but what if there is more the be split over the parts, then we will have to split again.

Let me explain with an example. Say we have a URL that needs to be parsed.

URL: http://localhost/system/config/file/action/updateLogo?fileName=largetc.jpg&text=Company%20Logo
W

So if we have to read all the the path parameters and then also read the arguments then we have to do a split over the '/' parameter as below:

String[] urlTokens = urlFullPath.split("/");

Now let us say that we want to read the path arguments that are passed in the URL. Then we will have to do multiple splits over the path string to reach the desired variables. The below is one of the ways that it can be achieved.

String[] urlTokens = urlFullPath.split("/");
for (String urlPath : urlTokens) {
if(urlPath.contains("?")){
String[] argTokens = urlPath.split("\\?");
String[] argsParts = argTokens[1].split("&");
for (String args : argsParts) {
System.out.println("Args: " + args);
}
}
}

The output of the above piece of Java code would look something like:
Args: fileName=largetc.jpg
Args: text=Company%20Logo
That, as you can see, are a a lot of splits. Is there any better way. Probably there are a dozen ones. Here is one with StringTokenizer for easier manipulation.

There are two ways to specify a delimiter for a StringTokenizer object.

  1. In the StringTokenizer constructor pass the delimiter when initializing the object
  2. In nextToken() method pass the delimiter you are looking for next at runtime

Using StringTokenizer constructor

In the constructor one can pass the list of all the characters on which the string has to be split and accessed as:
StringTokenizer stringTokenizer = new StringTokenizer(theStringToParse, "/?&");
And then iterate over the tokens via a while loop as below:
while (stringTokenizer.hasMoreTokens())
System.out.println(stringTokenizer.nextToken());
Using nextToken method

To use by runtime parameter to the nextToken method, below is one of the ways:
while (stringTokenizer.hasMoreTokens())
System.out.println(stringTokenizer.nextToken("/"));
The token above can be changed as needed. One thing that needs to be kept in mind is that once a move to nextToken is done then the previous token is lost and one cannot do a trace back.

Split that URL
Combining all of the above here's a piece of code that can be used to extract the arguments passed in a URL as a key value pair.

StringTokenizer stringTokenizer = new StringTokenizer(theStringToParse);
// iterate through tokens of path parameters
while (stringTokenizer.hasMoreTokens()) {
String partOfToken = stringTokenizer.nextToken("?");
if (partOfToken.contains("=")) {
StringTokenizer tokenizeAgain = new StringTokenizer(partOfToken, "&");
while (tokenizeAgain.hasMoreTokens()) {
String argument = tokenizeAgain.nextToken();
String[] keyValueOfArgument = argument.split("=");
System.out.println("Key: " + keyValueOfArgument[0] + " and Value: " + keyValueOfArgument[1]);
}
}
}
The output of the above piece of code, when integrated with all the fans and flurries needed to execute would be, assuming the URL given at the beginning is the string to be parsed:
Key: fileName and Value: largetc.jpg
Key: text and Value: Company%20Logo 

Saturday, September 26, 2015

Is the net really neutral?


The recent debate on net-neutrality has become a major issue, so much that even Rahul Gandhi spoke on this topic. Further it has made it clear to general public that there are many intermediate players before any of the content from the internet is delivered to the end user. All these players are there with a business of their own that serves their personal interest.

A part of this not-so-simple structure of the internet is the government. Hence the Federal Communications Commission (FCC) was created to regulate interstate communications by radio, television, wire, satellite, and cable, as a watchdog of USA’s telecommunication industry. TRAI is the Indian counterpart working to regulate telecom services and tariffs in India.

There has been several comparisons of the internet to the electricity company for the purpose of debate on net-neutrality. This comparison is not exactly appropriate. Electricity does not have an inherent meaning within the flow of charged particles that inform as to what type of electric instrument is being used. For example, if the consumer is using a TV, or a fridge, or any other such specific electric appliance cannot be known by looking at the rate of flow of the charged particles. Other comparison are to the swing, where the swing movement is being controlled based on the payment made for the use of its functionality and to the buying fruits from a street vendor. These comparisons are rather more simplistic ignoring the more complex nuances associated with the internet.

A more appropriate comparison on this would be that of a postman. This is more appropriate because of two reasons. Currently the service providers work using multiplexing of data from different users over a single connecting. This is because the speed of underlying connections that are laid using optical communication systems are at rates of Giga-Bytes that are much higher than what an individual can use. For example the network speeds can go up to 100 GB/sec while the consumer will not be able to consume data at such a speed. Hence instead of giving the whole underlying network for one user at any specific time, the network providers put together data from different users in a single package(data over a network is sent in packets of data, one at a time) for transmission. Hence it is like a postman who is carrying letters in a bag and instead of carrying one person’s letters at a time the letters from multiple users are put in a bag and carried along at the same time.

The second reason that this analogy is closer is because the independent letters have the inherent information in it informing of the source and the destination and so allowing for a discrimination based on the meta-data, considering the content of the mail as the actual data. This model tries to model the complexity on a smaller scale.

Another argument being put forth is that of Internet Fast Lanes. This would allow the telecom operators to give preferential speed to companies with deep pockets while throttling speeds of others. This was shown by the comparisons with swing given previously in this article. But the internet already has a “fast lanes” because of CDNs.  These are distributed system of servers that provide content to the end-users with high performance and availability. In simple language when someone logs in to say facebook or gmail it is not guaranteed that all the data of their wall is coming from facebook server. Most of it may be coming from a CDN that is lying geographically very close to the user. That way the speed of delivery can be increased for quick response to the users. Akamai Technologies is the most popular CDN that delivers content to several privileged companies. As soon as a user opens or logs in to many websites one can see content being pulled from Akamai.com that will be displayed in a small pop-up at the bottom of the browser screen. Another technique being used are the peering connections where the content providers have direct connections to ISPs and run dedicated servers deep inside these ISPs to deliver content faster. Clearly these “fast lanes” are available to only those with deep pockets giving them an edge over the others with lighter purses.
In one of our previous article we pointed out that the internet is controlled by the gateway of the internet, i.e. the search engines. We had argued that if something is hidden in the 100th page of the search result, even if it is the most relevant accessible information, it is as good as non-existent and inaccessible. So the top positions for specific keywords if paid and occupied by companies, however irrelevant to it, then we can clearly see how deep pockets can tilt the internet to be not so neutral. So let’s face it.

The debate over net neutrality is not a recent one. It started in 2003 when the Columbia University media law professor Tim Wu coined the term. What we are still missing is a means of keeping the ISPs in check, else these debates will resurface in a newer form and at different levels. These debates also raise serious concerns that internet service providers are growing too powerful to influence a policy change. One way of exercising control is through common carrier law. These laws are necessary to define the framework in which the internet service providing companies have to function. There will definitely be opposition if it clamps down the current freedom being enjoyed by these companies hence it has to be done impartially by a third party including public opinion in their decisions.

The internet.org by facebook is being touted for being against net neutrality while Mark Zuckerberg defends it as being a plan to bring the internet to everyone. After the uproar, majorly in India, Zuckerberg expanded internet.org so as to allow developers to provide an app through Internet.org. Their argument is that the debate was over consumer choice and developer choice and they seem to have addressed them via their improved platform. Currently they are offering several projects that can work via their platform and an option to build more. Hence believingly the argument has moved further from the debate of providing lopsided access to the internet. Now the discussion has to be around as to which services and websites are or can be provided access via internet.org and who is to decide this.

Let us face it. The internet is not as much neutral after all and people with deep pockets will keep working to further their interests in further making work more in their favour. Let us get back to our analogy of the postman. The postal service is everyone’s necessary. There will soon be a day when the internet will also be such a necessary service, just like railroad, bus services or airlines. Hence what is being proposed is to regulate the telecommunications as common carriers.

Of course there will be arguments against the government gaining control on the network of networks arguing that it is the freedom that has provided incentive to the network providers to build the whole infrastructure that currently delivers internet. Another argument is that if the government holds the control then the whole process will be slowed down while these type of services need a faster response. The need of the hour is to further the debate on the common carrier and take a stand for the common good of the masses at large along with appropriate consideration to the involved parties.



Published Article Reference: http://thecompanion.in/is-net-really-neutral/

Wednesday, September 25, 2013

A Question of Privacy

The access of the digital information by the government for the purpose of security is not a new or isolated phenomenon. As pointed-out in my previous article on “Who controls the Internet?” it’s evident that the government has significant effect on the way that the network-of-networks is shaped. In that sense the government already has a control on the data to some extent. Direct access to the data is of course debatable based on many factors, including the results of such access.

Google, in its motion on September 5th, 2013 has made it clear that it is rather foolish to think that the information put online by the user is not accessed at all and kept completely private.

Personal Information online is a concept that may lead to contradicting connotations. If Personal Information is put online, then the owner of the information is no more the individual but it lies with the owner of the servers where the site is hosted and where this information is stored. So, it may no more be called as Personal Information but may be Server Information as that is what identifies the server and becomes its attributes, e.g. a Facebook server is called so, as it has the information of the users of Facebook. Hence, once the information is out of the hands of an individual, it is at the discretion of the company that owns the data to use it as it wills. Google, in its motion on September 5th, 2013 has made it clear that it is rather foolish to think that the information put online by the user is not accessed at all and kept completely private. Google scans all the emails to gather information on an individual’s online activity. For example, if one is sending mail about pizza party, googling about pizza varieties and also searching on Youtube for videos about making pizzas then it is not at all a surprise that based on location information the person gets advertisement about Pizza retails outlet, or Pizza product selling shops. What should Google do if the individual is doing the same with the keyword of “Bombs” or “Guns”?

The Foreign Intelligence Surveillance Act of 1978 (FISA) spells out the circumstances under which the government can eavesdrop for the purpose of gathering foreign intelligence.  Before Sep 11th, 2011, Bush administration’s Justice Department approved a program that may have relied on similar technology, but was far narrower in scope. Post Sep 11th the USA PATRIOT Act was passed under Bush’s Administration, primarily to include terrorism on behalf of groups that are not specifically backed by a foreign government. Further the Protect America Act of 2007 removed the warrant requirement for governmental surveillance of foreign intelligence targets. These developments point out to two things; that the surveillance activity has been present from a time longer than what we might know and that the monitoring activity is born out of the requirement of battling terrorism using all the available data. The best way to analyze the achievement of this goal is to look at the success of the whole program. It is hard to determine this for mainly two reasons. A direct co-relation between something that did not happen or maybe was prevented from happening to the act of collecting public information can only be established if it is attributed as such by either the ones who prevented the event or those who handle the data. Such information directly in the public domain can put the further success of such a program at risk as it is the discretion of the program that lead to its success in the first place as argued further.

When the British government decided to build its own Big Brother Database, there was a public debate. There was such high criticism that the plan had to be dropped for good (the British government does still have its counterpart of PRISM). United States, on the other hand had the bill passed under different circumstances when the whole nation was and still continues to live in the state of perpetual fear which is evident in the surveys conducted on the citizens of America. In answer to the question of whether “people should support their country even if the country is in the wrong,” more Americans said “Yes” than citizens of eight European countries and when asked whether “right or wrong should be a matter of personal conscience,” Americans came in next-to-last. Above results were found in 2003 by the International Social Survey Program. Further a debate of sorts on NSA’s data-collection efforts was discouraged quoting the reason: “If you tell our adversaries and enemies in the counter terrorism fight exactly how we conduct business, they are not going to do business the same ever again,”[SIC] by Mike Rogers, The Chairman of the House Intelligence Committee.
There are several checks put by the government for gathering data. A special court is designed to review the applications for surveillance, which is composed of 11 U.S. District Court judges selected by the chief justice of the U.S. Supreme Court. The downside is that this court has been recently giving permissions for the collections of millions of records and hence Verizon order sweeps up detailed information about millions of Americans in a single order. Another argument put forth against privacy infringement is that NSA collects only metadata of the call with the idea that when a person dials a number or sends an email, like the postal address which is visible to all, the dialed number or the “To” email is addressed is public and visible to all. Hence there is not harm in collecting metadata and collecting the actual data will be requiring a separate individual warrant. The counter; let us assume that a newspaper correspondent publishes a controversial article citing Internal Sources. Using the metadata of as to whom the correspondent was talking to over the phone, as to whom she has been communicating over email, it can be very easily pin-pointed as to who the Internal Source is, which again would lead to the invasion of privacy.

Incidental data collection is also quoted where the purpose is to actually collect the relevant information but in the process of reaching that information one has to collect all the available data and then sift through the data to gather the required information. Certainly the call and online activity of every Verizon customer or those using email etc… cannot be relevant to such investigations. It can instead be argued that the agency is collecting massive amounts of information, regardless of whether that information is relevant to national security. These concerns find more strength when we hear of news such as the confession, after multiple denials of Central Intelligence Agency (CIA) of Snooping on MIT professor, Noam Chomsky. Bilateral relations with other nations will also have to be looked into, as the Act extends on the American soil and so to the Servers that lie on American soil. Other countries like Australia are debating on whether to keep their Server Information on American soil. If a company is using the cloud service of an American company with servers hosted in America, then the data of that company is potentially liable for the scrutiny. The only way to overcome this problem is to build similar alternatives inside the borders of a nation, be it for email or cloud or online shopping.

The NSA can retain the data for up to 5 years and make use of “inadvertently acquired” domestic communications if they contain usable intelligence, information on criminal activity, threat of harm to people or property, are encrypted, or are believed to contain any information relevant to cyber security and the data that could potentially contain anyone’s details. What this means is that if the data is encrypted then US government can track, scrutinize and keep it for analysis and to decipher it; if the data is not encrypted then anyone can see it. Anything that goes over https is encrypted, be it our email or Facebook data which makes it eligible for collection, and if unencrypted, any Tom-Dick-Harry can see what is being transferred over the network. Sounds more like a chicken-egg problem.

What this means is that if the data is encrypted then US government can track, scrutinize and keep it for analysis and to decipher it; if the data is not encrypted then anyone can see it.
Is all the data really solving the problem or complicating it further is a question that needs deeper analysis. As of October 2012, nearly five million people held government security clearances to access classified information out of which, 1.4 million held top-secret clearances. More than a third of those with top-secret clearances are contractors. Booz Allen Hamilton is the strategy and technology consulting firm where Edward Snowden has worked which employs almost 25,000 people, 76% of whom have government clearances allowing them to handle sensitive national security information. This is necessary as analysis of such huge amount of data will definitely require massive algorithms, computing facilities and workforce but then that gives access to such sensitive information to a large set of people leading to a different security concern.

So, should we be concerned at all or not is up to everyone to decide collectively? 

The argument of “I am not a terrorist and so I have nothing to hide” holds no ground. Benjamin Franklin warned of the siren’s call for power by government officials when he observed that “those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety.” Moreover on reflection, among others, the main concern seems to be about power, yes literally power. Where would they get all the electricity to keep-alive such a large Data center which is being built by contractors with top-secret clearances at Bluffdale that sits in a bowl-shaped valley, in the shadow of Utah’s Wasatch Range to the east and the Oquirrh Mountains to the west. Combined with it is the requirement of the computational and algorithmic power? Would this eventually turn out to be a failed project just like the previous Trailblazer Project? Only time will decide.

References:

Shayana Kadidal (June 7, 2013), Obama Administration Continues Bush’s Unconstitutional Policies, http://www.usnews.com/debate-club/should-americans-be-worried-about-the-national-security-agencys-data-collection/obama-administration-continues-bushs-unconstitutional-policies.
Jonathan Turley (June 7, 2013), The Founding Fathers Rejected a System of Authoritarian Power, http://www.usnews.com/debate-club/should-americans-be-worried-about-the-national-security-agencys-data-collection/the-founding-fathers-rejected-a-system-of-authoritarian-power.
Alberto Gonzales (June 7, 2013), The Government Must Use All Available Technology to Protect Americans, http://www.usnews.com/debate-club/should-americans-be-worried-about-the-national-security-agencys-data-collection/alberto-gonzales-the-government-must-use-all-available-technology-to-protect-americans.
John Yoo (June 7, 2013), Government Data Collection Doesn’t Violate the Constitution, http://www.usnews.com/debate-club/should-americans-be-worried-about-the-national-security-agencys-data-collection/john-yoo-government-data-collection-doesnt-violate-the-constitution.
Washington Wire (August 9, 2013), NSA Data Debate: Glossary and Who’s Who, http://blogs.wsj.com/washwire/2013/08/09/nsa-data-debate-glossary-and-whos-who/.
Tom Gara (June 10, 2013), Booz Allen’s Top-Secret Workforce, http://blogs.wsj.com/corporate-intelligence/2013/06/10/booz-allens-top-secret-workforce/.
Glenn Greenwald and James Ball (June 20, 2013), The top secret rules that allow NSA to use US data without a warrant, http://www.theguardian.com/world/2013/jun/20/fisa-court-nsa-without-warrant.
Eyal Press (August 5, 2013), Whistleblower, Leaker, Traitor, Spy, http://www.nybooks.com/blogs/nyrblog/2013/aug/05/whistleblower-leaker-traitor-spy/.
M.S. on Democracy in America (Jun 11, 2013), Should the government know less than Google?, http://www.economist.com/blogs/democracyinamerica/2013/06/surveillance-0.
Kevin Drum (June 10, 2013), Why the NSA Surveillance Program Isn’t Like “The Wire”, http://www.motherjones.com/kevin-drum/2013/06/nsa-debate-we-should-focus-future-not-present.
Mike Masnick (June 18, 2013), Senator Lindsey Graham Defends NSA Surveillance By Arguing About Something Entirely Different, http://www.techdirt.com/articles/20130617/01573323504/senator-lindsey-graham-defends-nsa-surveillance-arguing-about-something-entirely-different.shtml.
Andy Greenberg (June 20, 2013), Leaked NSA Doc Says It Can Collect And Keep Your Encrypted Data As Long As It Takes To Crack It, http://www.forbes.com/sites/andygreenberg/2013/06/20/leaked-nsa-doc-says-it-can-collect-and-keep-your-encrypted-data-as-long-as-it-takes-to-crack-it/.
Adam Bender (June 12, 2013), PRISM revives data sovereignty arguments in Australia, http://www.computerworld.com.au/article/464445/prism_revives_data_sovereignty_arguments_australia/.
James Bamford (November 5, 2009), Who’s in Big Brother’s Database?, http://www.nybooks.com/articles/archives/2009/nov/05/whos-in-big-brothers-database/.
Brad Bannon (June 6, 2013), The Epitome of Executive Overreach, http://www.usnews.com/opinion/blogs/brad-bannon/2013/06/06/government-overreaches-with-verizon-phone-record-collecting.
Newzfirst (22 August, 2013), NSA collected thousands of Americans’ emails, http://newzfirst.com/web/guest/full-story/-/asset_publisher/Qd8l/content/nsa-collected-thousands-of-americans-emails.

Wikipedia References:

  1. Foreign Intelligence Surveillance Act, http://en.wikipedia.org/wiki/Foreign_Intelligence_Surveillance_Act
  2. Patriot Act, http://en.wikipedia.org/wiki/USA_PATRIOT_Act
  3. Protect America Act of 2007, http://en.wikipedia.org/wiki/Protect_America_Act_of_2007
  4. Foreign Intelligence Surveillance Act of 1978 Amendments Act of 2008, http://en.wikipedia.org/wiki/FISA_Amendments_Act_of_2008
  5. National Security Agency, http://en.wikipedia.org/wiki/National_Security_Agency
  6. PRISM (surveillance program), http://en.wikipedia.org/wiki/PRISM_%28surveillance_program%29