Wednesday, March 23, 2011

More laziness with the XBMC Remote Android App

The XBMC android app is great. I mean really really great. It might just be the best android app on my shiny new Atrix. There is/was one problem though. While the wake on LAN properly wakes my box up, the app has no suspend feature.

Hmm... eerily similar to the situation I ran into a few weeks ago. Luckily the app is GPL and I can have a go at fixing things.

XBMC has a secure auth http port exposed and a second unauthed raw command port for LAN only use. The patch below adds a suspend function that sends json to the raw port, and adds a button on the home screen to call the new function. For now this is just a simple get it done hack (hardcoded hostname/port, not following the code style/convention), but it would be cool to build a nice full featured "Shutdown" menu that enables exit, shutdown, suspend, etc. functionality.

Maybe later. Need sleep now... Self.Suspend()


$ svn di src/org/xbmc/android/remote/presentation/controller/HomeController.java
Index: src/org/xbmc/android/remote/presentation/controller/HomeController.java
===================================================================
--- src/org/xbmc/android/remote/presentation/controller/HomeController.java (revision 759)
+++ src/org/xbmc/android/remote/presentation/controller/HomeController.java (working copy)
@@ -21,6 +21,11 @@

package org.xbmc.android.remote.presentation.controller;

+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;
@@ -103,8 +108,8 @@
private static final int HOME_ACTION_RECONNECT = 5;
private static final int HOME_ACTION_WOL = 6;
private static final int HOME_ACTION_TVSHOWS = 7;
+ private static final int HOME_ACTION_SUSPEND = 8;

-
private IInfoManager mInfoManager;

private static final String TAG = "HomeController";
@@ -229,6 +234,7 @@
prefs.registerOnSharedPreferenceChangeListener(this);
homeItems.add(new HomeItem(HOME_ACTION_NOWPLAYING, R.drawable.icon_home_playing, "Now Playing", "See what's"));
homeItems.add(remote);
+ homeItems.add(new HomeItem(HOME_ACTION_SUSPEND, R.drawable.icon_home_power, "Suspend", "Invoke"));

final ArrayList offlineItems = new ArrayList();
offlineItems.add(remote);
@@ -310,6 +316,9 @@
mWolCounter.start();
}
break;
+ case HOME_ACTION_SUSPEND:
+ doSuspend();
+ break;
}
if (intent != null) {
mActivity.startActivity(intent);
@@ -318,6 +327,18 @@
};
}

+ private void doSuspend() {
+ try {
+ final Socket mySocket = new Socket("myth.lan", 9090);
+ final PrintWriter out = new PrintWriter(mySocket.getOutputStream(), true);
+ out.println("{\"jsonrpc\": \"2.0\", \"method\": \"System.Suspend\", \"id\": \"1\"}'jsonrpc': \"2.0\", 'method': \"VideoLibrary.ScanForContent\", 'id': \"1\"");
+ out.close();
+ mySocket.close();
+ } catch (IOException e) {
+ }
+}
+
+
public void update(Observable observable, Object data) {
if (data instanceof BroadcastListener.Event) {
BroadcastListener.Event event = (BroadcastListener.Event)data;

12 Comments:

At December 31, 2021 at 10:56 PM , Blogger unknown said...

Thankyou for sharing.
regards
Universal remote codes

 
At January 1, 2022 at 12:28 AM , Blogger unknown said...

visit eagleapk and download gloud games mod apk for free. you can also download other mod apks and games

 
At January 1, 2022 at 1:06 AM , Blogger unknown said...

visit our website fromscratchmag and read guides online and magazines

 
At January 3, 2022 at 6:38 AM , Blogger unknown said...

visit site and download letspush plugin. Web Push Notification plugin for Wordpress, Woocommerece and BuddyPress.

 
At January 3, 2022 at 6:39 AM , Blogger unknown said...

Free download ThopTV Pro APK file latest version v45.9.0 for Android and watch live TV channels, movies, series, radio, TV shows

 
At January 3, 2022 at 6:39 AM , Blogger unknown said...

Thankyou for your kind information.
regards
dearlotterysambad

 
At February 6, 2022 at 7:57 AM , Blogger unknown said...

thanks for your kind information. visit our blog and check guide of best golf grips

 
At May 14, 2022 at 1:16 PM , Blogger unknown said...

Thanks for sharing. visit our website and get universal remote codes for sanyo tv with Instructions

 
At May 21, 2022 at 3:38 PM , Blogger unknown said...

MacBook Air is a strong computer and can play several games without damaging any hardware or software. However, it should only be used for casual gaming and not excessive gaming. If you intend to spend the whole day playing video games, you should not use your MacBook Air.

 
At May 22, 2022 at 12:21 AM , Blogger clickonwebsite741♡ said...

you have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site
바카라사이트
토토

 
At May 29, 2022 at 11:03 AM , Blogger unknown said...

Are you thinking about Assisted Living Costs?

It can be paid up front or prorated monthly. It usually runs between $1,000 and $5,000. What should you look for in a contract? Pricing is usually broken down into rent and services. check more details about Assisted living Seattle

 
At February 8, 2023 at 6:18 PM , Blogger Ryan Axel said...

Wow!
How To Get Girls To Chase you

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home