Friday, July 2, 2010

iPhone 4 Reception Issue Blamed on Software Algorithm Issue

Today Apple posted an open letter on their website stating that the apparent reception issues people are seeing with the "Death Grip" are caused by a bad algorithm they used for setting the number of bars.  I am sure this will fix a majority of the issues people are seeing, but who knows.

Here is the code I recommend for iOS 4.0.1 to fix the bug in the method for returning the number of bars to show.
public int getNumberOfBarsToDisplay(int signalStrengthDecibels)
{
    //if(signalStrengthDecibels < -113)
    //{
    //    return 0;
    //}
    //else if(signalStrengthDecibels < -107)
    //{
    //    return 1;
    //}

    //else if(signalStrengthDecibels < -103)
    //{
    //    return 2;
    //}
    //else if(signalStrengthDecibels < -101)
    //{
     //   return 3;
    //}
    //else if(signalStrengthDecibels < -91)
    //{
    //    return 4;
    //}
    //else
    {
        // Fix bug that was caused by the Death Grip.
        // Always return 5 bars.
        return 5;
    }
}

Here is the source for the decibel breakdown from AppleInsider, here.

Rant Friday

I feel it is my duty to update on the current status of my MicroCell.  Status: Nothing has changed.  My account online continues to say "Activation Pending" and the little green 3G light continues to flash on the device.  I am guessing this will not get fixed by the end of the weekend.  It would be one thing if the device had a subtle design, but instead it is this giant white plastic upside down Y shaped thing.  It doesn't help that it has to sit next to the router and cable modem, which already sit in our kitchen and the 50 feet of cable total that Apple and the modem company thought people would need (we only need about 2 feet).  The worst part is paying $150 for something to get a signal on my phone and now I still have no service, but AT&T has my money.  Ahhhhh!!!

Now onto my friends at Apple.  I am going to write off this antenna thing for the time being as a lot of media hype and besides I don't currently get service in most cases anyway (see above), so it isn't a big deal for me.  However, I do have a new gripe with the fruit company. What is the point of having a store if you can't buy anything?  The two most showcased items in the Apple Store right now are the iPhone 4 and the iPad.  They probably have 30 of each for demonstration purposes, the problem is if you actually want to buy one, well frankly you can't.  Now I understand not being able to keep the iPhone 4 in stock, its only been out for a week, but the iPad as of tomorrow will have been out for three months. Ridiculous!!  Maybe I should sell my AAPL stock now before people realize the number of sales of the iPhone and iPad each day at least in the Apple Store in the Burlington Mall are 0.0.  Maybe they should march the neglected Macintosh computers out into the spotlight and get people to buy some of those instead of just teasing people into liking a smartphone or tablet they can't even buy.  On the bright side maybe those people will be turned on to touch screen smartphones and go buy a Droid X on July 15th, leaving the next shipment of iPhone 4's all to me.  Until then I am sticking it out with this super slow iPhone 3G with iOS 4.

Thursday, July 1, 2010

Getting Flex and JBoss to use SSL

I have spent the last 7 or so hours at work trying to configure our Flex client to connect to our JBoss 4.2.3 server using SSL.

Now that I have figured it out here are the steps to make it work. The assumption is you have JBoss 4.2.3 installed and are able to access a web app on port 8080 over plain old http.

Types of SSL
JBoss supports at least two implementations of SSL:
Java Secure Socket Extension (JSSE) which uses the Java Runtime.
Apache Portable Runtime (APR) which uses OpenSSL.

Based on my version I am going to go out on a limb and say by default JBoss 4.2.3 uses APR out of the box.  You can verify this by looking in the server.xml found in your JBoss installation at /server/default/deploy/jboss-web.deployer/server.xml. At the very top of the file is a Listener tag for the AprLifecycleListener, which by default has the SSLEngine turned on. Below are the instructions for installing using both APR and JSSE.



APR SSL Setup Instructions
Generating a Private Key and Certificate
In order for all this SSL craziness to work you need to generate a private key and a certificate.  These can be generated using the OpenSSL command line tool.  All can be generated locally, but typically the certificate is generated by a Certificate Authority.  The following instructions show you how to create a self signed certificate. The private key and certificate will be kept in the /server/default/conf directory.

1. Open  a command line tool and navigate to /server/default/conf
2. Generate a private key: Execute openssl genrsa -des3 -out server.key 1024
3. Generate a certificate request: openssl req -new -key server.key -out server.csr
4. Generate a self signing certificate: openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
5. Voila you now have a private key and certificate in the conf directory called server.keystore

Configuring JBoss For SSL
The {jboss}/server/default/deploy/jboss-web.deployer/server.xml file now needs to be modified to connect on https.  This requires the addition of a Connector tag in the file specifying the port, keystore location and also the keystore password.  

1. Open {jboss}/server/default/deploy/jboss-web.deployer/server.xml in your favourite text editor.
2. By default the Connector for https is commented out (you can find it by searching for 8443)
3. Add a new Connector to the file:
<Connector port="8443" SSLEnabled="true"
    maxThreads="150" scheme="https" secure="true"
    SSLCertificateFile="${jboss.server.home.dir}/conf/casenet.crt" 
    SSLCertificateKeyFile="${jboss.server.home.dir}/conf/casenet.key"
    clientAuth="false" sslProtocol="TLSv1" />

4. You can modify the port as you like and also update the SSLCertificateFile and SSLCertificateKeyFile as is appropriate.
5. Save the file.


JSSE SSL Setup Instructions
Generating a KeyStore
In order for all this SSL craziness to work you need to generate a keystore for your server.  This keystore is created using the Java keytool executable.  The keystore will be kept in the /server/default/conf directory.

1. Open  a command line tool and navigate to /server/default/conf
2. Execute keytool -genkey -alias tomcat -keyalg RSA -keystore server.keystore
3. Enter '123456' as the password when prompted.
4. You will also be prompted to enter your name, organizational unit, organiation, city, state and country. Enter the appropriate values for you.
5. When prompted to enter the key password just hit enter to make it the same as the keystore password.
6. Voila you now have a key in the conf directory called server.keystore

Configuring JBoss For SSL
The {jboss}/server/default/deploy/jboss-web.deployer/server.xml file now needs to be modified to connect on https.  This requires the addition of a Connector tag in the file specifying the port, keystore location and also the keystore password.  In order to use JSSE we need to override the default protocol with org.apache.coyote.http11.Http11Protocol. This will cause it to override the APR SSL

1. Open {jboss}/server/default/deploy/jboss-web.deployer/server.xml in your favourite text editor.
2. By default the Connector for https is commented out (you can find it by searching for 8443)
3. Add a new Connector to the file:
<Connector port="8443" SSLEnabled="true"
protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" scheme="https" secure="true"
keystoreFile="${jboss.server.home.dir}/conf/server.keystore" keystorePass="123456" clientAuth="false" sslProtocol="TLS" />

4. You can modify the port as you like and also update the keystoreFile and keystorePass as is appropriate.
5. Save the file.




Verify Results for Either SSL
Now that you have created a keystore and also added a new connector you should be able to start up JBoss without errors. To verify you can now go to https://{server name}:{port}/{webapp}. You will be prompted to accept the certificate and once you accept the page should load.

Here are two very helpful sources: Steps for Building A Hello World Web App,  Apache Tomcat SSL How To, JBoss Community SSL Config, and How To Create a Self Signed Certificate

Updating the Flex Client
We use Granite and Gravity for transferring objects between the Flex client and the JBoss server.  All you need to do is update the services-config.xml Granite file.

Locate the channeldefinition tags and update them to use the secure channel classes and also update the URL to include https.
<channel-definition id="myApp-graniteamf" class="mx.messaging.channels.SecureAMFChannel">
<endpoint uri="https://localhost:8443/myApp/graniteamf/amf"
class="flex.messaging.endpoints.SecureAMFEndpoint" />
</channel-definition>

Wednesday, June 30, 2010

To iOS4 or Not To iOS4

A couple weeks ago I upgraded my iPhone 3G to the brand spanking new iOS4.  Of course the feature set gained by this is dramatically smaller than the full bevy of features on the iPhone 3GS or iPhone 4. I was mostly interested in folders, multiple exchange servers and also a unified inbox, so I decided to take the leap and boy have I paid for it.  The phone is nearly unusable now, think of it as running Windows 7 on a Windows 95 era machine.  What formerly was called the "Best iPod Ever", can barely even launch the iPod app in less than 15 seconds and once it is launched good luck getting it to not crash.  The Maps app opens and then locks up for several seconds before you can actually pan and zoom. Of course there is a short term solution for the problem which involves restarting the phone a couple times a day.

This would all be okay if I could actually find a store with the iPhone 4 in stock, but who knows when I will be able to find one.  I am now left with the decision of dealing with this slowness and leveraging the iPad as often as possible OR following some undocumented steps to revert my phone to iPhone 3.1.1.  Are the few features I get with the iOS 4 worth the trouble?  At the current time I am leaning towards NO and will probably do the downgrade soon.  If anybody else is having a similar problem here is a site with the Steps to Downgrade an iPhone's firmware.

Tuesday, June 29, 2010

The AT&T 3G MicroCell Installation

Ever since I brought home the iPhone 3G back in 2008 I have been living with little to no service at my house. At first this seemed odd to me considering I could see a tower from my house, but apparently AT&T doesn't use that tower. Instead it appears the nearest tower is behind a hill or somewhere that makes me live in a dead spot.

Enter the 3G MicroCell. As I began researching ways to improve my service, I found some blog posts about how AT&T was testing mini cell towers that you could buy and hook up to your internet to make calls. Of course they weren't testing near me so I had to wait until yesterday when I found they were finally available in our area. I went to an AT&T store right after work, purchased the little guy for $149 and rushed home to get it all hooked up.

Here are the basic steps:
1. Log on to att.com and activate your MicroCell.
a. Entering the serial number.
b. Coming up with a clever name for your device.
c. Setting up a street address.
d. Giving specific phone numbers that can use the device.
2. Hook up the hardware
a. Plug in some internet.
b. Plug in some power.
c. Put it near a window so it can connect to GPS for E911.
d. Wait 90 minutes.

It all seemed simple enough right, wrong! I figured the online registration would be the easiest part, but of course I forgot my experiences of two weeks ago when I tried to pre-order an iPhone from AT&T. First of all the website asks you to log in constantly and always puts you back to the beginning of a "wizard"-like page flow. I logged in to activate the 3G MicroCell, verified my address, entered a clever name for the MicroCell and then submitted. After about two minutes giant red text appeared telling me my request timed out and I needed to try again later. I ate some dinner and "tried again later" only to receive the message again. As any user is likely to do I hit it a couple more times for good measure and it changed to some sort of confirmation message. Weird, especially since I didn't receive a text or email as I would expect. I assumed at this point all was good and hooked up the hardware. I came back after fifteen minutes and was happy to see the GPS had locked on (previously this had been my biggest concern). After 90 minutes I returned to see the 3G light was still flashing, so per the troubleshooting instructions I restarted everything and waiting. Thirty minutes later and the light was still flashing. Grrrrrr. I went to bed and left it running hoping I would come down Christmas morning style to a solid 3G light.

As one might expect from AT&T at this point it was not working and my iPhone still had only one bar. I went online and looked at my MicroCell's settings page and noticed that it said "Activation Pending". I wondered if this was completely related to the setup part on the web site or if it was something that would only get set to complete once the damn 3G light stopped flashing. Once I was at work I called AT&T and the guy on the phone claimed the entire network was down. Upon further investigation I think they are just bogged down with activation requests. Either way I can't mess with my router from here so it will have to wait until tonight when I waste yet another evening trying to figure this out.

The best part is going through all of this and paying all of that money just to get my phone to work like it should anyway.

Monday, June 28, 2010

iPad Review - One Month

Well I have had my iPad for almost a month and decided it was time to give a review. Before i start I will admit i am an Apple fanboy, but I am always quick to point out any flaws I see in Apple's products I.e flickering MacBook screen, cracked case on MacBook, slowness in iPhone. so rest assured you should get a relatively honest review out of me.

Now the biggest comment i typically get from laptop owners is "my laptop does that too, big deal." This is important, because Steve Jobs mentioned the key to the iPad succeeding is it being able to do a bunch of things a laptop or mobile phone can do, just doing them better. i will come back to this throughout the review, but first impressions are really more important.

After taking it out of the box I laughed at the one page mini instruction manual and fired it up. Right away it was better than expected, the size of the screen was great and it was very quick especially comprared to my iPhone 3G. I was tempted to just play around, but knew it would be best if I synced some stuff from iTunes. Synching was a breeze and I was even asked if I wanted to load from an iPhone backup. While syncing I did notice that the iPad wasn't charging and as I later found out this was true, it can only charge from the included adapter (allegedly if the iPad is sleeping while plugged into a laptop it will charge but i haven't tested this). The synch was about as fast as a usual iPhone sync. I only bought a 16GB model because i figured i would have my iPhone at all times and wouldn't need all of my music.

Once I was ready to go I quickly played around with the apps that came with it. First the updates to Mail and Calendar are great. They are both much more robust than the iPhone versions, but are so much more usable. The Photos app is also improved with some more multitouch functionality and also support for some of the native iPhoto concepts like faces, and places. The only other app that comes out of the box I really cared about was the iTunes app. It is a little easier to navigate and also supports creation and editing of playlists. Besides that it is a music player so i don't that one would expect more.

The most common app people want to see when I give a demo is the iBook app and usually they are pretty impressed. The readability on the backlit screen is great and the added features of a dictionary, font type and size control and bookmarks are really great additions. I will admit i haven't spent several hours in a row reading, so I don't know how it will effect eyes, but I did do some reading and really enjoyed being able to read hands free. I also went through the process of buying a book, the best part is the ability to preview a book. The sample I downloaded for a 350 page book was about 70 pages, which seemed very generous.

Oh I almost forgot about Safari. It was made a lot more usable in the new iPad version with support for a bookmarks bar and also more controls in general available at the top of the screen. Surfing the internet is a great experience and feels so much more natural than on a laptop. There is something to be said about tapping and pinching web pages on a 9 inch screen. When i bought the iPad I mostly intended to use it from the couch at night while watching tv. Basically whenever i was at home and looking things up on the Internet with my iPhone would be a time i would use the iPad. It turns out I did use it for those occasions and much more, it seems the only time i use my MacBook now is when i need to import photos or do some iPhone app development.

Okay I think that takes care of the basic set of apps. Now as with the iPhone you can download apps from the App Store (that is actually where I got iBooks). Going into this I heard about support for iPhone apps on the iPad and thought I would just use those apps on the iPad. Initially I loaded several apps I had come to love on my iPhone on the iPad, but once loading them you can either see them in a 1X size which is exactly the size of an iPhone or you can tap the 2X and see them in double the original size. Unfortunately, most apps just look distorted and the graphics get very 8-bit block like. A couple apps are okay, but I ended up removing most of the iPhone apps and went to the App Store in search of new apps. It is actually cool to see some of the apps that have been created so far and how they take advantage of the big screen. One of my favorites so far was Solitaire, which is great to play on the big screen.

So far it has all been rosy, but there are indeed some frustrations/annoyances/problems. First and foremost I think is the on screen keyboard. When held in the landscape orientation the keyboard is a really decent size with keys almost as large as on a standard apple keyboard. Unfortunately for the "touch typist" it takes a lot of practice to get good with the keyboard and typing anything longer than a couple paragraphs (like this review) isn't worth the trouble. Yes, the keyboard does inline corrections, but I find I am constantly deleting or moving the cursor back to a spelling error for correction. Also the keyboard in portrait mode is virtually unusable, it is too wide to type like on the iPhone, and the buttons are two narrow for a regular typing stance.

The screen is another annoyance for me, mostly because it gets messy very quickly. Unlike the iPhone though you can't just rub it on your pant leg and instead need to find a towel or sleeve to wipe off any oils you lathered the screen with. The other problem with the screen is that it is glossy, so it is almost unusable in direct sunlight, well unless you want to use it as a mirror. If you are able to sit in the shade and can sit with darkness around you then it is okay, but the reflection is still there.

One other important thing to mention is how important the Apple iPad case may be for the iPad. I had the good sense to buy the case when I got it so I can't say not having it is bad, but if you ever intend on typing on a table or other flat surface I think it would a pain without the case. Now I am not a huge fan of cases on Apple products, but I planned on using it at work in meetings and knew I would be putting it on a flat surface. I have also found it provides a few more options even when sitting on the couch.

So the big question: Does it do things better than a laptop?
Internet - Yes, great experience.
Book Reading - Yes, it is slightly wider than a book, but the brightness, availability of titles and hands free reading is great.
TV/Movies - Yes, I downloaded the ABC app and really enjoyed sitting on the couch watching Lost. There is less concern about battery life and it isn't hot on your lap like a laptop.
Music - The jury's out. Its not really practical for listening to music, but neither is a laptop.
Calendar - Yes, flipping through the calendar with the tap of a finger is great.
Mail - Yes, if you are just reading and not typing out super long emails.
Word Processing/ Note Taking - No, typing a ton of stuff isn't reasonable.

In general as long as the way you use an app isn't keyboard intensive, the smaller size and touch navigation of the iPad give it a leg up. Oh yeah and the lack of Flash Player is rubbish. Despite claims that the internet is full of Flash content, I only come across Flash content every once in a while and while somewhat annoying isn't a deal breaker.

Overall, I love the iPad. There is certainly room for improvement: front facing camera, multi-tasking for third party apps (coming this Fall). I only got the WiFi version because I already pay enough for internet and also plan on using it primarily at home and at work where I always have Wi-Fi.

Dynamic Spring Beans

Ever wonder how to dynamically change the class used for a Spring Bean at runtime without modifying your war file in JBoss? After lots of trial and error i put the two important pieces of this puzzle together. The first and probably most important part of the process is the use of a Static or instance bean factory. This handy little device allows for dynamic determination of a bean's class at startup time. The easiest thing to do is to create a static factory because it involves less beans. Now dynamically changing the bean at jboss startup time without changing the war took a little more research. To handle this it involves some JNDI bindings in the jboss-services.XML and the addition of a J2EE property bean in your spring file. The spring property bean loads the value from the jndi binding and then it can be passed to the bean factory. Voilà you can easily switch between implementations of an interface without a recompile and without changing your war file.