OESF Portables Forum

Model Specific Forums => Gemini PDA => Gemini PDA - Android => Topic started by: ali1234 on May 19, 2018, 09:10:08 am

Title: ALEDxander - display unique LED patterns on incoming calls
Post by: ali1234 on May 19, 2018, 09:10:08 am
Hello,

I made an Android app to display unique LED patterns when you receive an incoming call. The patterns are generated by turning the phone number into an integer, and then lighting up the LEDs according to the low 15 bits (approx 5 digits). This means each number should display a fairly unique pattern.

Google Play: https://play.google.com/store/apps/details?...z.al.aledxander (https://play.google.com/store/apps/details?id=com.robotfuzz.al.aledxander)

The source code is here: https://github.com/ali1234/ALEDxander (https://github.com/ali1234/ALEDxander)

Github release page (APK): Releases (https://github.com/ali1234/ALEDxander/releases)

Shall I try to upload this to the Google app store?
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: GeorgeG on May 19, 2018, 11:29:45 am
Yes! Please do!
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: Sunyavadin on May 19, 2018, 07:45:04 pm
An apk would also be appreciated for those of us whose first action on getting a new android device is to delete play store.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: ali1234 on May 19, 2018, 08:11:20 pm
Quote from: Sunyavadin
An apk would also be appreciated for those of us whose first action on getting a new android device is to delete play store.

The APK is on the Github releases page.

It should be on the play store in a couple of days if it passes review.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: a1astair on May 19, 2018, 11:36:14 pm
Quote from: ali1234
Quote from: Sunyavadin
An apk would also be appreciated for those of us whose first action on getting a new android device is to delete play store.

The APK is on the Github releases page.

It should be on the play store in a couple of days if it passes review.

Great work! Shame Planet cannot get their app working yet. Why don't they publish the source code and get somebody else to work on it?
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: ali1234 on May 20, 2018, 01:15:30 am
Quote from: a1astair
Great work! Shame Planet cannot get their app working yet. Why don't they publish the source code and get somebody else to work on it?

The LEDs use a non-standard API that is not available in the standard Android SDK, so you would not be able to compile LEDison even if you had the source code.

Luckily Java has reflection, so it is not a problem for third-party utilities.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: Isaac on May 20, 2018, 10:37:22 am
This is great, thanks for releasing!
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: Ifanafi on May 20, 2018, 01:02:41 pm
Indulge my ignorance about this thread.

I gather the Gemini's LEDs are meant for eventual configuration to alert one to, say a phone call or text message and whatever.

Currently that functionality is in limbo waiting on PC to complete post-deliveries to backers.

What do you mean by "Luckily Java has reflection, so it is not a problem for third-party utilities."?

Have you made a work-around to get the limbo LEDs functioning as intended?

Thanks.

Ifanafi


Quote from: ali1234
Quote from: a1astair
Great work! Shame Planet cannot get their app working yet. Why don't they publish the source code and get somebody else to work on it?

The LEDs use a non-standard API that is not available in the standard Android SDK, so you would not be able to compile LEDison even if you had the source code.

Luckily Java has reflection, so it is not a problem for third-party utilities.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: Sunyavadin on May 20, 2018, 03:51:25 pm
Alas, I installed it, authorised it, and then tried to take a call, and every time I do this I get a message upon receiving the call that "aledxander has stopped working". No lights, no nothing.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: ali1234 on May 20, 2018, 07:09:30 pm
Quote from: Sunyavadin
Alas, I installed it, authorised it, and then tried to take a call, and every time I do this I get a message upon receiving the call that "aledxander has stopped working". No lights, no nothing.

Was it an unknown number? I don't know what parseInt does if you give it an empty string.

ADB logs would be helpful.

edit: I have uploaded a new release on github which should not crash on unknown numbers. It won't display any pattern for them as they are treated as 0.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: ali1234 on May 20, 2018, 07:23:19 pm
Quote from: Ifanafi
Indulge my ignorance about this thread.

I gather the Gemini's LEDs are meant for eventual configuration to alert one to, say a phone call or text message and whatever.

Currently that functionality is in limbo waiting on PC to complete post-deliveries to backers.

What do you mean by "Luckily Java has reflection, so it is not a problem for third-party utilities."?

Have you made a work-around to get the limbo LEDs functioning as intended?

Thanks.

Ifanafi

When you build an Android app you have to use the Android API. For example the Notification Manager API is documented here: https://developer.android.com/reference/and...ficationManager (https://developer.android.com/reference/android/app/NotificationManager)

When you download the Android SDK it includes a list of every API call. If you try to use a method which is not in the API, your app will not compile.

What Planet have done to make the LEDs work is change the Android Notification manager and add a new method called openLed. You will not find that method in the above documentation. In LEDison they call it like a normal API method:

[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
NotificationManager nm = context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.openLed(led, r, g, b, 0)
[/div]

If you try to compile that code with the normal Android SDK it will just generate an error because it does not know about the openLed method.

However, Java has something called reflection, which means that code can inspect itself at run time. This means you can get a list of methods on an object dynamically. We can ask the Notification Manager for the openLed function at run time, without needing the SDK to be aware of it. The following example is equivalent to the above except it will compile in the standard SDK:

[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
NotificationManager nm = context.getSystemService(Context.NOTIFICATION_SERVICE);
Method method = nm.getClass().getMethod("openLed", int.class, int.class, int.class, int.class, int.class);
method.invoke(nm, led, r, g, b, 0);
[/div]

So using reflection we can call non-standard Planet API additions without needing to have access to their patched version of the SDK.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: Sunyavadin on May 20, 2018, 09:57:46 pm
The call wasn't an unknown number, it was my partner's phone which I was making use of for testing purposes. The most commonly called of my contacts.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: ali1234 on May 21, 2018, 06:05:27 pm
Quote from: Sunyavadin
The call wasn't an unknown number, it was my partner's phone which I was making use of for testing purposes. The most commonly called of my contacts.

Found the problem. Phone numbers that start with 07 or 08 are numerically larger than a Java 32 bit int.

I have released a fix on Github and the Google PLay internal test channel.

I don't think there are any more bugs so I have published it to the release channel on Google Play, however this will take "a few hours" (assuming it passes).
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: jornada720 on May 21, 2018, 09:31:46 pm
Quote from: ali1234
Quote from: Sunyavadin
The call wasn't an unknown number, it was my partner's phone which I was making use of for testing purposes. The most commonly called of my contacts.

Found the problem. Phone numbers that start with 07 or 08 are numerically larger than a Java 32 bit int.

I have released a fix on Github and the Google PLay internal test channel.

I don't think there are any more bugs so I have published it to the release channel on Google Play, however this will take "a few hours" (assuming it passes).

You can also publish your app on the F-Droid store as well for additional distribution.
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: Sunyavadin on June 04, 2018, 03:58:32 pm
Just tested it with the new version and it's working great. Thanks!
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: jakfish on June 07, 2018, 09:30:09 am
I have the apk downloaded and waiting for my Gemini's arrival.

Wonderful work, thank you.

Jake
Title: ALEDxander - display unique LED patterns on incoming calls
Post by: graynada on June 22, 2018, 07:32:46 am
Quote from: ali1234
Quote from: Ifanafi
Indulge my ignorance about this thread.

I gather the Gemini's LEDs are meant for eventual configuration to alert one to, say a phone call or text message and whatever.

Currently that functionality is in limbo waiting on PC to complete post-deliveries to backers.

What do you mean by "Luckily Java has reflection, so it is not a problem for third-party utilities."?

Have you made a work-around to get the limbo LEDs functioning as intended?

Thanks.

Ifanafi

When you build an Android app you have to use the Android API. For example the Notification Manager API is documented here: https://developer.android.com/reference/and...ficationManager (https://developer.android.com/reference/android/app/NotificationManager)

When you download the Android SDK it includes a list of every API call. If you try to use a method which is not in the API, your app will not compile.

What Planet have done to make the LEDs work is change the Android Notification manager and add a new method called openLed. You will not find that method in the above documentation. In LEDison they call it like a normal API method:

[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
NotificationManager nm = context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.openLed(led, r, g, b, 0)
[/div]

If you try to compile that code with the normal Android SDK it will just generate an error because it does not know about the openLed method.

However, Java has something called reflection, which means that code can inspect itself at run time. This means you can get a list of methods on an object dynamically. We can ask the Notification Manager for the openLed function at run time, without needing the SDK to be aware of it. The following example is equivalent to the above except it will compile in the standard SDK:

[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
NotificationManager nm = context.getSystemService(Context.NOTIFICATION_SERVICE);
Method method = nm.getClass().getMethod("openLed", int.class, int.class, int.class, int.class, int.class);
method.invoke(nm, led, r, g, b, 0);
[/div]

So using reflection we can call non-standard Planet API additions without needing to have access to their patched version of the SDK.

Inspired by your good work and guidance here, thanks, I've been having a play around with my own notification app.  Do you have any docs/reference for the openLed method?  Not too difficult guessing suggests first argument is the LED number (numbered 1-5 looking at your code) and rgb are the decimals of the hex values.  Is the final argument always a 0?

Thanks in advance