Yet Another Blog

March 2, 2015

Connecting OnePlus One to GoPro wifi

Filed under: Android, gadgets — Tags: , , , , , , , , — guilleml @ 11:31 am

When I tried to connect my OnePlus One to my GoPro Hero 2 Wifi Bacpac I had a problem, the phone did keep waiting for dhcp to get al ip address so wifi connection didn’t pass “establishing connection” step.

What I did was connect to the phone via adb:

$adb shell

Once I had a terminal I searched in the log messages from dhcpcd to see what was happening:

$logcat -d | grep dhc

What I saw was:

I/dhcpcd ( 4957): version 5.5.6 starting
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
I/dhcpcd ( 4957): wlan0: broadcasting for a lease
I/dhcpcd ( 4957): wlan0: offered 10.5.5.109 from 10.5.5.9
W/dhcpcd ( 4957): wlan0: NAK: via 10.5.5.9
E/dhcpcd ( 4957): timed out
D/NetUtils( 772): dhcp_do_request failed : wlan0 (new)

I was receiving an ip but it wasn’t being set correctly, so I set a static IP in wifi configuration, as the image shows. I used the ip address the gopro was broadcasting 10.5.5.109.

Screenshot_2015-03-02-12-25-18

After that, the phone connects fine to the gopro and gopro app works 100% fine.

Advertisements

January 21, 2015

Asking for root in your Android app

Filed under: Android, computer, Java, Software — Tags: , , , , , — guilleml @ 12:34 pm

If your app needs root permissions to execute any command, you can do this using something like:


Process p;
try {
   p = Runtime.getRuntime().exec("su");
   DataOutputStream os = getRootSession(p);
   os.writeBytes("any command you want\n");
   os.flush();
} catch (IOException e1) {
   Log.d(MainActivity.class.getName(), "Error: " + e1.getMessage());
}

After running Runtime.getRuntime().exec(“su”) a dialog will appear to ask for permissions so the user can accept it.
What happens if you’re writing a service that will need root access anytime, even if the screen is off? The user won’t be able to accept the dialog so the app will fail.

To solve this you can do your app to ask for root permissions when it runs so, if the user accepts forever, the app will be able to run normally without asking the user anytime.
I know it’s better the user knows when an app is doing something as root but there are cases where you need to do this, for example, I’m writing an app that will disable charging for a phone when
the battery is charget at 100% in order to avoid microcharges. If you let the phone charging at night you won’t be there to disconnect the phone when it gets to 100% so this app monitors battery charge level and will use root permissions when the battery is 100%.

What I’ve done is to create an initial activiy to ask for permissions:

AskingRootActivity.java

public class AskingRootActivity extends ActionBarActivity {
private static final String TAG = AskingRootActivity.class.getName();

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_asking_root);
}
private void nextScreen(){
   Intent intent = new Intent(getApplicationContext(), NextActivity.class);
   startActivity(intent);
}

public void checkRoot(View v) {
   Process p;
   try {
      p = Runtime.getRuntime().exec("su");
      DataOutputStream os = new DataOutputStream(p.getOutputStream());
      os.writeBytes("ls /data\n");
      os.writeBytes("exit\n");
      os.flush();
      try {
         p.waitFor();
         if (p.exitValue() != 1) {/
         nextScreen();
         Log.d(TAG, "success getting root");
      }
      else {
         TextView tv = (TextView) findViewById(R.id.actionMsg);
         tv.setText(R.string.root_error);
         Log.d(TAG, "failing getting root");
      }
   } catch (InterruptedException e) {
      Log.d(TAG, "failing getting root");
}
} catch (IOException e) {
   Log.d(TAG, "failing getting root");
}
}
}

When the user clicks on the button, the app will try to get a root session so a dialog asking for root will appear.

After the user accepts or denies it, we try to do something we can only do as root, like listing files in /data directory. If the command runs succesfully, we navigate to the next screen/activity/logic/whatever, if not, we can show an error or finish the app.
As the app won’t do anything untill the user accepts or denies it, we can be sure when the app gets to the point when it needs root access, it will have it, at least if the user didn’t set a timeout for the permission.

activity_asking_root.xml

<RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot; android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot; android:paddingLeft=&quot;@dimen/activity_horizontal_margin&quot;
    android:paddingRight=&quot;@dimen/activity_horizontal_margin&quot;
    android:paddingTop=&quot;@dimen/activity_vertical_margin&quot;
    android:paddingBottom=&quot;@dimen/activity_vertical_margin&quot;
    tools:context=&quot;es.guille.sample.root.activities.AskingRootActivity&quot;>

    <TextView
        android:id=&quot;@+id/actionMsg&quot;
        android:text=&quot;@string/asking_root&quot; 
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; />

    <Button
        android:id=&quot;@+id/nextbtn&quot;
        android:onClick=&quot;checkRoot&quot;
        android:text=&quot;@string/ask_for_root&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_below=&quot;@id/actionMsg&quot;/>

</RelativeLayout>

This layout only defines an info message and a button to ask for root permissions.

May 30, 2014

Tuning Android Disk Encryption Feature

Filed under: Android, Security, Software — Tags: , , , , — guilleml @ 3:04 pm

I use my phone, like most of you, as my personal assistant so it carries all kind of information regarding banks, passwords, services, purchases, friends, photos, etc. Most of this information is private and I am very concerned about what would happen if someone gain access to this package of private information. Probably they would only want the hardware, but let’s be honest, if I couldn’t keep myself from taking a look to a lost phone and I know it can be done, no matter what password are you using, I expect anyone would do the same and they might have other intentions, as stealing passwords.

I was looking for a way to avoid this if my phone is stolen or lost. Of course I use cerberus but I need a way to really be sure no one can extract my information. Of course I’m not thinking in NSA or USA Gov as we all know they already have access to all of this.

Like linux, Android support crypted filesystems natively. http://www.saout.de/misc/dm-crypt/ is used in order to crypt, decrypt and manage the volume.

Android encryption feature will crypt all user data in order to avoid anyone to access your storage unit without a password.

It’s important to note that if you want to disable this feature you’ll need to reset your phone and restore all your data.

System Performance

In a nexus4 I haven’t noticed any performance impact but when installing apps. Installing apps is a little slower process but in the general use the interface, apps loading and use is unnoticeable.

How to Enable Android Disk Encryption Feature

You can enabled Android disk encryption feature under Security settings.

Screenshot_2014-05-26-13-41-05

This process needs pin screen lock so it will ask you to set a pin. You cannot use face recognition unlock or leave unlocked the phone.

This pin will be used to crypt the password that will be used to crypt all the volume. Google decided so in order to avoid users to remember several passwords just to boot and unlock their phones, the problem is that a 4 digits password is quite easy to break using brute force so we’ll see how to change this password to improve security.

Once you’ve selected the encryption feature and configured the password the system will reboot itself and begin the crypting process. This process may be long, so be sure to be able to let the phone working and connected to the AC charger for an hour or so.

When completed, the phone will ask for the password when booting, when it asks for it, type your pin code previously selected.

Install Cryptfs Password app from the Play Store to help you to change the password. You’ll need to be root so this process can be done.

Screenshot_2014-05-30-16-46-12

Just introduce your pin and your new safe long password using alphanumeric characters and symbols, this way you’ll have a secure password to mount the crypted phone storage memory and a 4 digits pin to unlock the screen making a brute force attack much more difficult to carry out.

With this, not so popular, feature you can be sure your data won’t be stolen if you lose your phone.

I found information about this process and link to the app from nelenkov’s blog.

August 26, 2011

Freshman with an iPad

Filed under: Android, ios, Software — Tags: , , , , , — guilleml @ 10:50 pm

I recently got an iPad, this is my first iOS device so I’m going to write my firsts impressions with this device and this system.

I must say I’m not an Apple fanboy and I have quite experience with Android (1.5-2.3).

First impressions:
  • It’s heavy, heavier than I imagined but it can be held on one hand easily.
  • Build quality seems very good.
  • Touch screen sensitivity is amazing.
  • It’s fast, very fast, shifting screen, opening and closing apps, web browsing…FAST
Needless to say I’m used to the weight already, I really like the smoothness and speed of iOS on the iPad, I don’t know if it’s so fast on iPhone.
After configuring accounts, wifi, etc…first thing was to install apps from the App Store, I used iTunes on a PC at first, now I use the App Store iPad application.
  • First thing I noted on the Apple App Store is that there are very little user comments and punctuations, I really find these useful since I used them on Android Market to know if the app is what I’m looking for.
  • Maybe there is but I haven’t found it yet, I would like to have a method to get a refund for apps, I may want to try them to know if they’re useful or I like them, if not I would like to uninstall them and get my money back since there is little user feedback.
  • Autocompletion on the search box could be nicer if it includes other users searches, not only apps names.
First apps I installed:
  • Google Search:
    Well…you get a link to google apps, they run on Safari so it’s like browsing Google Apps. You have a push Gmail notifier that will open your inbox in Safari.
    I guess I was hoping for something more, Google apps on Android are a real beauty.
  • IM+:
    An IM client, I have used it with Gtalk, it works fine most of the time.
    I got lot of FC (Force Close) at first, after an update it seems quite stable but I don’t like very much the interface.
    Here I noted how the notifications on iOS suck, I will talk about this later on this post.
    Now it works fine, when I’m browsing and someone talks to me, I change to IM+ app and I have to wait some seconds until the new messages are shown on the conversation window, it bothers me when I’m browsing and chatting because I can’t have a fast conversation, iPad is fast, IM+ is not.
  • Angry birds: Nothing to say here, it works great, fast and nice graphics.
  • Dropbox: I like this app, not very integrated in system as Dropbox for Android is, but it works fine.
  • Evernote: Very nice, fast, no problem at all.
Multitasking and notifications
Multitasking works fine with IM applications, IM+ uses push but it still drains the battery.
You can double press the button to see all apps “loaded in memory” and keep the finger on one of them to kill them.
Notifications are a joke, at least what I’ve seen, come on, it’s 2011!! notifications show a popup message or a number on the app icon. So I have to take a look to my desktop to know what’s happening or I see my web browsing interrupted when someone talks to me.
I think iOS5 implements notifications like Android or WebOS…that’s nice, nice and late!
This is what I really don’t like about iOS user experience, they really need to redesign all the notifications and information system. I know GUIs Apple policy but I really hate notifications now.

March 22, 2011

Opera Mini 6 – First Impressions on Android

Filed under: Android, Software — Tags: , , , — guilleml @ 9:39 am

Opera Mini 6 was released today and I’m a big fan so I’ve already downloaded and I’ve been playing with it for a while.The update can be found on the market and on the opera website.

After installing you can notice the new look, the color now is black, an opera icon on the settings menu, not much, I think the interface was and is good.

Loading on Android is faster, much faster. With version 5.x everytime you change the focus, for example if someone talks to you on gtalk, you had to reload Opera which tooks a few seconds and a loading screen. Most of the time you lose the page you were in.

Now, in version 6, loading is near instantaneous, no more fear to use several apps at the same time even on my old G1.

Speed Dial is still there, loading web pages is as fast as version 5, I didn’t notice neither faster nor slower.

First change on browsing, you need double tap to zoom in, and double to zoom out, just like chrome for android. You can click links in the zoom out view, again just like the stock browser.

It’s a multitouch enabled browser so you can pinch zooming.

Another think I liked a lot is the posibility to hide the navigation and address bar but keeping the android status bar, so you will still be able to see incoming notifications while having a near-full screen browser, you can always open the menu and address bar by pressing the menu button. I really needed this on version 5, thank you Opera, good work.

On the menu is another button to share links through the android share menu, so you can choose between bluetooth, dropbox, evernote, gmail, sms, reader, twitter, whatsapp…or whatever social software you have installed. I used to copy the link and paste it on a new mail, this is easier and faster.

For the moment this is the differences I’ve notices at first view, I’m sure there will be more. If you like Opera browser I recommend you to try this version, if not, I recommend you to try it anyway, Opera Mini uses very little data traffic since web pages are processed and adapted in their servers, it uses much less power because less processing is needed and well…it is fast, the fastest I’ve ever tried on android.

Blog at WordPress.com.