Author Topic: ALEDxander - display unique LED patterns on incoming calls  (Read 6745 times)

jakfish

  • Sr. Member
  • ****
  • Posts: 394
    • View Profile
ALEDxander - display unique LED patterns on incoming calls
« Reply #15 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

graynada

  • Full Member
  • ***
  • Posts: 117
    • View Profile
ALEDxander - display unique LED patterns on incoming calls
« Reply #16 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

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