Merge "Add feature to serialize simple class objects."
diff --git a/BluetoothFacade/src/com/googlecode/android_scripting/facade/BluetoothFacade.java b/BluetoothFacade/src/com/googlecode/android_scripting/facade/BluetoothFacade.java
index 6f5a08d..f24b0b5 100644
--- a/BluetoothFacade/src/com/googlecode/android_scripting/facade/BluetoothFacade.java
+++ b/BluetoothFacade/src/com/googlecode/android_scripting/facade/BluetoothFacade.java
@@ -176,12 +176,14 @@
   @Rpc(description = "Requests that the device be discoverable for Bluetooth connections.")
   public void bluetoothMakeDiscoverable(
       @RpcParameter(name = "duration", description = "period of time, in seconds, during which the device should be discoverable") @RpcDefault("300") Integer duration) {
-    if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
-      Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
-      discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, duration);
-      // Use startActivityForResult to make this a synchronous call.
-      mAndroidFacade.startActivityForResult(discoverableIntent);
-    }
+    Log.d("Making discoverable for "+duration+" seconds.\n");
+    mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, duration);
+  }
+
+  @Rpc(description = "Requests that the device be not discoverable.")
+  public void bluetoothMakeUndiscoverable() {
+    Log.d("Making undiscoverable\n");
+    mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE);
   }
 
   @Rpc(description = "Sends ASCII characters over the currently open Bluetooth connection.")
diff --git a/Common/src/com/googlecode/android_scripting/facade/EventFacade.java b/Common/src/com/googlecode/android_scripting/facade/EventFacade.java
index 045e784..0eeda48 100644
--- a/Common/src/com/googlecode/android_scripting/facade/EventFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/EventFacade.java
@@ -164,15 +164,21 @@
     return events;

   }

 

-  @Rpc(description = "Blocks until an event with the supplied name occurs. The returned event is not removed from the buffer.", returns = "Map of event properties.")

+  @Rpc(description = "Blocks until an event with the supplied name occurs. Event is removed from the buffer if removeEvent is True.",

+      returns = "Map of event properties.")

   public Event eventWaitFor(

       @RpcParameter(name = "eventName") final String eventName,

+      @RpcParameter(name = "removeEvent") final Boolean removeEvent,

       @RpcParameter(name = "timeout", description = "the maximum time to wait (in ms)") @RpcOptional Integer timeout)

       throws InterruptedException {

+    Event result = null;

     synchronized (mEventQueue) { // First check to make sure it isn't already there

       for (Event event : mEventQueue) {

         if (event.getName().equals(eventName)) {

-          return event;

+          result = event;

+          if(removeEvent)

+            mEventQueue.remove(event);

+          return result;

         }

       }

     }

@@ -186,15 +192,18 @@
               futureEvent.set(event);

               removeEventObserver(this);

             }

+            if(removeEvent)

+              mEventQueue.remove(event);

           }

         }

       }

     });

     if (timeout != null) {

-      return futureEvent.get(timeout, TimeUnit.MILLISECONDS);

+      result = futureEvent.get(timeout, TimeUnit.MILLISECONDS);

     } else {

-      return futureEvent.get();

+      result = futureEvent.get();

     }

+    return result;

   }

 

   @Rpc(description = "Blocks until an event occurs. The returned event is removed from the buffer.", returns = "Map of event properties.")

@@ -293,12 +302,14 @@
   }

 

   @RpcDeprecated(value = "eventWaitFor", release = "r4")

-  @Rpc(description = "Blocks until an event with the supplied name occurs. The returned event is not removed from the buffer.", returns = "Map of event properties.")

+  @Rpc(description = "Blocks until an event with the supplied name occurs. Event is removed from the buffer if removeEvent is True.",

+   returns = "Map of event properties.")

   public Event waitForEvent(

       @RpcParameter(name = "eventName") final String eventName,

+      @RpcOptional final Boolean removeEvent,

       @RpcParameter(name = "timeout", description = "the maximum time to wait") @RpcOptional Integer timeout)

       throws InterruptedException {

-    return eventWaitFor(eventName, timeout);

+    return eventWaitFor(eventName, removeEvent, timeout);

   }

 

   @Rpc(description = "Opens up a socket where you can read for events posted")

diff --git a/Common/src/com/googlecode/android_scripting/facade/ScanFacade.java b/Common/src/com/googlecode/android_scripting/facade/ScanFacade.java
index f098156..24097b8 100644
--- a/Common/src/com/googlecode/android_scripting/facade/ScanFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/ScanFacade.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2014 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.googlecode.android_scripting.facade;
 
 import android.app.Service;
@@ -16,6 +31,7 @@
 import com.googlecode.android_scripting.rpc.RpcStopEvent;
 
 import java.util.Hashtable;
+import java.util.List;
 import java.util.concurrent.Callable;
 
 /**
@@ -34,6 +50,7 @@
   private final Hashtable<Integer, WifiScanListener> wifiScannerListenerList;
   private final Hashtable<Integer, ChangeListener> wifiChangeListenerList;
   private final Hashtable<Integer, WifiHotspotListener> wifiHotspotListenerList;
+  private static Hashtable<Integer, ScanResult[]> wifiScannerResultList;
 
   public ScanFacade(FacadeManager manager) {
     super(manager);
@@ -43,48 +60,53 @@
     wifiScannerListenerList = new Hashtable<Integer, WifiScanListener>();
     wifiChangeListenerList = new Hashtable<Integer, ChangeListener>();
     wifiHotspotListenerList = new Hashtable<Integer, WifiHotspotListener>();
+    wifiScannerResultList = new Hashtable<Integer, ScanResult[]>();
+  }
+
+  public static List<ScanResult> getWifiScanResult(Integer listener_index, List<ScanResult> scanResults){
+    synchronized (wifiScannerResultList) {
+      ScanResult[] scanArray = wifiScannerResultList.get(listener_index);
+      for(ScanResult scanresult :  scanArray)
+        scanResults.add(scanresult);
+      return scanResults;
+    }
   }
 
   private class WifiActionListener implements WifiScanner.ActionListener {
-    private final Bundle mStatus;
     private final Bundle mResults;
-    public int index;
-    protected String listenerType;
+    public int mIndex;
+    protected String mEventType;
 
-    public WifiActionListener(String type, int idx, Bundle statusBundle, Bundle resultBundle) {
-      this.index = idx;
-      this.listenerType = type;
-      this.mStatus = statusBundle;
+    public WifiActionListener(String type, int idx, Bundle resultBundle) {
+      this.mIndex = idx;
+      this.mEventType = type;
       this.mResults = resultBundle;
     }
 
     @Override
     public void onSuccess() {
-      Log.d("android_scripting change onSuccess "+listenerType+index);
-      mStatus.putString("ID", listenerType+index);
-      mStatus.putBoolean("Status", true);
-      mEventFacade.postEvent("Started", mStatus.clone());
-      mStatus.clear();
+      Log.d("onSuccess " + mEventType + " " + mIndex);
+      mResults.putString("Type", "onSuccess");
+      mEventFacade.postEvent(mEventType + mIndex, mResults.clone());
+      mResults.clear();
     }
 
     @Override
     public void onFailure(int reason, String description) {
-      Log.d("android_scripting change onFailure "+listenerType+index);
-      mStatus.putString("ID", listenerType+index);
-      mStatus.putBoolean("Status", false);
-      mStatus.putInt("Reason", reason);
-      mStatus.putString("Exception", description);
-      mEventFacade.postEvent("Failed", mStatus.clone());
-      mStatus.clear();
+      Log.d("onFailure " + mEventType + " " + mIndex);
+      mResults.putString("Type", "onFailure");
+      mResults.putInt("Reason", reason);
+      mResults.putString("Description", description);
+      mEventFacade.postEvent(mEventType + mIndex, mResults.clone());
+      mResults.clear();
     }
 
-    public void reportResult(ScanResult[] results, String eventType) {
-      Log.d("android_scripting "+eventType+" "+listenerType+index);
-      mResults.putString("ID", listenerType+index);
+    public void reportResult(ScanResult[] results, String type) {
+      Log.d("reportResult "+ mEventType + " "+ mIndex);
       mResults.putLong("Timestamp", System.currentTimeMillis()/1000);
-      mResults.putString("Type", eventType);
+      mResults.putString("Type", type);
       mResults.putParcelableArray("Results", results);
-      mEventFacade.postEvent("ScanResults", mResults.clone());
+      mEventFacade.postEvent(mEventType + mIndex, mResults.clone());
       mResults.clear();
     }
   }
@@ -100,22 +122,21 @@
         return new WifiScanListener();
       }
     });
-    wifiScannerListenerList.put(mWifiScannerListener.index, mWifiScannerListener);
+    wifiScannerListenerList.put(mWifiScannerListener.mIndex, mWifiScannerListener);
     return mWifiScannerListener;
   }
 
   private class WifiScanListener implements WifiScanner.ScanListener {
+    private static final String mEventType =  "WifiBackgroundScan";
     protected final Bundle mScanResults;
-    protected final Bundle mScanStatus;
     private final WifiActionListener mWAL;
-    public int index;
+    public int mIndex;
 
     public WifiScanListener() {
-      mScanStatus = new Bundle();
       mScanResults = new Bundle();
       WifiScanListenerCnt += 1;
-      index = WifiScanListenerCnt;
-      mWAL = new WifiActionListener("WifiScanListener", index, mScanStatus, mScanResults);
+      mIndex = WifiScanListenerCnt;
+      mWAL = new WifiActionListener(mEventType, mIndex, mScanResults);
     }
 
     @Override
@@ -130,21 +151,24 @@
 
     @Override
     public void onPeriodChanged(int periodInMs) {
-      mScanStatus.putString("ID", "WifiScanListener"+index);
-      mScanStatus.putBoolean("Status", true);
-      mScanStatus.putInt("NewPeriod", periodInMs);
-      mEventFacade.postEvent("onPeriodChanged", mScanStatus.clone());
-      mScanStatus.clear();
+      Log.d("onPeriodChanged " + mEventType + " " + mIndex);
+      mScanResults.putString("Type", "onPeriodChanged");
+      mScanResults.putInt("NewPeriod", periodInMs);
+      mEventFacade.postEvent(mEventType + mIndex, mScanResults.clone());
+      mScanResults.clear();
     }
 
     @Override
     public void onResults(ScanResult[] results) {
+      synchronized (wifiScannerResultList) {
+        wifiScannerResultList.put(mIndex, results);
+      }
       mWAL.reportResult(results, "onScanResults");
     }
 
     @Override
     public void onFullResult(ScanResult fullScanResult) {
-      Log.d("android_scripting onFullResult WifiScanListener "+index);
+      Log.d("onFullResult WifiScanListener " + mIndex);
       mWAL.reportResult(new ScanResult[]{fullScanResult}, "onFullResult");
     }
   }
@@ -160,22 +184,21 @@
         return new ChangeListener();
       }
     });
-    wifiChangeListenerList.put(mWifiChangeListener.index, mWifiChangeListener);
+    wifiChangeListenerList.put(mWifiChangeListener.mIndex, mWifiChangeListener);
     return mWifiChangeListener;
   }
 
   private class ChangeListener implements WifiScanner.WifiChangeListener {
-    protected final Bundle mStatus;
+    private static final String mEventType =  "TrackChanges";
     protected final Bundle mResults;
     private final WifiActionListener mWAL;
-    public int index;
+    public int mIndex;
 
     public ChangeListener() {
-      mStatus = new Bundle();
       mResults = new Bundle();
       WifiChangeListenerCnt += 1;
-      index = WifiChangeListenerCnt;
-      mWAL = new WifiActionListener("WifiChangeListener", index, mStatus, mResults);
+      mIndex = WifiChangeListenerCnt;
+      mWAL = new WifiActionListener(mEventType, mIndex, mResults);
     }
 
     @Override
@@ -210,22 +233,21 @@
         return new WifiHotspotListener();
       }
     });
-    wifiHotspotListenerList.put(mWifiHotspotListener.index, mWifiHotspotListener);
+    wifiHotspotListenerList.put(mWifiHotspotListener.mIndex, mWifiHotspotListener);
     return mWifiHotspotListener;
   }
 
   private class WifiHotspotListener implements WifiScanner.HotspotListener {
-    protected final Bundle mStatus;
+    private static final String mEventType =  "TrackHotspot";
     protected final Bundle mResults;
     private final WifiActionListener mWAL;
-    public int index;
+    public int mIndex;
 
     public WifiHotspotListener() {
-      mStatus = new Bundle();
       mResults = new Bundle();
       WifiHotspotListenerCnt += 1;
-      index = WifiHotspotListenerCnt;
-      mWAL = new WifiActionListener("HotspotListener", index, mStatus, mResults);
+      mIndex = WifiHotspotListenerCnt;
+      mWAL = new WifiActionListener(mEventType, mIndex, mResults);
     }
 
     @Override
@@ -262,35 +284,37 @@
       ss.channels[i] = new WifiScanner.ChannelSpec(channel_freqs[i]);
     }
     ss.periodInMs = periodInMs;
-    Log.d("android_scripting periodInMs "+ss.periodInMs);
+    Log.d("startWifiBackgroundScan periodInMs " + ss.periodInMs);
     for(int i=0; i<ss.channels.length; i++) {
-      Log.d("android_scripting "+ss.channels[i].frequency+" "+ss.channels[i].passive+" "+ss.channels[i].dwellTimeMS);
+      Log.d("startWifiBackgroundScan " + ss.channels[i].frequency + " " + ss.channels[i].passive + " " + ss.channels[i].dwellTimeMS);
     }
     WifiScanListener mListener = genWifiScanListener();
     mScan.startBackgroundScan(ss, mListener);
-    return mListener.index;
+    return mListener.mIndex;
   }
 
   /**
    * Stops a wifi background scan
-   * @param listener_index the id of the scan listener whose scan to stop
+   * @param listener_mIndex the id of the scan listener whose scan to stop
    */
   @Rpc(description = "Stops an ongoing periodic Wifi scan in background")
   @RpcStopEvent("WifiScan")
   public void stopWifiBackgroundScan(@RpcParameter(name = "listener") Integer listener_index) {
-    Log.d("android_scripting stopping background scan");
     WifiScanListener mListener = wifiScannerListenerList.get(listener_index);
-    Log.d("android_scripting mListener "+mListener.index+mListener.toString());
+    Log.d("stopWifiBackgroundScan mListener "+ mListener.mIndex );
     mScan.stopBackgroundScan(mListener);
+    synchronized (wifiScannerResultList) {
+      wifiScannerResultList.remove(listener_index);
+    }
     wifiScannerListenerList.remove(listener_index);
   }
 
-  @Rpc(description = "Returns a list of indexes of existing listeners")
+  @Rpc(description = "Returns a list of mIndexes of existing listeners")
   public Integer[] showWifiScanListeners() {
     Integer[] result = new Integer[wifiScannerListenerList.size()];
     int j = 0;
     for(int i : wifiScannerListenerList.keySet()) {
-      result[j] = wifiScannerListenerList.get(i).index;
+      result[j] = wifiScannerListenerList.get(i).mIndex;
       j += 1;
     }
     return result;
@@ -302,10 +326,10 @@
    */
   @Rpc(description = "Starts tracking wifi changes")
   public Integer startTrackingChange() {
-    Log.d("android_scripting starting change track");
+    Log.d("starting change track");
     ChangeListener mListener = genWifiChangeListener();
     mScan.startTrackingWifiChange(mListener);
-    return mListener.index;
+    return mListener.mIndex;
   }
 
   /**
@@ -347,7 +371,7 @@
     }
     WifiHotspotListener mWHL = genWifiHotspotListener();
     mScan.startTrackingHotspots(mHotspotInfos, apLostThreshold, mWHL);
-    return mWHL.index;
+    return mWHL.mIndex;
   }
 
   /**
diff --git a/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java b/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
index 1635ffc..a21b389 100644
--- a/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
@@ -18,8 +18,8 @@
 
 import android.app.Service;
 import android.content.Context;
-import android.content.Intent;
 import android.media.AudioManager;
+import android.net.ConnectivityManager;
 import android.os.PowerManager;
 import android.provider.Settings.SettingNotFoundException;
 import android.view.WindowManager;
@@ -37,7 +37,7 @@
 
 /**
  * Exposes phone settings functionality.
- * 
+ *
  * @author Frank Spychalski (frank.spychalski@gmail.com)
  */
 public class SettingsFacade extends RpcReceiver {
@@ -48,10 +48,11 @@
   private final Service mService;
   private final AudioManager mAudio;
   private final PowerManager mPower;
+  private final ConnectivityManager mConnect;
 
   /**
    * Creates a new SettingsFacade.
-   * 
+   *
    * @param service
    *          is the {@link Context} the APIs will run under
    */
@@ -60,6 +61,7 @@
     mService = manager.getService();
     mAudio = (AudioManager) mService.getSystemService(Context.AUDIO_SERVICE);
     mPower = (PowerManager) mService.getSystemService(Context.POWER_SERVICE);
+    mConnect = (ConnectivityManager) mService.getSystemService(Context.CONNECTIVITY_SERVICE);
   }
 
   @Rpc(description = "Sets the screen timeout to this number of seconds.", returns = "The original screen timeout.")
@@ -91,17 +93,11 @@
   }
 
   @Rpc(description = "Toggles airplane mode on and off.", returns = "True if airplane mode is enabled.")
-  public Boolean toggleAirplaneMode(@RpcParameter(name = "enabled") @RpcOptional Boolean enabled) {
+  public void toggleAirplaneMode(@RpcParameter(name = "enabled") @RpcOptional Boolean enabled) {
     if (enabled == null) {
       enabled = !checkAirplaneMode();
     }
-    android.provider.Settings.System.putInt(mService.getContentResolver(),
-        android.provider.Settings.Global.AIRPLANE_MODE_ON, enabled ? AIRPLANE_MODE_ON
-            : AIRPLANE_MODE_OFF);
-    Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
-    intent.putExtra("state", enabled);
-    mService.sendBroadcast(intent);
-    return enabled;
+    mConnect.setAirplaneMode(enabled);
   }
 
   @Rpc(description = "Checks the ringer silent mode setting.", returns = "True if ringer silent mode is enabled.")
diff --git a/Common/src/com/googlecode/android_scripting/facade/WifiPasspointFacade.java b/Common/src/com/googlecode/android_scripting/facade/WifiPasspointFacade.java
new file mode 100644
index 0000000..8b5a119
--- /dev/null
+++ b/Common/src/com/googlecode/android_scripting/facade/WifiPasspointFacade.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2014 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.googlecode.android_scripting.facade;
+
+import android.app.Service;
+import android.content.Context;
+import android.net.wifi.ScanResult;
+import android.net.wifi.passpoint.WifiPasspointManager;
+import android.net.wifi.passpoint.WifiPasspointManager.Channel;
+import android.net.wifi.passpoint.WifiPasspointManager.ChannelListener;
+import android.os.Bundle;
+import android.os.Looper;
+
+import com.googlecode.android_scripting.Log;
+import com.googlecode.android_scripting.MainThread;
+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;
+import com.googlecode.android_scripting.rpc.RpcParameter;
+import com.googlecode.android_scripting.rpc.RpcStartEvent;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+/**
+ * Exposes WifiPasspointManger functionality.
+ */
+public class WifiPasspointFacade extends RpcReceiver {
+
+  private final static String mEventType = "ANQPInfo";
+  private final Service mService;
+  private final EventFacade mEventFacade;
+  private final WifiPasspointManager mWifiPasspointMgr;
+  private static int mWifiPasspointChannelALCnt;
+  private Hashtable<Integer, WifiPasspointChannelActionListener> mWifiPasspointChannelAlList;
+  private List<ScanResult> mScanResults;
+
+  public WifiPasspointFacade(FacadeManager facadeManager){
+    super(facadeManager);
+    mService = facadeManager.getService();
+    mEventFacade = facadeManager.getReceiver(EventFacade.class);
+    mWifiPasspointMgr = (WifiPasspointManager)mService.getSystemService(Context.WIFI_PASSPOINT_SERVICE);
+    mWifiPasspointChannelAlList = new Hashtable<Integer, WifiPasspointChannelActionListener>();
+    mScanResults = new ArrayList<ScanResult>();
+
+  }
+
+  public class WifiPasspointChannelActionListener implements WifiPasspointManager.ActionListener{
+
+    private ChannelListener mChannelListener;
+    private Channel mChannel;
+    private int mIndex;
+    private final Bundle mStatus;
+
+    public WifiPasspointChannelActionListener(){
+      mChannelListener = new WifiPasspointManager.ChannelListener() {
+        @Override
+        public void onChannelDisconnected() {
+          Log.e("Channel Disconnected with WifiPasspoint Framwork");
+        }
+      };
+      mChannel  = mWifiPasspointMgr.initialize(mService.getApplicationContext(), Looper.getMainLooper() , mChannelListener);
+      mIndex = ++mWifiPasspointChannelALCnt;
+      mStatus = new Bundle();
+    }
+
+    @Override
+    public void onSuccess() {
+      Log.d("onSuccess " + mEventType + " " + mIndex);
+      mStatus.putString("Type", "onSuccess");
+      mEventFacade.postEvent(mEventType + mIndex, mStatus.clone());
+      mStatus.clear();
+    }
+
+    @Override
+    public void onFailure(int reason){
+      Log.d("onFailure " + mEventType + " " + mIndex);
+      mStatus.putString("Type", "onFailure");
+      mStatus.putInt("Reason", reason);
+      mEventFacade.postEvent(mEventType + mIndex, mStatus.clone());
+      mStatus.clear();
+    }
+
+  }
+
+  /**
+   * Constructs a WifiPasspointChannelListener object and initialize it
+   * @return WifiPasspointChannelListener
+   */
+  private WifiPasspointChannelActionListener genWifiPasspointChannelAL() {
+    WifiPasspointChannelActionListener mWifiPpChannelAL =
+        MainThread.run(mService, new Callable<WifiPasspointChannelActionListener>() {
+      @Override
+      public WifiPasspointChannelActionListener call() throws Exception {
+        return new WifiPasspointChannelActionListener();
+      }
+    });
+    mWifiPasspointChannelAlList.put(mWifiPpChannelAL.mIndex, mWifiPpChannelAL);
+    return mWifiPpChannelAL;
+  }
+
+  /**
+   * Shuts down all activities associated with Passpoint
+   */
+  @Rpc(description = "Shuts down all Passpoint activities")
+  public void wifiPasspointShutdown() {
+    this.shutdown();
+  }
+
+  /** RPC Method Section */
+
+  /**
+   * Request ANQP Info of Passpoints
+   * @param mask
+   * @return the id of the Passpoint channel listener associated with this
+   */
+  @Rpc(description = "Request ANQP info.")
+  @RpcStartEvent("ANQPInfo")
+  public Integer requestAnqpInfoOfPasspoints(@RpcParameter(name = "scanIndex") Integer scanIndex,
+      @RpcParameter(name = "mask") Integer mask) {
+    ScanFacade.getWifiScanResult(scanIndex, mScanResults);
+    if(mScanResults.size() == 0)
+      return -1;
+    WifiPasspointChannelActionListener mWifiPpChannelAL = genWifiPasspointChannelAL();
+    mWifiPasspointMgr.requestAnqpInfo(mWifiPpChannelAL.mChannel,  mScanResults, mask, mWifiPpChannelAL);
+    return mWifiPpChannelAL.mIndex;
+  }
+  /*
+   * Release all resource before closing down
+   */
+  @Override
+  public void shutdown() {
+    mWifiPasspointChannelAlList.clear();
+    mScanResults.clear();
+  }
+
+}
diff --git a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
index 178c8ad..35646de 100644
--- a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
+++ b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
@@ -229,14 +229,17 @@
     result.put("seen", scanResult.seen);
     result.put("distanceCm", scanResult.distanceCm);
     result.put("distanceSdCm", scanResult.distanceSdCm);
-    JSONArray infoEles = new JSONArray();
-    for(ScanResult.InformationElement ie : scanResult.informationElements) {
-      JSONObject infoEle = new JSONObject();
-      infoEle.put("id", ie.id);
-      infoEle.put("bytes", Base64Codec.encodeBase64(ie.bytes));
-      infoEles.put(infoEle);
-    }
-    result.put("InfomationElements", infoEles);
+    if (scanResult.informationElements != null){
+      JSONArray infoEles = new JSONArray();
+      for(ScanResult.InformationElement ie : scanResult.informationElements) {
+        JSONObject infoEle = new JSONObject();
+        infoEle.put("id", ie.id);
+        infoEle.put("bytes", Base64Codec.encodeBase64(ie.bytes));
+        infoEles.put(infoEle);
+      }
+      result.put("InfomationElements", infoEles);
+    } else
+      result.put("InfomationElements", null);
     return result;
   }
 
diff --git a/ScriptingLayer/src/com/googlecode/android_scripting/facade/FacadeConfiguration.java b/ScriptingLayer/src/com/googlecode/android_scripting/facade/FacadeConfiguration.java
index b7f6306..3992a7f 100644
--- a/ScriptingLayer/src/com/googlecode/android_scripting/facade/FacadeConfiguration.java
+++ b/ScriptingLayer/src/com/googlecode/android_scripting/facade/FacadeConfiguration.java
@@ -93,7 +93,6 @@
 
     if (sSdkLevel >= 5) {
       sFacadeClassList.add(BluetoothFacade.class);
-      sFacadeClassList.add(ScanFacade.class);
     }
 
     if (sSdkLevel >= 7) {
@@ -104,6 +103,11 @@
       sFacadeClassList.add(WebCamFacade.class);
     }
 
+    if (sSdkLevel >= 18) {
+      sFacadeClassList.add(ScanFacade.class);
+      sFacadeClassList.add(WifiPasspointFacade.class);
+    }
+
     for (Class<? extends RpcReceiver> recieverClass : sFacadeClassList) {
       for (MethodDescriptor rpcMethod : MethodDescriptor.collectFrom(recieverClass)) {
         sRpcs.put(rpcMethod.getName(), rpcMethod);
diff --git a/ScriptingLayerForAndroid/Android.mk b/ScriptingLayerForAndroid/Android.mk
index 2b03d43..824f6a7 100644
--- a/ScriptingLayerForAndroid/Android.mk
+++ b/ScriptingLayerForAndroid/Android.mk
@@ -6,6 +6,8 @@
 
 LOCAL_PACKAGE_NAME := sl4a
 
+LOCAL_CERTIFICATE := platform
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 
diff --git a/ScriptingLayerForAndroid/AndroidManifest.xml b/ScriptingLayerForAndroid/AndroidManifest.xml
index 2b39602..d0bb6ed 100644
--- a/ScriptingLayerForAndroid/AndroidManifest.xml
+++ b/ScriptingLayerForAndroid/AndroidManifest.xml
@@ -1,154 +1,167 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-	package="com.googlecode.android_scripting" android:installLocation="auto"
-	android:versionCode="603" android:versionName="6x03">
-	<uses-permission android:name="android.permission.RECEIVE_SMS" />
-	<uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS" />
-	<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
-	<uses-permission android:name="android.permission.INTERNET" />
-	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
-	<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
-	<uses-permission android:name="android.permission.CALL_PHONE" />
-	<uses-permission android:name="android.permission.SEND_SMS" />
-	<uses-permission android:name="android.permission.READ_SMS" />
-	<uses-permission android:name="android.permission.WRITE_SMS" />
-	<uses-permission android:name="android.permission.VIBRATE" />
-	<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
-	<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
-	<uses-permission android:name="android.permission.READ_PHONE_STATE" />
-	<uses-permission android:name="android.permission.PERSISTENT_ACTIVITY" />
-	<uses-permission android:name="android.permission.RESTART_PACKAGES" />
-	<uses-permission android:name="android.permission.GET_TASKS" />
-	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-	<uses-permission android:name="android.permission.RECORD_AUDIO" />
-	<uses-permission android:name="android.permission.READ_LOGS" />
-	<uses-permission android:name="android.permission.WRITE_SETTINGS" />
-	<uses-permission android:name="android.permission.BLUETOOTH" />
-	<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
-	<uses-permission android:name="android.permission.CAMERA" />
-	<uses-permission android:name="android.permission.WAKE_LOCK" />
-	<uses-permission android:name="android.permission.READ_CONTACTS" />
-	<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
-	<uses-sdk android:targetSdkVersion="10" android:minSdkVersion="3" />
-	<application android:icon="@drawable/sl4a_logo_48"
-		android:label="@string/application_title" android:name=".Sl4aApplication">
-		<activity android:name=".activity.ScriptManager"
-			android:configChanges="keyboardHidden|orientation"
-			android:windowSoftInputMode="adjustResize" android:launchMode="singleTop">
-			<intent-filter>
-				<action android:name="android.intent.action.MAIN" />
-				<category android:name="android.intent.category.LAUNCHER" />
-			</intent-filter>
-			<intent-filter>
-				<action android:name="android.intent.action.SEARCH" />
-			</intent-filter>
-			<meta-data android:name="android.app.searchable"
-				android:resource="@xml/searchable_scripts" />
-		</activity>
-		<activity android:name=".activity.ScriptPicker"
-			android:configChanges="keyboardHidden|orientation" android:label="Scripts">
-			<intent-filter>
-				<action android:name="android.intent.action.CREATE_SHORTCUT" />
-				<category android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-			<intent-filter>
-				<action android:name="android.intent.action.PICK" />
-				<data android:scheme="content" android:path="sl4a/scripts" />
-				<category android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-		</activity>
-		<activity android:name=".activity.InterpreterPicker"
-			android:configChanges="keyboardHidden|orientation" android:label="Interpreters">
-			<intent-filter>
-				<action android:name="android.intent.action.CREATE_SHORTCUT" />
-				<category android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-		</activity>
-		<activity-alias android:name="LocalePlugin"
-			android:targetActivity=".activity.ScriptPicker" android:label="@string/application_title"
-			android:icon="@drawable/sl4a_logo_32">
-			<intent-filter>
-				<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
-			</intent-filter>
-		</activity-alias>
-		<receiver android:name=".locale.LocaleReceiver">
-			<intent-filter>
-				<action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
-			</intent-filter>
-		</receiver>
-		<activity android:name=".activity.Preferences" android:theme="@android:style/Theme.NoTitleBar" />
-		<activity android:name="org.connectbot.ConsoleActivity"
-			android:theme="@android:style/Theme.NoTitleBar"
-			android:configChanges="keyboardHidden|orientation"
-			android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
-			android:finishOnTaskLaunch="true" android:launchMode="singleTask" />
-
-		<activity android:name=".activity.ScriptEditor"
-			android:theme="@android:style/Theme.NoTitleBar"
-			android:configChanges="keyboardHidden|orientation"
-			android:windowSoftInputMode="stateAlwaysVisible|adjustResize">
-			<intent-filter>
-				<action android:name="com.googlecode.android_scripting.action.EDIT_SCRIPT" />
-				<category android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-		</activity>
-		<activity android:name=".activity.ApiBrowser"
-			android:configChanges="keyboardHidden|orientation"
-			android:launchMode="singleTop" android:windowSoftInputMode="adjustResize">
-			<intent-filter>
-				<action android:name="android.intent.action.SEARCH" />
-			</intent-filter>
-			<meta-data android:name="android.app.searchable"
-				android:resource="@xml/searchable_apis" />
-		</activity>
-		<activity android:name=".activity.ApiPrompt" android:theme="@android:style/Theme.NoTitleBar"
-			android:configChanges="keyboardHidden|orientation" />
-		<activity android:name=".activity.TriggerManager"
-			android:launchMode="singleTask" android:configChanges="keyboardHidden|orientation" />
-		<activity android:name=".activity.BluetoothDeviceList"
-			android:configChanges="keyboardHidden|orientation" />
-		<activity android:name=".activity.ScriptingLayerServiceLauncher"
-			android:taskAffinity="" android:theme="@android:style/Theme.Translucent.NoTitleBar">
-			<intent-filter>
-				<action android:name="android.intent.action.VIEW" />
-				<category android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-		</activity>
-		<activity android:name=".activity.FutureActivity"
-			android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
-		<activity android:name="org.connectbot.HelpActivity"
-			android:configChanges="keyboardHidden|orientation" />
-		<activity android:name="org.connectbot.HelpTopicActivity"
-			android:configChanges="keyboardHidden|orientation" />
-		<service android:name=".activity.ScriptingLayerService" />
-		<service android:name=".activity.TriggerService" />
-		<activity android:name=".activity.InterpreterManager"
-			android:launchMode="singleTask" android:configChanges="keyboardHidden|orientation" />
-		<activity android:name=".activity.LogcatViewer"
-			android:launchMode="singleTask" android:configChanges="keyboardHidden|orientation" />
-		<activity android:name=".activity.ScriptsLiveFolder"
-			android:label="Scripts" android:icon="@drawable/live_folder"
-			android:configChanges="keyboardHidden|orientation">
-			<intent-filter>
-				<action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
-				<category android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-		</activity>
-		<provider android:name=".provider.ScriptProvider"
-			android:authorities="com.googlecode.android_scripting.provider.scriptprovider" />
-		<provider android:name=".provider.ApiProvider"
-			android:authorities="com.googlecode.android_scripting.provider.apiprovider" />
-		<uses-library android:name="android.test.runner" />
-		<activity android:name=".activity.ScriptProcessMonitor"
-			android:launchMode="singleTask" android:finishOnTaskLaunch="true" />
-		<activity android:configChanges="keyboardHidden|orientation"
-			android:name="org.connectbot.util.ColorsActivity" android:theme="@android:style/Theme.Dialog">
-			<intent-filter>
-				<action android:name="com.googlecode.android_scripting.PICK_TERMINAL_COLORS" />
-				<category android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-		</activity>
-	</application>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.googlecode.android_scripting" android:installLocation="auto" android:versionCode="603" android:versionName="6x03">
+    <uses-permission android:name="android.permission.RECEIVE_SMS" />
+    <uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS" />
+    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <uses-permission android:name="android.permission.CALL_PHONE" />
+    <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
+    <uses-permission android:name="android.permission.SEND_SMS" />
+    <uses-permission android:name="android.permission.READ_SMS" />
+    <uses-permission android:name="android.permission.WRITE_SMS" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.PERSISTENT_ACTIVITY" />
+    <uses-permission android:name="android.permission.RESTART_PACKAGES" />
+    <uses-permission android:name="android.permission.GET_TASKS" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+    <uses-permission android:name="android.permission.READ_LOGS" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+    <uses-permission android:name="android.permission.DEVICE_POWER" />
+    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
+    <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
+    <uses-permission android:name="android.permission.NFC" />
+    <uses-permission android:name="android.permission.HARDWARE_TEST" />
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+    <uses-permission android:name="android.permission.MASTER_CLEAR" />
+    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+    <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" />
+    <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+    <uses-permission android:name="android.permission.ACCESS_WIMAX_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIMAX_STATE" />
+    <uses-permission android:name="com.android.certinstaller.INSTALL_AS_USER" />
+    <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
+    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
+    <uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
+    <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" />
+    <uses-permission android:name="android.permission.READ_USER_DICTIONARY" />
+    <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
+    <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" />
+    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
+    <uses-permission android:name="android.permission.BATTERY_STATS" />
+    <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
+    <uses-permission android:name="android.permission.MOVE_PACKAGE" />
+    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+    <uses-permission android:name="android.permission.BACKUP" />
+    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
+    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+    <uses-permission android:name="android.permission.READ_SYNC_STATS" />
+    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
+    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+    <uses-permission android:name="android.permission.STATUS_BAR" />
+    <uses-permission android:name="android.permission.MANAGE_USB" />
+    <uses-permission android:name="android.permission.SET_POINTER_SPEED" />
+    <uses-permission android:name="android.permission.SET_KEYBOARD_LAYOUT" />
+    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
+    <uses-permission android:name="android.permission.COPY_PROTECTED_DATA" />
+    <uses-permission android:name="android.permission.MANAGE_USERS" />
+    <uses-permission android:name="android.permission.READ_PROFILE" />
+    <uses-permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" />
+    <uses-permission android:name="android.permission.SET_TIME" />
+    <uses-permission android:name="android.permission.ACCESS_NOTIFICATIONS" />
+    <uses-permission android:name="android.permission.REBOOT" />
+    <uses-permission android:name="android.permission.MANAGE_DEVICE_ADMINS" />
+    <uses-sdk android:targetSdkVersion="10" android:minSdkVersion="3" />
+    <application android:icon="@drawable/sl4a_logo_48" android:label="@string/application_title" android:name=".Sl4aApplication">
+        <activity android:name=".activity.ScriptManager" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="adjustResize" android:launchMode="singleTop">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.SEARCH" />
+            </intent-filter>
+            <meta-data android:name="android.app.searchable" android:resource="@xml/searchable_scripts" />
+        </activity>
+        <activity android:name=".activity.ScriptPicker" android:configChanges="keyboardHidden|orientation" android:label="Scripts">
+            <intent-filter>
+                <action android:name="android.intent.action.CREATE_SHORTCUT" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.PICK" />
+                <data android:scheme="content" android:path="sl4a/scripts" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".activity.InterpreterPicker" android:configChanges="keyboardHidden|orientation" android:label="Interpreters">
+            <intent-filter>
+                <action android:name="android.intent.action.CREATE_SHORTCUT" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+        <activity-alias android:name="LocalePlugin" android:targetActivity=".activity.ScriptPicker" android:label="@string/application_title" android:icon="@drawable/sl4a_logo_32">
+            <intent-filter>
+                <action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
+            </intent-filter>
+        </activity-alias>
+        <receiver android:name=".locale.LocaleReceiver">
+            <intent-filter>
+                <action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
+            </intent-filter>
+        </receiver>
+        <activity android:name=".activity.Preferences" android:theme="@android:style/Theme.NoTitleBar" />
+        <activity android:name="org.connectbot.ConsoleActivity" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="stateAlwaysVisible|adjustResize" android:finishOnTaskLaunch="true" android:launchMode="singleTask" />
+        <activity android:name=".activity.ScriptEditor" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="stateAlwaysVisible|adjustResize">
+            <intent-filter>
+                <action android:name="com.googlecode.android_scripting.action.EDIT_SCRIPT" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".activity.ApiBrowser" android:configChanges="keyboardHidden|orientation" android:launchMode="singleTop" android:windowSoftInputMode="adjustResize">
+            <intent-filter>
+                <action android:name="android.intent.action.SEARCH" />
+            </intent-filter>
+            <meta-data android:name="android.app.searchable" android:resource="@xml/searchable_apis" />
+        </activity>
+        <activity android:name=".activity.ApiPrompt" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="keyboardHidden|orientation" />
+        <activity android:name=".activity.TriggerManager" android:launchMode="singleTask" android:configChanges="keyboardHidden|orientation" />
+        <activity android:name=".activity.BluetoothDeviceList" android:configChanges="keyboardHidden|orientation" />
+        <activity android:name=".activity.ScriptingLayerServiceLauncher" android:taskAffinity="" android:theme="@android:style/Theme.Translucent.NoTitleBar">
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".activity.FutureActivity" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
+        <activity android:name="org.connectbot.HelpActivity" android:configChanges="keyboardHidden|orientation" />
+        <activity android:name="org.connectbot.HelpTopicActivity" android:configChanges="keyboardHidden|orientation" />
+        <service android:name=".activity.ScriptingLayerService" />
+        <service android:name=".activity.TriggerService" />
+        <activity android:name=".activity.InterpreterManager" android:launchMode="singleTask" android:configChanges="keyboardHidden|orientation" />
+        <activity android:name=".activity.LogcatViewer" android:launchMode="singleTask" android:configChanges="keyboardHidden|orientation" />
+        <activity android:name=".activity.ScriptsLiveFolder" android:label="Scripts" android:icon="@drawable/live_folder" android:configChanges="keyboardHidden|orientation">
+            <intent-filter>
+                <action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+        <provider android:name=".provider.ScriptProvider" android:authorities="com.googlecode.android_scripting.provider.scriptprovider" />
+        <provider android:name=".provider.ApiProvider" android:authorities="com.googlecode.android_scripting.provider.apiprovider" />
+        <uses-library android:name="android.test.runner" />
+        <activity android:name=".activity.ScriptProcessMonitor" android:launchMode="singleTask" android:finishOnTaskLaunch="true" />
+        <activity android:configChanges="keyboardHidden|orientation" android:name="org.connectbot.util.ColorsActivity" android:theme="@android:style/Theme.Dialog">
+            <intent-filter>
+                <action android:name="com.googlecode.android_scripting.PICK_TERMINAL_COLORS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+    </application>
 </manifest>
\ No newline at end of file
diff --git a/build_all.sh b/build_all.sh
index 32cb04e..3ae62a2 100755
--- a/build_all.sh
+++ b/build_all.sh
@@ -34,7 +34,7 @@
 APP_NAME=sl4a
 APP_PACKAGE_NAME=com.googlecode.android_scripting
 
-BRANCH_ROOT=~/My_workshope/klp-wireless-dev
+BRANCH_ROOT=~/dev/android/another-klp-wireless-dev
 SL4A_ROOT=$BRANCH_ROOT/vendor/google_testing/comms/Tools/sl4a
 SHARED_LIB_JAR_ROOT=$BRANCH_ROOT/out/target/common/obj/JAVA_LIBRARIES
 APP_JAR_ROOT=$BRANCH_ROOT/out/target/common/obj/APPS
@@ -78,12 +78,18 @@
 exec mm -B "building $APP_NAME.apk"
 echo
 
+echo -e "${y}Switching to root${NC}"
+adb root
+adb remount
+
 echo -e "${y}Uninstalling old apk from device${NC}"
 adb uninstall $APP_PACKAGE_NAME
+adb shell rm -r /system/priv-app/$APP_NAME.apk
 
 echo -e "${lb}Installing apk to device${NC}"
 cd $APK_ROOT
-exec adb install $APP_NAME.apk "installing apk to device"
+#exec adb install $APP_NAME.apk "installing apk to device"
+exec adb push $APP_NAME.apk /system/priv-app "installing apk to previliged dir"
 
 echo "All clear!"
 echo -e " ${r}U${brn}N${y}I${g}C${cy}O${lb}R${p}N ${r}P${brn}O${y}W${g}E${cy}R${lb}!${p}!${NC}"