Friday, 14 June 2013

Windows 7 - Attempting to Hibernate Results in Locking Instead


This post details how I fixed a problem with my laptop where attempting to hibernate the computer resulted in it locking instead.

This seems to be a reasonably uncommon problem; there are results on Google but there is no clear one-size-fits-all solution. This is largely due to there being multiple reasons this can occur. Whilst you may be more likely to see this problem if you dual boot Windows with another OS, I started seeing the issue after upgrading my laptop's hard drive.

The Problem

Every day, when finished with the laptop, I click the hibernate button, close the lid and place the laptop away in a drawer. Since upgrading my hard drive however, I've found that the next morning the laptop's battery is completely drained and prompts me like I've let the computer running. Tracking that down today, I discovered that when the hibernate button is pressed now, the screen goes blank for a few seconds before returning me to the lock screen. Still fully powered on, just locked.

Saturday, 4 May 2013

Z-Wave - Fixing the Inverted LED Issue on TKB On/Off Switch

On my TKB On/Off Socket, the blue LED turned on when the switch state was in the off position, and the blue LED turned off when the switch state was in the on position. This turns out to be configurable with the right tools. The following post describes how to configure to your preference.

This is probably the epitome of first world problems. I'm concerned that the socket, which I have the power to control over the internet and from my mobile, emits a blue light and I'd rather it didn't. I know, I know, get a life. However, the purpose of this particular socket for me was to have connected in the bedroom. This means this fairly bright LED would be on all night long, and actually would be on about 99% of the time. A problem worth fixing it seems.

Monday, 29 April 2013

Robolectric Error - Couldn't find value resource directory

Android development using Robolectric provides a powerful testing framework which runs on your desktop JVM instead of an Android device or emulator. This makes tests written using Robolectric run a lot faster than those written to run using Android Instrumentation.

However, when setting up Robolectric in IntelliJ, I recently received the following nastiness:

testExceptionThrownGivenNullHeadersInput(LocationHeaderParsingTest)  Time elapsed: 28.753 sec  <<< ERROR!
java.lang.RuntimeException: java.lang.RuntimeException: Couldn't find value resource directory: C:\Programming\Workspace\ .... \.\res\values
at com.xtremelabs.robolectric.res.ResourceLoader.getValueResourceDir(
at com.xtremelabs.robolectric.res.ResourceLoader.init(
at com.xtremelabs.robolectric.res.ResourceLoader.setLayoutQualifierSearchPath(
at com.xtremelabs.robolectric.RobolectricTestRunner.setupApplicationState(
at com.xtremelabs.robolectric.RobolectricTestRunner.internalBeforeTest(
at com.xtremelabs.robolectric.RobolectricTestRunner.methodBlock(
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.ParentRunner$
at org.junit.runners.ParentRunner$1.schedule(
at org.junit.runners.ParentRunner.runChildren(
at org.junit.runners.ParentRunner.access$000(
at org.junit.runners.ParentRunner$2.evaluate(
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(
at org.apache.maven.surefire.booter.ForkedBooter.main(

My particular setup is as follows:

  1. IntelliJ
  2. Maven multi-module project:
    1. Parent-pom
      1. Android Application
      2. Android Test Project to test the Android Application
  3. Unit tests using the following frameworks
    1. Mockito for mocking 
    2. Robolectric 
    3. Robotium for auotmated UI testing
The problem here is that when creating my Android Test Project, I didn't see the need to create the res/values directory (as my tests didn't require any resources from here). However, the Robolectric framework does not work properly without that directory being present.

  1. Create an empty directory under the project root called res (if doesn't already exist)
  2. Create an empty directory in res called values
Your project structure should therefore look something like this:

     |-> application-myapp-android
     |-> application-myapp-android-test
               |-> res

That should fix your Couldn't find value resource directory issue.

Thursday, 24 January 2013

Setup Guide / Walkthrough of Tenvis JPT3815W 2013 IP Camera

UPDATE - 2014-06-30

I will leave the rest of this review intact for posterity, but please read this warning before purchasing. 

Given the seriousness of this vulnerability, I would strongly recommend against buying this camera, or any others from Tenvis. 

Not until the company can prove they know how to build secure products and care about their users.

Please read this warning very closely if you already own this model, or any Tenvis camera.

Tenvis JPT3815W 2013

The Camera

Tenvis are a Chinese manufacturer whose product line includes IP Cameras, such as the model JPT3815W 2013 featured in this setup guide. Available to purchase online, this serves the budget-end of the IP Camera market. In fact, this camera currently has a selling price of less than £40. Tenvis offer a Global User Experience Improvment Program, which offers a free camera in return for writing guides to help other users. This camera was received through such a program.

View on Amazon.

However, any opinions expressed about the camera (good and bad) are entirely my own.

I became a member of the improvement program when I reported a security vulnerability to the company. They responded by thanking me for my report, and informed me they would work to fix the vulnerability immediately.

Read on for the full setup guide and review.

Monday, 14 January 2013

Android Daydream Mode - Prevent Screen Burn

Daydream Mode - An Old Solution to an Old Problem

Daydream Mode not working for you?

After having problems with Android 4.2's new Daydream mode, I discovered the problem which was preventing the mode from ever starting. If that's why you're here, skip to the very bottom section entitled "Developers Beware - You Need More Sleep".

What is it all about anyway?

Got an Android 4.2 device? Have you tried the Daydream mode yet? It's basically a screensaver for your phone. It can display items like a clock, top stories from Currents or Flipboard, show a slideshow of your photo albums or even StumbleUpon for you; the last two seem to be wrought with potential dangers in my opinion, but hey, it's an option.

Is it a novelty? Partly. But there is a genuinely good reason for its existence; screen burn. You might have heard of this phenomenon in the world of TVs and monitors. Also known as ghosting. If an image is held on the screen for too long, without it moving or any other activity happening, that image can actually have lasting damage on the screen. The most common symptom of screen burn is the retention of some pixels or parts of an image long after that image should have disappeared, resulting in a ghostly silhouette of the pixels that were once there. Basically what happens to your pixels when they die and can't enter the afterlife. Seen the movie Ghost? It's great isn't it? Ghost is actually an extended metaphor and a warning about screen burn.[1]

Old CRT monitors, like the one pictured below, were bad for screen burn, and was one of the reasons early operating systems supported screen savers.

Ghosting on a CRT monitor

Whilst more modern LCD monitors were less susceptible to screen burn, plasma TVs and monitors also suffered. But what's all this to do with Android Daydream mode?

Unfortunately, modern screen technologies used on your smartphone might be susceptible to screen burn also. OLED screens, and AMOLED, can also be damaged with an image shown on screen for too long. This means your mobile screen might end up retaining the image made up by some pixels which are static and shown for long periods of time. Menu bars, soft key buttons and the likes, these are the kind of areas on the screen which change infrequently, and therefore may end up burning into the screen their spooky, ghostly presence long after you want them to.

Hence the introduction of Android's version of a screen saver; Daydream mode.

Acessing Daydream Mode

Access it by going to "Settings->Display->Daydream".

Daydream mode offers its services only when your phone is charging or in a dock. These options are accessed in the "WHEN TO DAYDREAM" section.

The Clock option is especially suited for those looking for a night time bed-side clock. It even has a "Night Mode" option allowing for the screen to be dimmed to avoid it beaming out too much light in the night.

Developers Beware - You Need More Sleep

What happens if you are in the position of having selected your Daydream options, plugged your phone in and docked it, but nothing ever happens? I discovered that a Developer setting might override your phone's ability to daydream.

Accessing Developer Options

In Android 4.2 (and presumably above), the developer options have been hidden from view by default. To enable that menu, enter the "Settings" section of your phone, and select "About phone" from the bottom. Tap on "Build number" seven times. No no, I'm not kidding. Tap seven times and you will be treated with a toast message informing you that "You are now a developer" which is nice. The developer menu will now be available under the standard "Settings" section of your phone.

Tap on "Build number" 7 times to enable Developer Mode

Disabling Stay Awake

Check your "Developer Options". "Stay awake" must be unchecked for Daydream to work.


[1] - Not really