Merge "Added a method to include device name in advertisement data." into lmp-dev
diff --git a/Common/src/com/googlecode/android_scripting/facade/ApplicationManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/ApplicationManagerFacade.java
index e79f771..bc199d8 100644
--- a/Common/src/com/googlecode/android_scripting/facade/ApplicationManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/ApplicationManagerFacade.java
@@ -67,7 +67,7 @@
}
@Rpc(description = "Kill the specified app.")
- public Boolean mediaKill(@RpcParameter(name = "name") String name) {
+ public Boolean appKill(@RpcParameter(name = "name") String name) {
for (RunningAppProcessInfo info : mActivityManager.getRunningAppProcesses()) {
if (info.processName.contains(name)) {
Log.d("Killing " + info.processName);
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothAvrcpFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothAvrcpFacade.java
index 334ff51..f336b4f 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothAvrcpFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothAvrcpFacade.java
@@ -1,5 +1,7 @@
package com.googlecode.android_scripting.facade.bluetooth;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.List;
import android.app.Service;
@@ -10,6 +12,7 @@
import android.bluetooth.BluetoothUuid;
import android.os.ParcelUuid;
+import com.googlecode.android_scripting.Log;
import com.googlecode.android_scripting.facade.FacadeManager;
import com.googlecode.android_scripting.jsonrpc.RpcReceiver;
import com.googlecode.android_scripting.rpc.Rpc;
@@ -53,19 +56,41 @@
@Rpc(description = "Get all the devices connected through AVRCP.")
public List<BluetoothDevice> bluetoothAvrcpGetConnectedDevices() {
- while (!sIsAvrcpReady);
+ if (!sIsAvrcpReady) {
+ Log.d("AVRCP profile is not ready.");
+ return null;
+ }
return sAvrcpProfile.getConnectedDevices();
}
+ @Rpc(description = "Close AVRCP connection.")
+ public void bluetoothAvrcpDisconnect() throws NoSuchMethodException,
+ IllegalAccessException,
+ IllegalArgumentException,
+ InvocationTargetException {
+ if (!sIsAvrcpReady) {
+ Log.d("AVRCP profile is not ready.");
+ return;
+ }
+ Method m = sAvrcpProfile.getClass().getMethod("close");
+ m.invoke(sAvrcpProfile);
+ }
+
@Rpc(description = "Send AVRPC passthrough command.")
public void bluetoothAvrcpSendPassThroughCmd(
- @RpcParameter(name = "deviceID", description = "Name or MAC address of a bluetooth device.")
+ @RpcParameter(name = "deviceID",
+ description = "Name or MAC address of a bluetooth device.")
String deviceID,
@RpcParameter(name = "keyCode")
Integer keyCode,
@RpcParameter(name = "keyState")
Integer keyState) throws Exception {
- BluetoothDevice mDevice = BluetoothFacade.getDevice(sAvrcpProfile.getConnectedDevices(), deviceID);
+ if (!sIsAvrcpReady) {
+ Log.d("AVRCP profile is not ready.");
+ return;
+ }
+ BluetoothDevice mDevice = BluetoothFacade.getDevice(sAvrcpProfile.getConnectedDevices(),
+ deviceID);
sAvrcpProfile.sendPassThroughCmd(mDevice, keyCode, keyState);
}
diff --git a/Common/src/com/googlecode/android_scripting/facade/media/MediaPlayerFacade.java b/Common/src/com/googlecode/android_scripting/facade/media/MediaPlayerFacade.java
index 0b7fafa..b307925 100644
--- a/Common/src/com/googlecode/android_scripting/facade/media/MediaPlayerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/media/MediaPlayerFacade.java
@@ -160,6 +160,13 @@
return !mediaIsPlaying(tag) && player.getCurrentPosition() == 0;
}
+ @Rpc(description = "Stop all players.")
+ public synchronized void mediaPlayStopAll() {
+ for (MediaPlayer p : mPlayers.values()) {
+ p.stop();
+ }
+ }
+
@Rpc(description = "Seek To Position", returns = "New Position (in ms)")
public synchronized int mediaPlaySeek(@RpcParameter(name = "msec",
description = "Position in millseconds")
diff --git a/Common/src/com/googlecode/android_scripting/facade/media/MediaScannerFacade.java b/Common/src/com/googlecode/android_scripting/facade/media/MediaScannerFacade.java
index 5097692..636cecd 100644
--- a/Common/src/com/googlecode/android_scripting/facade/media/MediaScannerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/media/MediaScannerFacade.java
@@ -1,11 +1,17 @@
package com.googlecode.android_scripting.facade.media;
import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.media.MediaScanner;
import android.net.Uri;
+import android.os.Bundle;
import android.os.Environment;
+import com.googlecode.android_scripting.Log;
+import com.googlecode.android_scripting.facade.EventFacade;
import com.googlecode.android_scripting.facade.FacadeManager;
import com.googlecode.android_scripting.jsonrpc.RpcReceiver;
import com.googlecode.android_scripting.rpc.Rpc;
@@ -18,17 +24,36 @@
private final Service mService;
private final MediaScanner mScanService;
+ private final EventFacade mEventFacade;
+ private final MediaScannerReceiver mReceiver;
public MediaScannerFacade(FacadeManager manager) {
super(manager);
mService = manager.getService();
mScanService = new MediaScanner(mService);
+ mEventFacade = manager.getReceiver(EventFacade.class);
+ mReceiver = new MediaScannerReceiver();
+ }
+
+ public class MediaScannerReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if(action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
+ Log.d("Scan finished, posting event.");
+ mEventFacade.postEvent("MediaScanFinished", new Bundle());
+ mService.unregisterReceiver(mReceiver);
+ }
+ }
}
@Rpc(description = "Scan external storage for media files.")
public void mediaScanForFiles() {
mService.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
+ mService.registerReceiver(mReceiver,
+ new IntentFilter(Intent.ACTION_MEDIA_SCANNER_FINISHED));
}
@Rpc(description = "Scan for a media file.")
diff --git a/Common/src/com/googlecode/android_scripting/facade/media/MediaSessionFacade.java b/Common/src/com/googlecode/android_scripting/facade/media/MediaSessionFacade.java
index 0c08495..9200910 100644
--- a/Common/src/com/googlecode/android_scripting/facade/media/MediaSessionFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/media/MediaSessionFacade.java
@@ -5,11 +5,9 @@
import java.util.List;
import java.util.concurrent.Callable;
-import android.app.ActivityManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.media.session.MediaSessionInfo;
diff --git a/ScriptingLayerForAndroid/AndroidManifest.xml b/ScriptingLayerForAndroid/AndroidManifest.xml
index 6c81297..9165b67 100644
--- a/ScriptingLayerForAndroid/AndroidManifest.xml
+++ b/ScriptingLayerForAndroid/AndroidManifest.xml
@@ -15,6 +15,7 @@
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />