Pages

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:

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

    ReplyDelete
  2. visit our website fromscratchmag and read guides online and magazines

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

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

    ReplyDelete
  5. Thankyou for your kind information.
    regards
    dearlotterysambad

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

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

    ReplyDelete
  8. 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.

    ReplyDelete
  9. 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
    바카라사이트
    토토

    ReplyDelete
  10. 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

    ReplyDelete