Binary files Android_6.0.1_r11/frameworks/av/.git/index and SAMD_6.0.1_r11_20170930/frameworks/av/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/base/Android.mk SAMD_6.0.1_r11_20170930/frameworks/base/Android.mk
--- Android_6.0.1_r11/frameworks/base/Android.mk	2017-09-27 02:07:48.711736113 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/Android.mk	2017-09-15 11:28:53.215024000 +0900
@@ -252,6 +252,12 @@
 	core/java/android/service/wallpaper/IWallpaperService.aidl \
 	core/java/android/service/chooser/IChooserTargetService.aidl \
 	core/java/android/service/chooser/IChooserTargetResult.aidl \
+	core/java/android/service/collaboroid/IGeneralMessageListener.aidl \
+	core/java/android/service/distribute/IDistributedComputingService.aidl \
+	core/java/android/service/devicemanagement/IDeviceManagementService.aidl \
+	core/java/android/service/remote/IRemoteService.aidl \
+	core/java/android/service/samd/ISAMDService.aidl \
+	core/java/android/service/samd/ISAMDListener.aidl \
 	core/java/android/view/accessibility/IAccessibilityInteractionConnection.aidl\
 	core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl\
 	core/java/android/view/accessibility/IAccessibilityManager.aidl \
@@ -423,7 +429,10 @@
 			$(framework_res_source_path)/com/android/internal/R.java
 
 LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := core-libart conscrypt okhttp core-junit bouncycastle ext
+
+#Collaboroid
+LOCAL_JAVA_LIBRARIES := libbaksmali libsmali core-libart conscrypt okhttp core-junit bouncycastle ext
+#LOCAL_STATIC_JAVA_LIBRARIES += monster
 
 LOCAL_MODULE := framework
 
@@ -1082,7 +1091,7 @@
 ext_dirs := \
 	../../external/nist-sip/java \
 	../../external/tagsoup/src \
-
+	
 ext_src_files := $(call all-java-files-under,$(ext_dirs))
 
 # ====  the library  =========================================
@@ -1100,7 +1109,6 @@
 
 include $(BUILD_JAVA_LIBRARY)
 
-
 # Include subdirectory makefiles
 # ============================================================
 
diff -urN Android_6.0.1_r11/frameworks/base/api/current.txt SAMD_6.0.1_r11_20170930/frameworks/base/api/current.txt
--- Android_6.0.1_r11/frameworks/base/api/current.txt	2017-09-27 02:07:48.791736112 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/api/current.txt	2017-09-22 01:27:06.984519000 +0900
@@ -194,6 +194,7 @@
 
   public static final class R.attr {
     ctor public R.attr();
+    field public static final int SAMDApp = 16844018; // 0x10104f2
     field public static final int absListViewStyle = 16842858; // 0x101006a
     field public static final int accessibilityEventTypes = 16843648; // 0x1010380
     field public static final int accessibilityFeedbackType = 16843650; // 0x1010382
@@ -969,6 +970,7 @@
     field public static final int readPermission = 16842759; // 0x1010007
     field public static final int recognitionService = 16843932; // 0x101049c
     field public static final int relinquishTaskIdentity = 16843894; // 0x1010476
+    field public static final int remoteable = 16844019; // 0x10104f3
     field public static final int reparent = 16843964; // 0x10104bc
     field public static final int reparentWithOverlay = 16843965; // 0x10104bd
     field public static final int repeatCount = 16843199; // 0x10101bf
@@ -994,6 +996,7 @@
     field public static final int restrictionType = 16843923; // 0x1010493
     field public static final int resumeWhilePausing = 16843954; // 0x10104b2
     field public static final int reversible = 16843851; // 0x101044b
+    field public static final int reviseApp = 16844020; // 0x10104f4
     field public static final int revisionCode = 16843989; // 0x10104d5
     field public static final int right = 16843183; // 0x10101af
     field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093
@@ -3284,6 +3287,8 @@
   public class Activity extends android.view.ContextThemeWrapper implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback android.view.LayoutInflater.Factory2 android.view.View.OnCreateContextMenuListener android.view.Window.Callback {
     ctor public Activity();
     method public void addContentView(android.view.View, android.view.ViewGroup.LayoutParams);
+    method public byte[] bitmapToByteArray(android.graphics.Bitmap);
+    method public android.graphics.Bitmap byteArrayToBitmap(byte[]);
     method public void closeContextMenu();
     method public void closeOptionsMenu();
     method public android.app.PendingIntent createPendingResult(int, android.content.Intent, int);
@@ -3296,6 +3301,7 @@
     method public boolean dispatchTrackballEvent(android.view.MotionEvent);
     method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
     method public android.view.View findViewById(int);
+    method public android.view.View findViewById(java.lang.String);
     method public void finish();
     method public void finishActivity(int);
     method public void finishActivityFromChild(android.app.Activity, int);
@@ -3439,11 +3445,13 @@
     method public boolean requestVisibleBehind(boolean);
     method public final boolean requestWindowFeature(int);
     method public final void runOnUiThread(java.lang.Runnable);
+    method public void saveBitmaptoJpeg(android.graphics.Bitmap, java.lang.String, java.lang.String);
     method public void setActionBar(android.widget.Toolbar);
     method public void setContentTransitionManager(android.transition.TransitionManager);
     method public void setContentView(int);
     method public void setContentView(android.view.View);
     method public void setContentView(android.view.View, android.view.ViewGroup.LayoutParams);
+    method public void setContentView2(java.lang.String);
     method public final void setDefaultKeyMode(int);
     method public void setEnterSharedElementCallback(android.app.SharedElementCallback);
     method public void setExitSharedElementCallback(android.app.SharedElementCallback);
@@ -3500,15 +3508,22 @@
     method public void takeKeyEvents(boolean);
     method public void triggerSearch(java.lang.String, android.os.Bundle);
     method public void unregisterForContextMenu(android.view.View);
+    field public static java.lang.ClassLoader CUSTOM_LOADER;
     field public static final int DEFAULT_KEYS_DIALER = 1; // 0x1
     field public static final int DEFAULT_KEYS_DISABLE = 0; // 0x0
     field public static final int DEFAULT_KEYS_SEARCH_GLOBAL = 4; // 0x4
     field public static final int DEFAULT_KEYS_SEARCH_LOCAL = 3; // 0x3
     field public static final int DEFAULT_KEYS_SHORTCUT = 2; // 0x2
     field protected static final int[] FOCUSED_STATE_SET;
+    field public static java.lang.ClassLoader ORIGINAL_LOADER;
     field public static final int RESULT_CANCELED = 0; // 0x0
     field public static final int RESULT_FIRST_USER = 1; // 0x1
     field public static final int RESULT_OK = -1; // 0xffffffff
+    field public android.app.Activity.InitActivity initAsync;
+  }
+
+   class Activity.InitActivity extends android.os.AsyncTask {
+    method protected java.lang.Boolean doInBackground(java.lang.Void...);
   }
 
   public deprecated class ActivityGroup extends android.app.Activity {
@@ -7737,13 +7752,17 @@
     field public static final java.lang.String CAPTIONING_SERVICE = "captioning";
     field public static final java.lang.String CARRIER_CONFIG_SERVICE = "carrier_config";
     field public static final java.lang.String CLIPBOARD_SERVICE = "clipboard";
+    field public static final java.lang.String COLLABOROID = "collaboroid";
+    field public static final java.lang.String COLLABOROID_SERVICE = "collaboroid";
     field public static final java.lang.String CONNECTIVITY_SERVICE = "connectivity";
     field public static final java.lang.String CONSUMER_IR_SERVICE = "consumer_ir";
     field public static final int CONTEXT_IGNORE_SECURITY = 2; // 0x2
     field public static final int CONTEXT_INCLUDE_CODE = 1; // 0x1
     field public static final int CONTEXT_RESTRICTED = 4; // 0x4
+    field public static final java.lang.String DEVICE_MANAGEMENT_SERVICE = "devicemanagement";
     field public static final java.lang.String DEVICE_POLICY_SERVICE = "device_policy";
     field public static final java.lang.String DISPLAY_SERVICE = "display";
+    field public static final java.lang.String DISTRIBUTE_SERVICE = "distribute";
     field public static final java.lang.String DOWNLOAD_SERVICE = "download";
     field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
     field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
@@ -7770,7 +7789,9 @@
     field public static final java.lang.String NSD_SERVICE = "servicediscovery";
     field public static final java.lang.String POWER_SERVICE = "power";
     field public static final java.lang.String PRINT_SERVICE = "print";
+    field public static final java.lang.String REMOTE_SERVICE = "remote";
     field public static final java.lang.String RESTRICTIONS_SERVICE = "restrictions";
+    field public static final java.lang.String SAMD_SERVICE = "samd";
     field public static final java.lang.String SEARCH_SERVICE = "search";
     field public static final java.lang.String SENSOR_SERVICE = "sensor";
     field public static final java.lang.String STORAGE_SERVICE = "storage";
@@ -8880,6 +8901,7 @@
     ctor public ApplicationInfo(android.content.pm.ApplicationInfo);
     method public int describeContents();
     method public void dump(android.util.Printer, java.lang.String);
+    method public boolean isSAMDApp();
     method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager);
     field public static final android.os.Parcelable.Creator<android.content.pm.ApplicationInfo> CREATOR;
     field public static final int FLAG_ALLOW_BACKUP = 32768; // 0x8000
@@ -8901,6 +8923,7 @@
     field public static final int FLAG_PERSISTENT = 8; // 0x8
     field public static final int FLAG_RESIZEABLE_FOR_SCREENS = 4096; // 0x1000
     field public static final int FLAG_RESTORE_ANY_VERSION = 131072; // 0x20000
+    field public static final int FLAG_SAMD_APP = 1073741824; // 0x40000000
     field public static final int FLAG_STOPPED = 2097152; // 0x200000
     field public static final int FLAG_SUPPORTS_LARGE_SCREENS = 2048; // 0x800
     field public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1024; // 0x400
@@ -9059,6 +9082,16 @@
     method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
   }
 
+  public class MethodLineNode implements java.lang.Comparable {
+    ctor public MethodLineNode();
+    ctor public MethodLineNode(int, java.lang.String);
+    method public int compareTo(android.content.pm.MethodLineNode);
+    method public int getLineNum();
+    method public java.lang.String getMethodName();
+    method public void setLineNum(int);
+    method public void setMethodName(java.lang.String);
+  }
+
   public class PackageInfo implements android.os.Parcelable {
     ctor public PackageInfo();
     method public int describeContents();
@@ -9197,6 +9230,7 @@
     field public java.lang.String name;
     field public java.lang.CharSequence nonLocalizedLabel;
     field public java.lang.String packageName;
+    field public boolean remoteable;
   }
 
   public static class PackageItemInfo.DisplayNameComparator implements java.util.Comparator {
@@ -9489,6 +9523,7 @@
     field public boolean multiprocess;
     field public android.content.pm.PathPermission[] pathPermissions;
     field public java.lang.String readPermission;
+    field public boolean remoteable;
     field public android.os.PatternMatcher[] uriPermissionPatterns;
     field public java.lang.String writePermission;
   }
@@ -9523,6 +9558,12 @@
     method public final int compare(android.content.pm.ResolveInfo, android.content.pm.ResolveInfo);
   }
 
+  public class ReverseLineInputStream extends java.io.InputStream {
+    ctor public ReverseLineInputStream(java.io.File) throws java.io.IOException;
+    ctor public ReverseLineInputStream(java.io.File, int, int) throws java.io.IOException;
+    method public int read() throws java.io.IOException;
+  }
+
   public class ServiceInfo extends android.content.pm.ComponentInfo implements android.os.Parcelable {
     ctor public ServiceInfo();
     ctor public ServiceInfo(android.content.pm.ServiceInfo);
@@ -9552,6 +9593,17 @@
 
 package android.content.res {
 
+  public final class ABCManager extends android.content.res.AssetManager {
+    method public void addResource(int);
+    method public int getIdFromName(java.lang.String);
+    method public java.util.HashMap<java.lang.String, java.lang.String> getmKeyToPath();
+    method public java.util.HashMap<java.lang.String, java.lang.Integer> getmNameToId();
+    field public static final int ACCESS_BUFFER = 3; // 0x3
+    field public static final int ACCESS_RANDOM = 1; // 0x1
+    field public static final int ACCESS_STREAMING = 2; // 0x2
+    field public static final int ACCESS_UNKNOWN = 0; // 0x0
+  }
+
   public class AssetFileDescriptor implements java.io.Closeable android.os.Parcelable {
     ctor public AssetFileDescriptor(android.os.ParcelFileDescriptor, long, long);
     ctor public AssetFileDescriptor(android.os.ParcelFileDescriptor, long, long, android.os.Bundle);
@@ -9578,9 +9630,10 @@
     ctor public AssetFileDescriptor.AutoCloseOutputStream(android.content.res.AssetFileDescriptor) throws java.io.IOException;
   }
 
-  public final class AssetManager implements java.lang.AutoCloseable {
+  public class AssetManager implements java.lang.AutoCloseable {
     method public void close();
     method public final java.lang.String[] getLocales();
+    method public java.lang.CharSequence getResourceText2(int);
     method public final java.lang.String[] list(java.lang.String) throws java.io.IOException;
     method public final java.io.InputStream open(java.lang.String) throws java.io.IOException;
     method public final java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
@@ -9743,6 +9796,7 @@
     ctor public Resources(android.content.res.AssetManager, android.util.DisplayMetrics, android.content.res.Configuration);
     method public final void finishPreloading();
     method public final void flushLayoutCache();
+    method public final android.content.res.ABCManager getABC();
     method public android.content.res.XmlResourceParser getAnimation(int) throws android.content.res.Resources.NotFoundException;
     method public final android.content.res.AssetManager getAssets();
     method public boolean getBoolean(int) throws android.content.res.Resources.NotFoundException;
@@ -9757,6 +9811,7 @@
     method public android.util.DisplayMetrics getDisplayMetrics();
     method public deprecated android.graphics.drawable.Drawable getDrawable(int) throws android.content.res.Resources.NotFoundException;
     method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException;
+    method public android.graphics.drawable.Drawable getDrawable2(java.lang.String) throws android.content.res.Resources.NotFoundException;
     method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException;
     method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme);
     method public float getFraction(int, int, int);
@@ -9764,6 +9819,7 @@
     method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException;
     method public int getInteger(int) throws android.content.res.Resources.NotFoundException;
     method public android.content.res.XmlResourceParser getLayout(int) throws android.content.res.Resources.NotFoundException;
+    method public android.content.res.XmlResourceParser getLayout(java.lang.String) throws android.content.res.Resources.NotFoundException;
     method public android.graphics.Movie getMovie(int) throws android.content.res.Resources.NotFoundException;
     method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException;
     method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException;
@@ -9838,6 +9894,8 @@
     method public java.lang.CharSequence[] getTextArray(int);
     method public int getType(int);
     method public boolean getValue(int, android.util.TypedValue);
+    method public int[] getmData();
+    method public int[] getmIndices();
     method public boolean hasValue(int);
     method public boolean hasValueOrEmpty(int);
     method public int length();
@@ -14628,6 +14686,7 @@
     field public static final java.lang.String NETWORK_PROVIDER = "network";
     field public static final java.lang.String PASSIVE_PROVIDER = "passive";
     field public static final java.lang.String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED";
+    field public static final java.lang.String REMOTE_PROVIDER = "remote";
   }
 
   public class LocationProvider {
@@ -26497,6 +26556,7 @@
     field public static final java.lang.String AUTO_TIME = "auto_time";
     field public static final java.lang.String AUTO_TIME_ZONE = "auto_time_zone";
     field public static final java.lang.String BLUETOOTH_ON = "bluetooth_on";
+    field public static final java.lang.String COLLABOROID_ON = "collaboroid_on";
     field public static final android.net.Uri CONTENT_URI;
     field public static final java.lang.String DATA_ROAMING = "data_roaming";
     field public static final java.lang.String DEBUG_APP = "debug_app";
@@ -26513,6 +26573,7 @@
     field public static final java.lang.String SHOW_PROCESSES = "show_processes";
     field public static final java.lang.String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
     field public static final java.lang.String SYS_PROP_SETTING_VERSION = "sys.settings_global_version";
+    field public static final java.lang.String TASKEXECUTOR_ON = "taskexecutor_on";
     field public static final java.lang.String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
     field public static final java.lang.String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
     field public static final java.lang.String USE_GOOGLE_MAIL = "use_google_mail";
@@ -28577,6 +28638,148 @@
 
 }
 
+package android.service.collaboroid {
+
+  public class CollaboRoidManager {
+    ctor public CollaboRoidManager(android.content.Context);
+    method public void setCollaboRoidEnabled(boolean);
+    field public static final java.lang.String COLLABOROID_STATE_CHANGED_ACTION = "android.service.collaboroid.COLLABOROID_STATE_CHANGED";
+    field public static final int COLLABOROID_STATE_DISABLED = 1; // 0x1
+    field public static final int COLLABOROID_STATE_DISABLING = 0; // 0x0
+    field public static final int COLLABOROID_STATE_ENABLED = 3; // 0x3
+    field public static final int COLLABOROID_STATE_ENABLING = 2; // 0x2
+    field public static final int COLLABOROID_STATE_UNKNOWN = 4; // 0x4
+    field public static final java.lang.String EXTRA_COLLABOROID_STATE = "collaboroid_state";
+  }
+
+  public abstract interface IGeneralMessageListener implements android.os.IInterface {
+    method public abstract void onMessageReceived(java.lang.String) throws android.os.RemoteException;
+  }
+
+  public static abstract class IGeneralMessageListener.Stub extends android.os.Binder implements android.service.collaboroid.IGeneralMessageListener {
+    ctor public IGeneralMessageListener.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.collaboroid.IGeneralMessageListener asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+}
+
+package android.service.devicemanagement {
+
+  public class Device implements android.os.Parcelable {
+    ctor public Device(java.lang.String, java.lang.String, java.lang.String, int, int);
+    ctor public Device();
+    method public int describeContents();
+    method public void initDevice();
+    method public void setAllowedResources(int[]);
+    method public void setAskedResources(int[]);
+    method public void updateDevice(java.lang.String, java.lang.String, java.lang.String, int, int);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.devicemanagement.Device> CREATOR;
+    field public java.lang.String HaveDexFiles;
+    field public static final int RESOURCE_TYPE_AUDIO = 5; // 0x5
+    field public static final int RESOURCE_TYPE_KEY = 1; // 0x1
+    field public static final int RESOURCE_TYPE_LOCATION = 3; // 0x3
+    field public static final int RESOURCE_TYPE_REMOTE_ACTIVITY = 7; // 0x7
+    field public static final int RESOURCE_TYPE_SENSOR = 2; // 0x2
+    field public static final int RESOURCE_TYPE_SIZE = 8; // 0x8
+    field public static final int RESOURCE_TYPE_TOUCH = 0; // 0x0
+    field public static final int RESOURCE_TYPE_VIBRATOR = 6; // 0x6
+    field public static final int RESOURCE_TYPE_VIDEO = 4; // 0x4
+    field public static final java.lang.String[] ResourceNames;
+    field public final int SYSTEM_SERVICE_LIST;
+    field public final int TASK_EXECUTOR_LIST;
+    field public int[] allowedResources;
+    field public int[] askedResources;
+    field public java.lang.String deviceName;
+    field public java.util.List<java.lang.String> dexTable;
+    field public java.lang.String idleCpu;
+    field public java.lang.String ipaddress;
+    field public int isSystemServiceOn;
+    field public int isTaskExecutorOn;
+    field public java.util.List<java.lang.String> resourceTable;
+  }
+
+  public class DeviceList {
+    ctor public DeviceList();
+    method public static java.util.HashMap<java.lang.String, android.service.devicemanagement.Device> getDevices();
+    method public static void setDevices(java.util.HashMap<java.lang.String, android.service.devicemanagement.Device>);
+  }
+
+  public class DeviceManager {
+    ctor public DeviceManager(android.service.devicemanagement.IDeviceManagementService);
+    ctor public DeviceManager(android.content.Context);
+    ctor public DeviceManager();
+    method public void addHaveDexFiles(int, java.lang.String);
+    method public void allowResources(java.lang.String, int[]);
+    method public void askResources(java.util.List<android.service.devicemanagement.Device>);
+    method public void constructCluster(java.util.List<android.service.devicemanagement.Device>);
+    method public android.service.devicemanagement.Device getDevice(java.lang.String);
+    method public java.util.List<android.service.devicemanagement.Device> getDeviceList(int);
+    method public java.lang.String getHaveDexFiles(int);
+    method public int getNumofConfiguredDevices();
+    method public java.lang.String[] getSystemServiceOnServerList();
+    method public java.lang.String[] getTaskExecutorOnServerList();
+    method public java.lang.String recommendDevice(java.util.List<android.service.devicemanagement.Device>);
+  }
+
+  public abstract interface IDeviceManagementService implements android.os.IInterface {
+    method public abstract void addHaveDexFiles(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void allowResources(java.lang.String, int[]) throws android.os.RemoteException;
+    method public abstract void askResources(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract void constructCluster(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract android.service.devicemanagement.Device getDevice(java.lang.String) throws android.os.RemoteException;
+    method public abstract java.util.List<android.service.devicemanagement.Device> getDeviceList(int) throws android.os.RemoteException;
+    method public abstract java.lang.String getHaveDexFiles(int) throws android.os.RemoteException;
+    method public abstract int getNumofConfiguredDevices() throws android.os.RemoteException;
+    method public abstract java.lang.String[] getSystemServiceOnServerList() throws android.os.RemoteException;
+    method public abstract java.lang.String[] getTaskExecutorOnServerList() throws android.os.RemoteException;
+    method public abstract void initDevices() throws android.os.RemoteException;
+    method public abstract boolean isAllowedForResource(java.lang.String, int) throws android.os.RemoteException;
+    method public abstract java.lang.String recommendDevice(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract void showRequestDialog(java.lang.String, java.lang.String, int[]) throws android.os.RemoteException;
+  }
+
+  public static abstract class IDeviceManagementService.Stub extends android.os.Binder implements android.service.devicemanagement.IDeviceManagementService {
+    ctor public IDeviceManagementService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.devicemanagement.IDeviceManagementService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+}
+
+package android.service.distribute {
+
+  public class Distributor {
+    ctor public Distributor(android.service.distribute.IDistributedComputingService);
+    ctor public Distributor();
+    ctor public Distributor(android.content.Context);
+    method public void startJobManager(java.lang.String);
+    method public void startTaskExecutor();
+    method public int sum(int, int);
+    method public void testOperation();
+  }
+
+  public abstract interface IDistributedComputingService implements android.os.IInterface {
+    method public abstract void startJobManager(java.lang.String) throws android.os.RemoteException;
+    method public abstract void startTaskExecutor() throws android.os.RemoteException;
+    method public abstract void stopJobManager() throws android.os.RemoteException;
+    method public abstract void stopTaskExecutor() throws android.os.RemoteException;
+    method public abstract int sum(int, int) throws android.os.RemoteException;
+    method public abstract void testOperation() throws android.os.RemoteException;
+  }
+
+  public static abstract class IDistributedComputingService.Stub extends android.os.Binder implements android.service.distribute.IDistributedComputingService {
+    ctor public IDistributedComputingService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.distribute.IDistributedComputingService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+}
+
 package android.service.dreams {
 
   public class DreamService extends android.app.Service implements android.view.Window.Callback {
@@ -28736,6 +28939,193 @@
 
 }
 
+package android.service.remote {
+
+  public class AppendingObjectOutputStream extends java.io.ObjectOutputStream {
+    ctor public AppendingObjectOutputStream(java.io.OutputStream) throws java.io.IOException;
+  }
+
+  public class DexCode implements android.os.Parcelable java.io.Serializable {
+    ctor public DexCode();
+    ctor public DexCode(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public DexCode(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.DexCode> CREATOR;
+  }
+
+  public static class DexCode.RemoteKeyEvent implements java.io.Serializable {
+    ctor public DexCode.RemoteKeyEvent(int, int, int);
+    ctor public DexCode.RemoteKeyEvent(android.os.Parcel);
+    method public int getAction();
+    method public int getCode();
+    method public int getSource();
+  }
+
+  public abstract interface IRemoteService implements android.os.IInterface {
+    method public abstract void addSensorHandle(int, int) throws android.os.RemoteException;
+    method public abstract boolean connectToServer(java.lang.String) throws android.os.RemoteException;
+    method public abstract void disconnectToServer() throws android.os.RemoteException;
+    method public abstract java.util.List<java.lang.String> getClientIPs() throws android.os.RemoteException;
+    method public abstract java.util.List<java.lang.String> getServerIPs() throws android.os.RemoteException;
+    method public abstract int getVideoPlayers() throws android.os.RemoteException;
+    method public abstract void initConnections() throws android.os.RemoteException;
+    method public abstract boolean isAllowedForResource(java.lang.String, java.lang.String, int[]) throws android.os.RemoteException;
+    method public abstract boolean isServerOn() throws android.os.RemoteException;
+    method public abstract void playMusic() throws android.os.RemoteException;
+    method public abstract void refreshDevices() throws android.os.RemoteException;
+    method public abstract void registerListener(android.service.collaboroid.IGeneralMessageListener) throws android.os.RemoteException;
+    method public abstract void removeSensorHandle(int) throws android.os.RemoteException;
+    method public abstract void requestMotionEvents() throws android.os.RemoteException;
+    method public abstract boolean respondAllowedResources(java.lang.String, int[]) throws android.os.RemoteException;
+    method public abstract void sendAllMusic(int, byte[], long) throws android.os.RemoteException;
+    method public abstract void sendAllrequest(android.service.remote.RemoteRequest) throws android.os.RemoteException;
+    method public abstract void sendKeyEvent(android.view.KeyEvent) throws android.os.RemoteException;
+    method public abstract void sendLocation(android.location.Location) throws android.os.RemoteException;
+    method public abstract void sendMotionEvent(android.view.MotionEvent) throws android.os.RemoteException;
+    method public abstract void sendMusicData(int, byte[], long) throws android.os.RemoteException;
+    method public abstract boolean sendRequest(android.service.remote.RemoteRequest) throws android.os.RemoteException;
+    method public abstract boolean sendResourceRequests(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract void sendSensorEvent(int, int, float[], int, long) throws android.os.RemoteException;
+    method public abstract void sendVideoSignal(int) throws android.os.RemoteException;
+    method public abstract void setConfiguration() throws android.os.RemoteException;
+    method public abstract void setEnabled(boolean) throws android.os.RemoteException;
+    method public abstract boolean startServer() throws android.os.RemoteException;
+    method public abstract boolean stopServer() throws android.os.RemoteException;
+    method public abstract void testKey() throws android.os.RemoteException;
+    method public abstract void testLocation() throws android.os.RemoteException;
+    method public abstract void testMusic() throws android.os.RemoteException;
+    method public abstract void testSensor() throws android.os.RemoteException;
+    method public abstract void testTouch() throws android.os.RemoteException;
+    method public abstract void testVibrate() throws android.os.RemoteException;
+    method public abstract void testVideo() throws android.os.RemoteException;
+    method public abstract void unregisterListener(android.service.collaboroid.IGeneralMessageListener) throws android.os.RemoteException;
+  }
+
+  public static abstract class IRemoteService.Stub extends android.os.Binder implements android.service.remote.IRemoteService {
+    ctor public IRemoteService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.remote.IRemoteService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+  public class RemoteRequest implements android.os.Parcelable java.io.Serializable {
+    ctor public RemoteRequest();
+    ctor public RemoteRequest(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public RemoteRequest(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.RemoteRequest> CREATOR;
+  }
+
+  public static class RemoteRequest.RemoteKeyEvent implements java.io.Serializable {
+    ctor public RemoteRequest.RemoteKeyEvent(int, int, int);
+    ctor public RemoteRequest.RemoteKeyEvent(android.os.Parcel);
+    method public int getAction();
+    method public int getCode();
+    method public int getSource();
+  }
+
+  public class RemoteRequest2 implements android.os.Parcelable java.io.Serializable {
+    ctor public RemoteRequest2();
+    ctor public RemoteRequest2(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public RemoteRequest2(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.RemoteRequest> CREATOR;
+  }
+
+  public class RemoteServiceManager {
+    ctor public RemoteServiceManager(android.service.remote.IRemoteService);
+    ctor public RemoteServiceManager();
+    ctor public RemoteServiceManager(android.content.Context);
+    method public void connectToServer(java.lang.String);
+    method public void disconnectToServer();
+    method public void refreshDevices();
+    method public void requestMotionEvents();
+    method public void sendAllMusic(int, byte[], long);
+    method public void sendAllrequest(android.service.remote.RemoteRequest);
+    method public void sendMusicData(int, byte[], long);
+    method public boolean sendRequest(android.service.remote.RemoteRequest);
+    method public void setConfiguration();
+    method public void setEnabled(boolean);
+    method public void startServer();
+    method public void stopServer();
+    method public void testKey();
+    method public void testLocation();
+    method public void testMusic();
+    method public void testSensor();
+    method public void testTouch();
+    method public void testVibrate();
+    method public void testVideo();
+  }
+
+  public class ResourceAapt implements android.os.Parcelable java.io.Serializable {
+    ctor public ResourceAapt();
+    ctor public ResourceAapt(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public ResourceAapt(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.ResourceAapt> CREATOR;
+  }
+
+  public static class ResourceAapt.RemoteKeyEvent implements java.io.Serializable {
+    ctor public ResourceAapt.RemoteKeyEvent(int, int, int);
+    ctor public ResourceAapt.RemoteKeyEvent(android.os.Parcel);
+    method public int getAction();
+    method public int getCode();
+    method public int getSource();
+  }
+
+  public class SdPackage implements java.io.Serializable {
+    ctor public SdPackage(int, byte[], long);
+    ctor public SdPackage(java.lang.String, int, int, int, long, byte[]);
+    method public int getBitrate();
+    method public int getChannels();
+    method public long getDuration();
+    method public java.lang.String getMime();
+    method public long getPresentationTime();
+    method public byte[] getSampleData();
+    method public int getSampleRate();
+    method public int getSampleSize();
+    method public byte[] get_csd0();
+  }
+
+  public class vData implements java.io.Serializable {
+    ctor public vData();
+    ctor public vData(int, byte[], long);
+    method public int getHeight();
+    method public java.lang.String getMime();
+    method public long getPresentationTime();
+    method public byte[] getSampleData();
+    method public int getSampleSize();
+    method public int getWidth();
+    method public byte[] get_csd0();
+    method public byte[] get_csd1();
+    method public void setMediaFormat(java.lang.String, int, int, byte[], byte[]);
+    field public long presentationTime;
+    field public byte[] sampleData;
+    field public int sampleSize;
+  }
+
+}
+
 package android.service.restrictions {
 
   public abstract class RestrictionsReceiver extends android.content.BroadcastReceiver {
@@ -28746,6 +29136,107 @@
 
 }
 
+package android.service.samd {
+
+  public abstract interface ISAMDListener implements android.os.IInterface {
+    method public abstract void onSAMDMsg(android.service.samd.SAMDMessage) throws android.os.RemoteException;
+  }
+
+  public static abstract class ISAMDListener.Stub extends android.os.Binder implements android.service.samd.ISAMDListener {
+    ctor public ISAMDListener.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.samd.ISAMDListener asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+  public abstract interface ISAMDService implements android.os.IInterface {
+    method public abstract void ConvertDex(java.lang.String) throws android.os.RemoteException;
+    method public abstract java.lang.String getCurrentAppName() throws android.os.RemoteException;
+    method public abstract int getRemoteDeviceCount() throws android.os.RemoteException;
+    method public abstract int getRemoteDeviceNumber() throws android.os.RemoteException;
+    method public abstract boolean initialARTable(java.lang.String) throws android.os.RemoteException;
+    method public abstract boolean initialARTableD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void launchActivity(java.lang.String) throws android.os.RemoteException;
+    method public abstract void launchActivityD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void launchActivityWithRes(java.lang.String, java.util.List<java.lang.String>) throws android.os.RemoteException;
+    method public abstract void launchActivityWithResD(int, java.lang.String, java.util.List<java.lang.String>) throws android.os.RemoteException;
+    method public abstract void popUpActivity(java.lang.String) throws android.os.RemoteException;
+    method public abstract void preSendDex(java.lang.String, java.lang.String) throws android.os.RemoteException;
+    method public abstract void requestSAMDListener(android.service.samd.ISAMDListener) throws android.os.RemoteException;
+    method public abstract void sendAPKFile(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendDexActivity(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendDexActivityD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendMessageToLocal(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendMessageToRemote(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendMessageToRemoteD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendResourcesToLocal(java.util.List<java.lang.String>) throws android.os.RemoteException;
+    method public abstract void sendResourcesToRemote(java.util.List<java.lang.String>, java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendResourcesToRemoteD(int, java.util.List<java.lang.String>, java.lang.String) throws android.os.RemoteException;
+  }
+
+  public static abstract class ISAMDService.Stub extends android.os.Binder implements android.service.samd.ISAMDService {
+    ctor public ISAMDService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.samd.ISAMDService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+  public abstract interface SAMDListener {
+    method public abstract void onSAMDMsg(android.service.samd.SAMDMessage);
+  }
+
+  public class SAMDManager {
+    ctor public SAMDManager(android.service.samd.ISAMDService);
+    ctor public SAMDManager();
+    ctor public SAMDManager(android.content.Context);
+    method public void ConvertDex(java.lang.String);
+    method public java.lang.String getCurrentAppName();
+    method public int getRemoteDeviceCount();
+    method public int getRemoteDeviceNumber();
+    method public boolean initialARTable(java.lang.String);
+    method public boolean initialARTableD(int, java.lang.String);
+    method public void launchActivity(java.lang.String);
+    method public void launchActivity(int, java.lang.String);
+    method public void launchActivity(java.lang.String, android.os.Bundle);
+    method public void launchActivity(int, java.lang.String, android.os.Bundle);
+    method public void popUpActivity(java.lang.String);
+    method public void preSendDex(java.lang.String, java.lang.String);
+    method public boolean registerSAMDListener(android.service.samd.SAMDListener);
+    method public void requestSAMDListener(android.service.samd.ISAMDListener);
+    method public void sendAPKFile(java.lang.String);
+    method public void sendActivityDynamic(java.lang.String);
+    method public void sendActivityDynamic(int, java.lang.String);
+    method public void sendMessageToLocal(java.lang.String);
+    method public void sendMessageToRemote(int, java.lang.String);
+    method public void sendMessageToRemote(java.lang.String);
+    method public void sendResourcesToLocal(android.os.Bundle);
+    method public void sendResourcesToRemote(android.os.Bundle, java.lang.String);
+    method public void sendResourcesToRemote(int, android.os.Bundle, java.lang.String);
+    field public android.os.Handler handler;
+    field public android.service.samd.SAMDListener listener;
+  }
+
+  public class SAMDMessage implements android.os.Parcelable java.io.Serializable {
+    ctor public SAMDMessage();
+    ctor public SAMDMessage(int, int, java.lang.String);
+    ctor public SAMDMessage(int, int, java.lang.String, java.lang.String, java.lang.String);
+    ctor public SAMDMessage(android.os.Parcel);
+    method public int describeContents();
+    method public long getEtime();
+    method public int getFromDN();
+    method public java.lang.String getFromDip();
+    method public java.lang.String getMessage();
+    method public long getStime();
+    method public int getToDN();
+    method public java.lang.String getToDip();
+    method public void setEtime(long);
+    method public void setStime(long);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.samd.SAMDMessage> CREATOR;
+  }
+
+}
+
 package android.service.textservice {
 
   public abstract class SpellCheckerService extends android.app.Service {
@@ -35329,6 +35820,8 @@
     method public android.view.View inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup);
     method public android.view.View inflate(int, android.view.ViewGroup, boolean);
     method public android.view.View inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean);
+    method public android.view.View inflate2(java.lang.String, android.view.ViewGroup);
+    method public android.view.View inflate2(java.lang.String, android.view.ViewGroup, boolean);
     method protected android.view.View onCreateView(java.lang.String, android.util.AttributeSet) throws java.lang.ClassNotFoundException;
     method protected android.view.View onCreateView(android.view.View, java.lang.String, android.util.AttributeSet) throws java.lang.ClassNotFoundException;
     method public void setFactory(android.view.LayoutInflater.Factory);
@@ -35971,6 +36464,7 @@
     method public void getDrawingRect(android.graphics.Rect);
     method public long getDrawingTime();
     method public float getElevation();
+    method public java.lang.String getEntryName();
     method public boolean getFilterTouchesWhenObscured();
     method public boolean getFitsSystemWindows();
     method public java.util.ArrayList<android.view.View> getFocusables(int);
@@ -36595,6 +37089,10 @@
     method public abstract boolean onTouch(android.view.View, android.view.MotionEvent);
   }
 
+  public static abstract interface View.SAMDListener {
+    method public abstract void onReceiveMessage();
+  }
+
   public final class ViewAnimationUtils {
     method public static android.animation.Animator createCircularReveal(android.view.View, int, int, float, float);
   }
@@ -37164,6 +37662,7 @@
     method public abstract void setContentView(int);
     method public abstract void setContentView(android.view.View);
     method public abstract void setContentView(android.view.View, android.view.ViewGroup.LayoutParams);
+    method public abstract void setContentView2(java.lang.String);
     method protected void setDefaultWindowFormat(int);
     method public void setDimAmount(float);
     method public void setElevation(float);
@@ -40371,6 +40870,7 @@
     method public void setImageLevel(int);
     method public void setImageMatrix(android.graphics.Matrix);
     method public void setImageResource(int);
+    method public void setImageResource(java.lang.String);
     method public void setImageState(int[], boolean);
     method public void setImageTintList(android.content.res.ColorStateList);
     method public void setImageTintMode(android.graphics.PorterDuff.Mode);
diff -urN Android_6.0.1_r11/frameworks/base/api/system-current.txt SAMD_6.0.1_r11_20170930/frameworks/base/api/system-current.txt
--- Android_6.0.1_r11/frameworks/base/api/system-current.txt	2017-09-27 02:07:48.839736112 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/api/system-current.txt	2017-09-22 01:27:07.272495000 +0900
@@ -286,6 +286,7 @@
 
   public static final class R.attr {
     ctor public R.attr();
+    field public static final int SAMDApp = 16844018; // 0x10104f2
     field public static final int absListViewStyle = 16842858; // 0x101006a
     field public static final int accessibilityEventTypes = 16843648; // 0x1010380
     field public static final int accessibilityFeedbackType = 16843650; // 0x1010382
@@ -1061,6 +1062,7 @@
     field public static final int readPermission = 16842759; // 0x1010007
     field public static final int recognitionService = 16843932; // 0x101049c
     field public static final int relinquishTaskIdentity = 16843894; // 0x1010476
+    field public static final int remoteable = 16844019; // 0x10104f3
     field public static final int reparent = 16843964; // 0x10104bc
     field public static final int reparentWithOverlay = 16843965; // 0x10104bd
     field public static final int repeatCount = 16843199; // 0x10101bf
@@ -1086,6 +1088,7 @@
     field public static final int restrictionType = 16843923; // 0x1010493
     field public static final int resumeWhilePausing = 16843954; // 0x10104b2
     field public static final int reversible = 16843851; // 0x101044b
+    field public static final int reviseApp = 16844020; // 0x10104f4
     field public static final int revisionCode = 16843989; // 0x10104d5
     field public static final int right = 16843183; // 0x10101af
     field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093
@@ -3383,6 +3386,8 @@
   public class Activity extends android.view.ContextThemeWrapper implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback android.view.LayoutInflater.Factory2 android.view.View.OnCreateContextMenuListener android.view.Window.Callback {
     ctor public Activity();
     method public void addContentView(android.view.View, android.view.ViewGroup.LayoutParams);
+    method public byte[] bitmapToByteArray(android.graphics.Bitmap);
+    method public android.graphics.Bitmap byteArrayToBitmap(byte[]);
     method public void closeContextMenu();
     method public void closeOptionsMenu();
     method public void convertFromTranslucent();
@@ -3397,6 +3402,7 @@
     method public boolean dispatchTrackballEvent(android.view.MotionEvent);
     method public void dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
     method public android.view.View findViewById(int);
+    method public android.view.View findViewById(java.lang.String);
     method public void finish();
     method public void finishActivity(int);
     method public void finishActivityFromChild(android.app.Activity, int);
@@ -3542,11 +3548,13 @@
     method public boolean requestVisibleBehind(boolean);
     method public final boolean requestWindowFeature(int);
     method public final void runOnUiThread(java.lang.Runnable);
+    method public void saveBitmaptoJpeg(android.graphics.Bitmap, java.lang.String, java.lang.String);
     method public void setActionBar(android.widget.Toolbar);
     method public void setContentTransitionManager(android.transition.TransitionManager);
     method public void setContentView(int);
     method public void setContentView(android.view.View);
     method public void setContentView(android.view.View, android.view.ViewGroup.LayoutParams);
+    method public void setContentView2(java.lang.String);
     method public final void setDefaultKeyMode(int);
     method public void setEnterSharedElementCallback(android.app.SharedElementCallback);
     method public void setExitSharedElementCallback(android.app.SharedElementCallback);
@@ -3603,15 +3611,22 @@
     method public void takeKeyEvents(boolean);
     method public void triggerSearch(java.lang.String, android.os.Bundle);
     method public void unregisterForContextMenu(android.view.View);
+    field public static java.lang.ClassLoader CUSTOM_LOADER;
     field public static final int DEFAULT_KEYS_DIALER = 1; // 0x1
     field public static final int DEFAULT_KEYS_DISABLE = 0; // 0x0
     field public static final int DEFAULT_KEYS_SEARCH_GLOBAL = 4; // 0x4
     field public static final int DEFAULT_KEYS_SEARCH_LOCAL = 3; // 0x3
     field public static final int DEFAULT_KEYS_SHORTCUT = 2; // 0x2
     field protected static final int[] FOCUSED_STATE_SET;
+    field public static java.lang.ClassLoader ORIGINAL_LOADER;
     field public static final int RESULT_CANCELED = 0; // 0x0
     field public static final int RESULT_FIRST_USER = 1; // 0x1
     field public static final int RESULT_OK = -1; // 0xffffffff
+    field public android.app.Activity.InitActivity initAsync;
+  }
+
+   class Activity.InitActivity extends android.os.AsyncTask {
+    method protected java.lang.Boolean doInBackground(java.lang.Void...);
   }
 
   public static abstract interface Activity.TranslucentConversionListener {
@@ -7981,13 +7996,17 @@
     field public static final java.lang.String CAPTIONING_SERVICE = "captioning";
     field public static final java.lang.String CARRIER_CONFIG_SERVICE = "carrier_config";
     field public static final java.lang.String CLIPBOARD_SERVICE = "clipboard";
+    field public static final java.lang.String COLLABOROID = "collaboroid";
+    field public static final java.lang.String COLLABOROID_SERVICE = "collaboroid";
     field public static final java.lang.String CONNECTIVITY_SERVICE = "connectivity";
     field public static final java.lang.String CONSUMER_IR_SERVICE = "consumer_ir";
     field public static final int CONTEXT_IGNORE_SECURITY = 2; // 0x2
     field public static final int CONTEXT_INCLUDE_CODE = 1; // 0x1
     field public static final int CONTEXT_RESTRICTED = 4; // 0x4
+    field public static final java.lang.String DEVICE_MANAGEMENT_SERVICE = "devicemanagement";
     field public static final java.lang.String DEVICE_POLICY_SERVICE = "device_policy";
     field public static final java.lang.String DISPLAY_SERVICE = "display";
+    field public static final java.lang.String DISTRIBUTE_SERVICE = "distribute";
     field public static final java.lang.String DOWNLOAD_SERVICE = "download";
     field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
     field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
@@ -8017,7 +8036,9 @@
     field public static final java.lang.String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block";
     field public static final java.lang.String POWER_SERVICE = "power";
     field public static final java.lang.String PRINT_SERVICE = "print";
+    field public static final java.lang.String REMOTE_SERVICE = "remote";
     field public static final java.lang.String RESTRICTIONS_SERVICE = "restrictions";
+    field public static final java.lang.String SAMD_SERVICE = "samd";
     field public static final java.lang.String SEARCH_SERVICE = "search";
     field public static final java.lang.String SENSOR_SERVICE = "sensor";
     field public static final java.lang.String STORAGE_SERVICE = "storage";
@@ -9137,6 +9158,7 @@
     ctor public ApplicationInfo(android.content.pm.ApplicationInfo);
     method public int describeContents();
     method public void dump(android.util.Printer, java.lang.String);
+    method public boolean isSAMDApp();
     method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager);
     field public static final android.os.Parcelable.Creator<android.content.pm.ApplicationInfo> CREATOR;
     field public static final int FLAG_ALLOW_BACKUP = 32768; // 0x8000
@@ -9158,6 +9180,7 @@
     field public static final int FLAG_PERSISTENT = 8; // 0x8
     field public static final int FLAG_RESIZEABLE_FOR_SCREENS = 4096; // 0x1000
     field public static final int FLAG_RESTORE_ANY_VERSION = 131072; // 0x20000
+    field public static final int FLAG_SAMD_APP = 1073741824; // 0x40000000
     field public static final int FLAG_STOPPED = 2097152; // 0x200000
     field public static final int FLAG_SUPPORTS_LARGE_SCREENS = 2048; // 0x800
     field public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1024; // 0x400
@@ -9341,6 +9364,16 @@
     field public static final android.os.Parcelable.Creator<android.content.pm.ManifestDigest> CREATOR;
   }
 
+  public class MethodLineNode implements java.lang.Comparable {
+    ctor public MethodLineNode();
+    ctor public MethodLineNode(int, java.lang.String);
+    method public int compareTo(android.content.pm.MethodLineNode);
+    method public int getLineNum();
+    method public java.lang.String getMethodName();
+    method public void setLineNum(int);
+    method public void setMethodName(java.lang.String);
+  }
+
   public class PackageInfo implements android.os.Parcelable {
     ctor public PackageInfo();
     method public int describeContents();
@@ -9480,6 +9513,7 @@
     field public java.lang.String name;
     field public java.lang.CharSequence nonLocalizedLabel;
     field public java.lang.String packageName;
+    field public boolean remoteable;
   }
 
   public static class PackageItemInfo.DisplayNameComparator implements java.util.Comparator {
@@ -9826,6 +9860,7 @@
     field public boolean multiprocess;
     field public android.content.pm.PathPermission[] pathPermissions;
     field public java.lang.String readPermission;
+    field public boolean remoteable;
     field public android.os.PatternMatcher[] uriPermissionPatterns;
     field public java.lang.String writePermission;
   }
@@ -9860,6 +9895,12 @@
     method public final int compare(android.content.pm.ResolveInfo, android.content.pm.ResolveInfo);
   }
 
+  public class ReverseLineInputStream extends java.io.InputStream {
+    ctor public ReverseLineInputStream(java.io.File) throws java.io.IOException;
+    ctor public ReverseLineInputStream(java.io.File, int, int) throws java.io.IOException;
+    method public int read() throws java.io.IOException;
+  }
+
   public class ServiceInfo extends android.content.pm.ComponentInfo implements android.os.Parcelable {
     ctor public ServiceInfo();
     ctor public ServiceInfo(android.content.pm.ServiceInfo);
@@ -9889,6 +9930,17 @@
 
 package android.content.res {
 
+  public final class ABCManager extends android.content.res.AssetManager {
+    method public void addResource(int);
+    method public int getIdFromName(java.lang.String);
+    method public java.util.HashMap<java.lang.String, java.lang.String> getmKeyToPath();
+    method public java.util.HashMap<java.lang.String, java.lang.Integer> getmNameToId();
+    field public static final int ACCESS_BUFFER = 3; // 0x3
+    field public static final int ACCESS_RANDOM = 1; // 0x1
+    field public static final int ACCESS_STREAMING = 2; // 0x2
+    field public static final int ACCESS_UNKNOWN = 0; // 0x0
+  }
+
   public class AssetFileDescriptor implements java.io.Closeable android.os.Parcelable {
     ctor public AssetFileDescriptor(android.os.ParcelFileDescriptor, long, long);
     ctor public AssetFileDescriptor(android.os.ParcelFileDescriptor, long, long, android.os.Bundle);
@@ -9915,9 +9967,10 @@
     ctor public AssetFileDescriptor.AutoCloseOutputStream(android.content.res.AssetFileDescriptor) throws java.io.IOException;
   }
 
-  public final class AssetManager implements java.lang.AutoCloseable {
+  public class AssetManager implements java.lang.AutoCloseable {
     method public void close();
     method public final java.lang.String[] getLocales();
+    method public java.lang.CharSequence getResourceText2(int);
     method public final java.lang.String[] list(java.lang.String) throws java.io.IOException;
     method public final java.io.InputStream open(java.lang.String) throws java.io.IOException;
     method public final java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
@@ -10080,6 +10133,7 @@
     ctor public Resources(android.content.res.AssetManager, android.util.DisplayMetrics, android.content.res.Configuration);
     method public final void finishPreloading();
     method public final void flushLayoutCache();
+    method public final android.content.res.ABCManager getABC();
     method public android.content.res.XmlResourceParser getAnimation(int) throws android.content.res.Resources.NotFoundException;
     method public final android.content.res.AssetManager getAssets();
     method public boolean getBoolean(int) throws android.content.res.Resources.NotFoundException;
@@ -10094,6 +10148,7 @@
     method public android.util.DisplayMetrics getDisplayMetrics();
     method public deprecated android.graphics.drawable.Drawable getDrawable(int) throws android.content.res.Resources.NotFoundException;
     method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException;
+    method public android.graphics.drawable.Drawable getDrawable2(java.lang.String) throws android.content.res.Resources.NotFoundException;
     method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException;
     method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme);
     method public float getFraction(int, int, int);
@@ -10101,6 +10156,7 @@
     method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException;
     method public int getInteger(int) throws android.content.res.Resources.NotFoundException;
     method public android.content.res.XmlResourceParser getLayout(int) throws android.content.res.Resources.NotFoundException;
+    method public android.content.res.XmlResourceParser getLayout(java.lang.String) throws android.content.res.Resources.NotFoundException;
     method public android.graphics.Movie getMovie(int) throws android.content.res.Resources.NotFoundException;
     method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException;
     method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException;
@@ -10175,6 +10231,8 @@
     method public java.lang.CharSequence[] getTextArray(int);
     method public int getType(int);
     method public boolean getValue(int, android.util.TypedValue);
+    method public int[] getmData();
+    method public int[] getmIndices();
     method public boolean hasValue(int);
     method public boolean hasValueOrEmpty(int);
     method public int length();
@@ -15827,6 +15885,7 @@
     field public static final java.lang.String NETWORK_PROVIDER = "network";
     field public static final java.lang.String PASSIVE_PROVIDER = "passive";
     field public static final java.lang.String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED";
+    field public static final java.lang.String REMOTE_PROVIDER = "remote";
   }
 
   public class LocationProvider {
@@ -28555,6 +28614,7 @@
     field public static final java.lang.String AUTO_TIME = "auto_time";
     field public static final java.lang.String AUTO_TIME_ZONE = "auto_time_zone";
     field public static final java.lang.String BLUETOOTH_ON = "bluetooth_on";
+    field public static final java.lang.String COLLABOROID_ON = "collaboroid_on";
     field public static final android.net.Uri CONTENT_URI;
     field public static final java.lang.String DATA_ROAMING = "data_roaming";
     field public static final java.lang.String DEBUG_APP = "debug_app";
@@ -28571,6 +28631,7 @@
     field public static final java.lang.String SHOW_PROCESSES = "show_processes";
     field public static final java.lang.String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
     field public static final java.lang.String SYS_PROP_SETTING_VERSION = "sys.settings_global_version";
+    field public static final java.lang.String TASKEXECUTOR_ON = "taskexecutor_on";
     field public static final java.lang.String THEATER_MODE_ON = "theater_mode_on";
     field public static final java.lang.String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
     field public static final java.lang.String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
@@ -30636,6 +30697,148 @@
 
 }
 
+package android.service.collaboroid {
+
+  public class CollaboRoidManager {
+    ctor public CollaboRoidManager(android.content.Context);
+    method public void setCollaboRoidEnabled(boolean);
+    field public static final java.lang.String COLLABOROID_STATE_CHANGED_ACTION = "android.service.collaboroid.COLLABOROID_STATE_CHANGED";
+    field public static final int COLLABOROID_STATE_DISABLED = 1; // 0x1
+    field public static final int COLLABOROID_STATE_DISABLING = 0; // 0x0
+    field public static final int COLLABOROID_STATE_ENABLED = 3; // 0x3
+    field public static final int COLLABOROID_STATE_ENABLING = 2; // 0x2
+    field public static final int COLLABOROID_STATE_UNKNOWN = 4; // 0x4
+    field public static final java.lang.String EXTRA_COLLABOROID_STATE = "collaboroid_state";
+  }
+
+  public abstract interface IGeneralMessageListener implements android.os.IInterface {
+    method public abstract void onMessageReceived(java.lang.String) throws android.os.RemoteException;
+  }
+
+  public static abstract class IGeneralMessageListener.Stub extends android.os.Binder implements android.service.collaboroid.IGeneralMessageListener {
+    ctor public IGeneralMessageListener.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.collaboroid.IGeneralMessageListener asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+}
+
+package android.service.devicemanagement {
+
+  public class Device implements android.os.Parcelable {
+    ctor public Device(java.lang.String, java.lang.String, java.lang.String, int, int);
+    ctor public Device();
+    method public int describeContents();
+    method public void initDevice();
+    method public void setAllowedResources(int[]);
+    method public void setAskedResources(int[]);
+    method public void updateDevice(java.lang.String, java.lang.String, java.lang.String, int, int);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.devicemanagement.Device> CREATOR;
+    field public java.lang.String HaveDexFiles;
+    field public static final int RESOURCE_TYPE_AUDIO = 5; // 0x5
+    field public static final int RESOURCE_TYPE_KEY = 1; // 0x1
+    field public static final int RESOURCE_TYPE_LOCATION = 3; // 0x3
+    field public static final int RESOURCE_TYPE_REMOTE_ACTIVITY = 7; // 0x7
+    field public static final int RESOURCE_TYPE_SENSOR = 2; // 0x2
+    field public static final int RESOURCE_TYPE_SIZE = 8; // 0x8
+    field public static final int RESOURCE_TYPE_TOUCH = 0; // 0x0
+    field public static final int RESOURCE_TYPE_VIBRATOR = 6; // 0x6
+    field public static final int RESOURCE_TYPE_VIDEO = 4; // 0x4
+    field public static final java.lang.String[] ResourceNames;
+    field public final int SYSTEM_SERVICE_LIST;
+    field public final int TASK_EXECUTOR_LIST;
+    field public int[] allowedResources;
+    field public int[] askedResources;
+    field public java.lang.String deviceName;
+    field public java.util.List<java.lang.String> dexTable;
+    field public java.lang.String idleCpu;
+    field public java.lang.String ipaddress;
+    field public int isSystemServiceOn;
+    field public int isTaskExecutorOn;
+    field public java.util.List<java.lang.String> resourceTable;
+  }
+
+  public class DeviceList {
+    ctor public DeviceList();
+    method public static java.util.HashMap<java.lang.String, android.service.devicemanagement.Device> getDevices();
+    method public static void setDevices(java.util.HashMap<java.lang.String, android.service.devicemanagement.Device>);
+  }
+
+  public class DeviceManager {
+    ctor public DeviceManager(android.service.devicemanagement.IDeviceManagementService);
+    ctor public DeviceManager(android.content.Context);
+    ctor public DeviceManager();
+    method public void addHaveDexFiles(int, java.lang.String);
+    method public void allowResources(java.lang.String, int[]);
+    method public void askResources(java.util.List<android.service.devicemanagement.Device>);
+    method public void constructCluster(java.util.List<android.service.devicemanagement.Device>);
+    method public android.service.devicemanagement.Device getDevice(java.lang.String);
+    method public java.util.List<android.service.devicemanagement.Device> getDeviceList(int);
+    method public java.lang.String getHaveDexFiles(int);
+    method public int getNumofConfiguredDevices();
+    method public java.lang.String[] getSystemServiceOnServerList();
+    method public java.lang.String[] getTaskExecutorOnServerList();
+    method public java.lang.String recommendDevice(java.util.List<android.service.devicemanagement.Device>);
+  }
+
+  public abstract interface IDeviceManagementService implements android.os.IInterface {
+    method public abstract void addHaveDexFiles(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void allowResources(java.lang.String, int[]) throws android.os.RemoteException;
+    method public abstract void askResources(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract void constructCluster(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract android.service.devicemanagement.Device getDevice(java.lang.String) throws android.os.RemoteException;
+    method public abstract java.util.List<android.service.devicemanagement.Device> getDeviceList(int) throws android.os.RemoteException;
+    method public abstract java.lang.String getHaveDexFiles(int) throws android.os.RemoteException;
+    method public abstract int getNumofConfiguredDevices() throws android.os.RemoteException;
+    method public abstract java.lang.String[] getSystemServiceOnServerList() throws android.os.RemoteException;
+    method public abstract java.lang.String[] getTaskExecutorOnServerList() throws android.os.RemoteException;
+    method public abstract void initDevices() throws android.os.RemoteException;
+    method public abstract boolean isAllowedForResource(java.lang.String, int) throws android.os.RemoteException;
+    method public abstract java.lang.String recommendDevice(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract void showRequestDialog(java.lang.String, java.lang.String, int[]) throws android.os.RemoteException;
+  }
+
+  public static abstract class IDeviceManagementService.Stub extends android.os.Binder implements android.service.devicemanagement.IDeviceManagementService {
+    ctor public IDeviceManagementService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.devicemanagement.IDeviceManagementService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+}
+
+package android.service.distribute {
+
+  public class Distributor {
+    ctor public Distributor(android.service.distribute.IDistributedComputingService);
+    ctor public Distributor();
+    ctor public Distributor(android.content.Context);
+    method public void startJobManager(java.lang.String);
+    method public void startTaskExecutor();
+    method public int sum(int, int);
+    method public void testOperation();
+  }
+
+  public abstract interface IDistributedComputingService implements android.os.IInterface {
+    method public abstract void startJobManager(java.lang.String) throws android.os.RemoteException;
+    method public abstract void startTaskExecutor() throws android.os.RemoteException;
+    method public abstract void stopJobManager() throws android.os.RemoteException;
+    method public abstract void stopTaskExecutor() throws android.os.RemoteException;
+    method public abstract int sum(int, int) throws android.os.RemoteException;
+    method public abstract void testOperation() throws android.os.RemoteException;
+  }
+
+  public static abstract class IDistributedComputingService.Stub extends android.os.Binder implements android.service.distribute.IDistributedComputingService {
+    ctor public IDistributedComputingService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.distribute.IDistributedComputingService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+}
+
 package android.service.dreams {
 
   public class DreamService extends android.app.Service implements android.view.Window.Callback {
@@ -30865,6 +31068,193 @@
 
 }
 
+package android.service.remote {
+
+  public class AppendingObjectOutputStream extends java.io.ObjectOutputStream {
+    ctor public AppendingObjectOutputStream(java.io.OutputStream) throws java.io.IOException;
+  }
+
+  public class DexCode implements android.os.Parcelable java.io.Serializable {
+    ctor public DexCode();
+    ctor public DexCode(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public DexCode(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.DexCode> CREATOR;
+  }
+
+  public static class DexCode.RemoteKeyEvent implements java.io.Serializable {
+    ctor public DexCode.RemoteKeyEvent(int, int, int);
+    ctor public DexCode.RemoteKeyEvent(android.os.Parcel);
+    method public int getAction();
+    method public int getCode();
+    method public int getSource();
+  }
+
+  public abstract interface IRemoteService implements android.os.IInterface {
+    method public abstract void addSensorHandle(int, int) throws android.os.RemoteException;
+    method public abstract boolean connectToServer(java.lang.String) throws android.os.RemoteException;
+    method public abstract void disconnectToServer() throws android.os.RemoteException;
+    method public abstract java.util.List<java.lang.String> getClientIPs() throws android.os.RemoteException;
+    method public abstract java.util.List<java.lang.String> getServerIPs() throws android.os.RemoteException;
+    method public abstract int getVideoPlayers() throws android.os.RemoteException;
+    method public abstract void initConnections() throws android.os.RemoteException;
+    method public abstract boolean isAllowedForResource(java.lang.String, java.lang.String, int[]) throws android.os.RemoteException;
+    method public abstract boolean isServerOn() throws android.os.RemoteException;
+    method public abstract void playMusic() throws android.os.RemoteException;
+    method public abstract void refreshDevices() throws android.os.RemoteException;
+    method public abstract void registerListener(android.service.collaboroid.IGeneralMessageListener) throws android.os.RemoteException;
+    method public abstract void removeSensorHandle(int) throws android.os.RemoteException;
+    method public abstract void requestMotionEvents() throws android.os.RemoteException;
+    method public abstract boolean respondAllowedResources(java.lang.String, int[]) throws android.os.RemoteException;
+    method public abstract void sendAllMusic(int, byte[], long) throws android.os.RemoteException;
+    method public abstract void sendAllrequest(android.service.remote.RemoteRequest) throws android.os.RemoteException;
+    method public abstract void sendKeyEvent(android.view.KeyEvent) throws android.os.RemoteException;
+    method public abstract void sendLocation(android.location.Location) throws android.os.RemoteException;
+    method public abstract void sendMotionEvent(android.view.MotionEvent) throws android.os.RemoteException;
+    method public abstract void sendMusicData(int, byte[], long) throws android.os.RemoteException;
+    method public abstract boolean sendRequest(android.service.remote.RemoteRequest) throws android.os.RemoteException;
+    method public abstract boolean sendResourceRequests(java.util.List<android.service.devicemanagement.Device>) throws android.os.RemoteException;
+    method public abstract void sendSensorEvent(int, int, float[], int, long) throws android.os.RemoteException;
+    method public abstract void sendVideoSignal(int) throws android.os.RemoteException;
+    method public abstract void setConfiguration() throws android.os.RemoteException;
+    method public abstract void setEnabled(boolean) throws android.os.RemoteException;
+    method public abstract boolean startServer() throws android.os.RemoteException;
+    method public abstract boolean stopServer() throws android.os.RemoteException;
+    method public abstract void testKey() throws android.os.RemoteException;
+    method public abstract void testLocation() throws android.os.RemoteException;
+    method public abstract void testMusic() throws android.os.RemoteException;
+    method public abstract void testSensor() throws android.os.RemoteException;
+    method public abstract void testTouch() throws android.os.RemoteException;
+    method public abstract void testVibrate() throws android.os.RemoteException;
+    method public abstract void testVideo() throws android.os.RemoteException;
+    method public abstract void unregisterListener(android.service.collaboroid.IGeneralMessageListener) throws android.os.RemoteException;
+  }
+
+  public static abstract class IRemoteService.Stub extends android.os.Binder implements android.service.remote.IRemoteService {
+    ctor public IRemoteService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.remote.IRemoteService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+  public class RemoteRequest implements android.os.Parcelable java.io.Serializable {
+    ctor public RemoteRequest();
+    ctor public RemoteRequest(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public RemoteRequest(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.RemoteRequest> CREATOR;
+  }
+
+  public static class RemoteRequest.RemoteKeyEvent implements java.io.Serializable {
+    ctor public RemoteRequest.RemoteKeyEvent(int, int, int);
+    ctor public RemoteRequest.RemoteKeyEvent(android.os.Parcel);
+    method public int getAction();
+    method public int getCode();
+    method public int getSource();
+  }
+
+  public class RemoteRequest2 implements android.os.Parcelable java.io.Serializable {
+    ctor public RemoteRequest2();
+    ctor public RemoteRequest2(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public RemoteRequest2(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.RemoteRequest> CREATOR;
+  }
+
+  public class RemoteServiceManager {
+    ctor public RemoteServiceManager(android.service.remote.IRemoteService);
+    ctor public RemoteServiceManager();
+    ctor public RemoteServiceManager(android.content.Context);
+    method public void connectToServer(java.lang.String);
+    method public void disconnectToServer();
+    method public void refreshDevices();
+    method public void requestMotionEvents();
+    method public void sendAllMusic(int, byte[], long);
+    method public void sendAllrequest(android.service.remote.RemoteRequest);
+    method public void sendMusicData(int, byte[], long);
+    method public boolean sendRequest(android.service.remote.RemoteRequest);
+    method public void setConfiguration();
+    method public void setEnabled(boolean);
+    method public void startServer();
+    method public void stopServer();
+    method public void testKey();
+    method public void testLocation();
+    method public void testMusic();
+    method public void testSensor();
+    method public void testTouch();
+    method public void testVibrate();
+    method public void testVideo();
+  }
+
+  public class ResourceAapt implements android.os.Parcelable java.io.Serializable {
+    ctor public ResourceAapt();
+    ctor public ResourceAapt(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    ctor public ResourceAapt(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getMethod();
+    method public java.util.ArrayList<java.lang.Object> getPara();
+    method public java.lang.String getType();
+    method public void set(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.Object>);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.remote.ResourceAapt> CREATOR;
+  }
+
+  public static class ResourceAapt.RemoteKeyEvent implements java.io.Serializable {
+    ctor public ResourceAapt.RemoteKeyEvent(int, int, int);
+    ctor public ResourceAapt.RemoteKeyEvent(android.os.Parcel);
+    method public int getAction();
+    method public int getCode();
+    method public int getSource();
+  }
+
+  public class SdPackage implements java.io.Serializable {
+    ctor public SdPackage(int, byte[], long);
+    ctor public SdPackage(java.lang.String, int, int, int, long, byte[]);
+    method public int getBitrate();
+    method public int getChannels();
+    method public long getDuration();
+    method public java.lang.String getMime();
+    method public long getPresentationTime();
+    method public byte[] getSampleData();
+    method public int getSampleRate();
+    method public int getSampleSize();
+    method public byte[] get_csd0();
+  }
+
+  public class vData implements java.io.Serializable {
+    ctor public vData();
+    ctor public vData(int, byte[], long);
+    method public int getHeight();
+    method public java.lang.String getMime();
+    method public long getPresentationTime();
+    method public byte[] getSampleData();
+    method public int getSampleSize();
+    method public int getWidth();
+    method public byte[] get_csd0();
+    method public byte[] get_csd1();
+    method public void setMediaFormat(java.lang.String, int, int, byte[], byte[]);
+    field public long presentationTime;
+    field public byte[] sampleData;
+    field public int sampleSize;
+  }
+
+}
+
 package android.service.restrictions {
 
   public abstract class RestrictionsReceiver extends android.content.BroadcastReceiver {
@@ -30875,6 +31265,107 @@
 
 }
 
+package android.service.samd {
+
+  public abstract interface ISAMDListener implements android.os.IInterface {
+    method public abstract void onSAMDMsg(android.service.samd.SAMDMessage) throws android.os.RemoteException;
+  }
+
+  public static abstract class ISAMDListener.Stub extends android.os.Binder implements android.service.samd.ISAMDListener {
+    ctor public ISAMDListener.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.samd.ISAMDListener asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+  public abstract interface ISAMDService implements android.os.IInterface {
+    method public abstract void ConvertDex(java.lang.String) throws android.os.RemoteException;
+    method public abstract java.lang.String getCurrentAppName() throws android.os.RemoteException;
+    method public abstract int getRemoteDeviceCount() throws android.os.RemoteException;
+    method public abstract int getRemoteDeviceNumber() throws android.os.RemoteException;
+    method public abstract boolean initialARTable(java.lang.String) throws android.os.RemoteException;
+    method public abstract boolean initialARTableD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void launchActivity(java.lang.String) throws android.os.RemoteException;
+    method public abstract void launchActivityD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void launchActivityWithRes(java.lang.String, java.util.List<java.lang.String>) throws android.os.RemoteException;
+    method public abstract void launchActivityWithResD(int, java.lang.String, java.util.List<java.lang.String>) throws android.os.RemoteException;
+    method public abstract void popUpActivity(java.lang.String) throws android.os.RemoteException;
+    method public abstract void preSendDex(java.lang.String, java.lang.String) throws android.os.RemoteException;
+    method public abstract void requestSAMDListener(android.service.samd.ISAMDListener) throws android.os.RemoteException;
+    method public abstract void sendAPKFile(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendDexActivity(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendDexActivityD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendMessageToLocal(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendMessageToRemote(java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendMessageToRemoteD(int, java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendResourcesToLocal(java.util.List<java.lang.String>) throws android.os.RemoteException;
+    method public abstract void sendResourcesToRemote(java.util.List<java.lang.String>, java.lang.String) throws android.os.RemoteException;
+    method public abstract void sendResourcesToRemoteD(int, java.util.List<java.lang.String>, java.lang.String) throws android.os.RemoteException;
+  }
+
+  public static abstract class ISAMDService.Stub extends android.os.Binder implements android.service.samd.ISAMDService {
+    ctor public ISAMDService.Stub();
+    method public android.os.IBinder asBinder();
+    method public static android.service.samd.ISAMDService asInterface(android.os.IBinder);
+    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
+  }
+
+  public abstract interface SAMDListener {
+    method public abstract void onSAMDMsg(android.service.samd.SAMDMessage);
+  }
+
+  public class SAMDManager {
+    ctor public SAMDManager(android.service.samd.ISAMDService);
+    ctor public SAMDManager();
+    ctor public SAMDManager(android.content.Context);
+    method public void ConvertDex(java.lang.String);
+    method public java.lang.String getCurrentAppName();
+    method public int getRemoteDeviceCount();
+    method public int getRemoteDeviceNumber();
+    method public boolean initialARTable(java.lang.String);
+    method public boolean initialARTableD(int, java.lang.String);
+    method public void launchActivity(java.lang.String);
+    method public void launchActivity(int, java.lang.String);
+    method public void launchActivity(java.lang.String, android.os.Bundle);
+    method public void launchActivity(int, java.lang.String, android.os.Bundle);
+    method public void popUpActivity(java.lang.String);
+    method public void preSendDex(java.lang.String, java.lang.String);
+    method public boolean registerSAMDListener(android.service.samd.SAMDListener);
+    method public void requestSAMDListener(android.service.samd.ISAMDListener);
+    method public void sendAPKFile(java.lang.String);
+    method public void sendActivityDynamic(java.lang.String);
+    method public void sendActivityDynamic(int, java.lang.String);
+    method public void sendMessageToLocal(java.lang.String);
+    method public void sendMessageToRemote(int, java.lang.String);
+    method public void sendMessageToRemote(java.lang.String);
+    method public void sendResourcesToLocal(android.os.Bundle);
+    method public void sendResourcesToRemote(android.os.Bundle, java.lang.String);
+    method public void sendResourcesToRemote(int, android.os.Bundle, java.lang.String);
+    field public android.os.Handler handler;
+    field public android.service.samd.SAMDListener listener;
+  }
+
+  public class SAMDMessage implements android.os.Parcelable java.io.Serializable {
+    ctor public SAMDMessage();
+    ctor public SAMDMessage(int, int, java.lang.String);
+    ctor public SAMDMessage(int, int, java.lang.String, java.lang.String, java.lang.String);
+    ctor public SAMDMessage(android.os.Parcel);
+    method public int describeContents();
+    method public long getEtime();
+    method public int getFromDN();
+    method public java.lang.String getFromDip();
+    method public java.lang.String getMessage();
+    method public long getStime();
+    method public int getToDN();
+    method public java.lang.String getToDip();
+    method public void setEtime(long);
+    method public void setStime(long);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.service.samd.SAMDMessage> CREATOR;
+  }
+
+}
+
 package android.service.textservice {
 
   public abstract class SpellCheckerService extends android.app.Service {
@@ -37621,6 +38112,8 @@
     method public android.view.View inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup);
     method public android.view.View inflate(int, android.view.ViewGroup, boolean);
     method public android.view.View inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean);
+    method public android.view.View inflate2(java.lang.String, android.view.ViewGroup);
+    method public android.view.View inflate2(java.lang.String, android.view.ViewGroup, boolean);
     method protected android.view.View onCreateView(java.lang.String, android.util.AttributeSet) throws java.lang.ClassNotFoundException;
     method protected android.view.View onCreateView(android.view.View, java.lang.String, android.util.AttributeSet) throws java.lang.ClassNotFoundException;
     method public void setFactory(android.view.LayoutInflater.Factory);
@@ -38263,6 +38756,7 @@
     method public void getDrawingRect(android.graphics.Rect);
     method public long getDrawingTime();
     method public float getElevation();
+    method public java.lang.String getEntryName();
     method public boolean getFilterTouchesWhenObscured();
     method public boolean getFitsSystemWindows();
     method public java.util.ArrayList<android.view.View> getFocusables(int);
@@ -38887,6 +39381,10 @@
     method public abstract boolean onTouch(android.view.View, android.view.MotionEvent);
   }
 
+  public static abstract interface View.SAMDListener {
+    method public abstract void onReceiveMessage();
+  }
+
   public final class ViewAnimationUtils {
     method public static android.animation.Animator createCircularReveal(android.view.View, int, int, float, float);
   }
@@ -39456,6 +39954,7 @@
     method public abstract void setContentView(int);
     method public abstract void setContentView(android.view.View);
     method public abstract void setContentView(android.view.View, android.view.ViewGroup.LayoutParams);
+    method public abstract void setContentView2(java.lang.String);
     method protected void setDefaultWindowFormat(int);
     method public void setDimAmount(float);
     method public void setDisableWallpaperTouchEvents(boolean);
@@ -42977,6 +43476,7 @@
     method public void setImageLevel(int);
     method public void setImageMatrix(android.graphics.Matrix);
     method public void setImageResource(int);
+    method public void setImageResource(java.lang.String);
     method public void setImageState(int[], boolean);
     method public void setImageTintList(android.content.res.ColorStateList);
     method public void setImageTintMode(android.graphics.PorterDuff.Mode);
diff -urN Android_6.0.1_r11/frameworks/base/CleanSpec.mk SAMD_6.0.1_r11_20170930/frameworks/base/CleanSpec.mk
--- Android_6.0.1_r11/frameworks/base/CleanSpec.mk	2017-09-27 02:07:48.711736113 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/CleanSpec.mk	2016-11-01 17:36:40.386409000 +0900
@@ -239,3 +239,12 @@
 # ******************************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST ABOVE THIS BANNER
 # ******************************************************************
+
+# clean steps for aapt
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_PREBUILT_TAG)/bin/aapt)
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_PREBUILT_TAG)/obj32/EXECUTABLES/aapt_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_PREBUILT_TAG)/bin/libaapt_tests)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/aapt_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/aapt)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/bin/aapt)
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_PREBUILT_TAG)/obj32/STATIC_LIBRARIES/libaapt_intermediates)
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/app/Activity.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/Activity.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/app/Activity.java	2017-09-27 02:07:48.875736111 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/Activity.java	2017-09-21 13:22:46.105169000 +0900
@@ -25,7 +25,10 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.StyleRes;
+import android.graphics.BitmapFactory;
+import android.os.AsyncTask;
 import android.os.PersistableBundle;
+import android.service.samd.SAMDManager;
 import android.transition.Scene;
 import android.transition.TransitionManager;
 import android.util.ArrayMap;
@@ -91,6 +94,7 @@
 import android.view.MenuItem;
 import android.view.MotionEvent;
 import com.android.internal.policy.PhoneWindow;
+
 import android.view.SearchEvent;
 import android.view.View;
 import android.view.View.OnCreateContextMenuListener;
@@ -104,7 +108,12 @@
 import android.view.accessibility.AccessibilityEvent;
 import android.widget.AdapterView;
 
+import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.FileDescriptor;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
@@ -672,6 +681,47 @@
         Window.Callback, KeyEvent.Callback,
         OnCreateContextMenuListener, ComponentCallbacks2,
         Window.OnWindowDismissedCallback {
+
+    class InitActivity extends AsyncTask<Void,Void,Boolean> {
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... voids) {
+            boolean start = true;
+            //collaboroid
+            SAMDManager ss = (SAMDManager) getSystemService(Context.SAMD_SERVICE);
+            int stringId = getApplicationInfo().labelRes;
+            if(stringId == 0){
+                if(getApplicationInfo().nonLocalizedLabel != null){
+
+                }
+            }else{
+                if(!ss.getCurrentAppName().equals(getApplicationContext().getString(stringId))){
+                    //null
+                    start = ss.initialARTable(getApplicationContext().getString(stringId));
+                }
+            }
+            return start;
+        }
+
+        // AsyncTask.cancel(boolean) 메소드가 true 인자로
+        // 실행되면 호출되는 콜백.
+        // background 작업이 취소될때 꼭 해야될 작업은  여기에 구현.
+        @Override
+        protected void onCancelled() {
+            // TODO Auto-generated method stub
+            super.onCancelled();
+        }
+    }
+
+    public InitActivity initAsync;
+
+    public static ClassLoader ORIGINAL_LOADER;
+    public static ClassLoader CUSTOM_LOADER = null;
+
     private static final String TAG = "Activity";
     private static final boolean DEBUG_LIFECYCLE = false;
 
@@ -771,7 +821,7 @@
         private boolean mUpdated;
     }
     private final ArrayList<ManagedCursor> mManagedCursors =
-        new ArrayList<ManagedCursor>();
+            new ArrayList<ManagedCursor>();
 
     // protected by synchronized (this)
     int mResultCode = RESULT_CANCELED;
@@ -902,28 +952,69 @@
     @MainThread
     @CallSuper
     protected void onCreate(@Nullable Bundle savedInstanceState) {
-        if (DEBUG_LIFECYCLE) Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
-        if (mLastNonConfigurationInstances != null) {
-            mFragments.restoreLoaderNonConfig(mLastNonConfigurationInstances.loaders);
-        }
-        if (mActivityInfo.parentActivityName != null) {
-            if (mActionBar == null) {
-                mEnableDefaultActionBarUp = true;
-            } else {
-                mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
+        if(getApplicationInfo().isSAMDApp()){
+            boolean activityPop = false;
+            initAsync = new InitActivity();
+            try {
+                activityPop = initAsync.execute().get();
+            }catch(Exception e) {
+                e.printStackTrace();
+            }
+            if(activityPop){
+                SAMDManager ss = (SAMDManager) getSystemService(Context.SAMD_SERVICE);
+                ss.preSendDex(getLocalClassName(), getPackageName());
+
+                if (DEBUG_LIFECYCLE){
+                    Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
+                }
+                if (mLastNonConfigurationInstances != null) {
+                    mFragments.restoreLoaderNonConfig(mLastNonConfigurationInstances.loaders);
+                }
+                if (mActivityInfo.parentActivityName != null) {
+                    if (mActionBar == null) {
+                        mEnableDefaultActionBarUp = true;
+                    } else {
+                        mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
+                    }
+                }
+                if (savedInstanceState != null) {
+                    Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
+                    mFragments.restoreAllState(p, mLastNonConfigurationInstances != null
+                            ? mLastNonConfigurationInstances.fragments : null);
+                }
+                mFragments.dispatchCreate();
+                getApplication().dispatchActivityCreated(this, savedInstanceState);
+                if (mVoiceInteractor != null) {
+                    mVoiceInteractor.attachActivity(this);
+                }
+                mCalled = true;
             }
+        }else{
+            if (DEBUG_LIFECYCLE){
+                Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
+            }
+            if (mLastNonConfigurationInstances != null) {
+                mFragments.restoreLoaderNonConfig(mLastNonConfigurationInstances.loaders);
+            }
+            if (mActivityInfo.parentActivityName != null) {
+                if (mActionBar == null) {
+                    mEnableDefaultActionBarUp = true;
+                } else {
+                    mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
+                }
+            }
+            if (savedInstanceState != null) {
+                Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
+                mFragments.restoreAllState(p, mLastNonConfigurationInstances != null
+                        ? mLastNonConfigurationInstances.fragments : null);
+            }
+            mFragments.dispatchCreate();
+            getApplication().dispatchActivityCreated(this, savedInstanceState);
+            if (mVoiceInteractor != null) {
+                mVoiceInteractor.attachActivity(this);
+            }
+            mCalled = true;
         }
-        if (savedInstanceState != null) {
-            Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
-            mFragments.restoreAllState(p, mLastNonConfigurationInstances != null
-                    ? mLastNonConfigurationInstances.fragments : null);
-        }
-        mFragments.dispatchCreate();
-        getApplication().dispatchActivityCreated(this, savedInstanceState);
-        if (mVoiceInteractor != null) {
-            mVoiceInteractor.attachActivity(this);
-        }
-        mCalled = true;
     }
 
     /**
@@ -947,7 +1038,7 @@
      * @see #onPostCreate
      */
     public void onCreate(@Nullable Bundle savedInstanceState,
-            @Nullable PersistableBundle persistentState) {
+                         @Nullable PersistableBundle persistentState) {
         onCreate(savedInstanceState);
     }
 
@@ -974,7 +1065,7 @@
      * @param persistentState contains the persistable saved state
      */
     final void performRestoreInstanceState(Bundle savedInstanceState,
-            PersistableBundle persistentState) {
+                                           PersistableBundle persistentState) {
         onRestoreInstanceState(savedInstanceState, persistentState);
         if (savedInstanceState != null) {
             restoreManagedDialogs(savedInstanceState);
@@ -1002,6 +1093,7 @@
      * @see #onSaveInstanceState
      */
     protected void onRestoreInstanceState(Bundle savedInstanceState) {
+        //변화가 생긴이후로는 여기로 들어온다.
         if (mWindow != null) {
             Bundle windowState = savedInstanceState.getBundle(WINDOW_HIERARCHY_TAG);
             if (windowState != null) {
@@ -1032,7 +1124,7 @@
      * @see #onSaveInstanceState
      */
     public void onRestoreInstanceState(Bundle savedInstanceState,
-            PersistableBundle persistentState) {
+                                       PersistableBundle persistentState) {
         if (savedInstanceState != null) {
             onRestoreInstanceState(savedInstanceState);
         }
@@ -1123,7 +1215,7 @@
      * @see #onCreate
      */
     public void onPostCreate(@Nullable Bundle savedInstanceState,
-            @Nullable PersistableBundle persistentState) {
+                             @Nullable PersistableBundle persistentState) {
         onPostCreate(savedInstanceState);
     }
 
@@ -1652,9 +1744,17 @@
      */
     @CallSuper
     protected void onDestroy() {
-        if (DEBUG_LIFECYCLE) Slog.v(TAG, "onDestroy " + this);
+
+        if (DEBUG_LIFECYCLE) {
+            Slog.v(TAG, "onDestroy " + this);
+        }
         mCalled = true;
 
+//        if(getApplicationInfo().isRemoteApp()){
+//            Log.d("samd experiment","is remote app");
+//            initAsync.onCancelled();
+//        }
+
         // dismiss any dialogs we are managing.
         if (mManagedDialogs != null) {
             final int numDialogs = mManagedDialogs.size();
@@ -1963,7 +2063,7 @@
      */
     @Deprecated
     public final Cursor managedQuery(Uri uri, String[] projection, String selection,
-            String sortOrder) {
+                                     String sortOrder) {
         Cursor c = getContentResolver().query(uri, projection, selection, null, sortOrder);
         if (c != null) {
             startManagingCursor(c);
@@ -2003,7 +2103,7 @@
      */
     @Deprecated
     public final Cursor managedQuery(Uri uri, String[] projection, String selection,
-            String[] selectionArgs, String sortOrder) {
+                                     String[] selectionArgs, String sortOrder) {
         Cursor c = getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder);
         if (c != null) {
             startManagingCursor(c);
@@ -2096,6 +2196,13 @@
         return getWindow().findViewById(id);
     }
 
+    @Nullable
+    public View findViewById(String name) {
+        int id = getResources().getABC().getIdFromName(name);
+        Log.d(TAG, "findViewById: " + id);
+        return getWindow().findViewById(id);
+    }
+
     /**
      * Retrieve a reference to this activity's ActionBar.
      *
@@ -2173,6 +2280,11 @@
         initWindowDecorActionBar();
     }
 
+    public void setContentView2(String layoutResKey) {
+        getWindow().setContentView2(layoutResKey);
+        initWindowDecorActionBar();
+    }
+
     /**
      * Set the activity content to an explicit view.  This view is placed
      * directly into the activity's view hierarchy.  It can itself be a complex
@@ -2349,18 +2461,18 @@
         // Some modes use a SpannableStringBuilder to track & dispatch input events
         // This list must remain in sync with the switch in onKeyDown()
         switch (mode) {
-        case DEFAULT_KEYS_DISABLE:
-        case DEFAULT_KEYS_SHORTCUT:
-            mDefaultKeySsb = null;      // not used in these modes
-            break;
-        case DEFAULT_KEYS_DIALER:
-        case DEFAULT_KEYS_SEARCH_LOCAL:
-        case DEFAULT_KEYS_SEARCH_GLOBAL:
-            mDefaultKeySsb = new SpannableStringBuilder();
-            Selection.setSelection(mDefaultKeySsb,0);
-            break;
-        default:
-            throw new IllegalArgumentException();
+            case DEFAULT_KEYS_DISABLE:
+            case DEFAULT_KEYS_SHORTCUT:
+                mDefaultKeySsb = null;      // not used in these modes
+                break;
+            case DEFAULT_KEYS_DIALER:
+            case DEFAULT_KEYS_SEARCH_LOCAL:
+            case DEFAULT_KEYS_SEARCH_GLOBAL:
+                mDefaultKeySsb = new SpannableStringBuilder();
+                Selection.setSelection(mDefaultKeySsb,0);
+                break;
+            default:
+                throw new IllegalArgumentException();
         }
     }
 
@@ -2428,17 +2540,17 @@
                     clearSpannable = true;
 
                     switch (mDefaultKeyMode) {
-                    case DEFAULT_KEYS_DIALER:
-                        Intent intent = new Intent(Intent.ACTION_DIAL,  Uri.parse("tel:" + str));
-                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-                        startActivity(intent);
-                        break;
-                    case DEFAULT_KEYS_SEARCH_LOCAL:
-                        startSearch(str, false, null, false);
-                        break;
-                    case DEFAULT_KEYS_SEARCH_GLOBAL:
-                        startSearch(str, false, null, true);
-                        break;
+                        case DEFAULT_KEYS_DIALER:
+                            Intent intent = new Intent(Intent.ACTION_DIAL,  Uri.parse("tel:" + str));
+                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                            startActivity(intent);
+                            break;
+                        case DEFAULT_KEYS_SEARCH_LOCAL:
+                            startSearch(str, false, null, false);
+                            break;
+                        case DEFAULT_KEYS_SEARCH_GLOBAL:
+                            startSearch(str, false, null, true);
+                            break;
                     }
                 }
             }
@@ -2816,12 +2928,12 @@
 
         LayoutParams params = getWindow().getAttributes();
         boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) &&
-            (params.height == LayoutParams.MATCH_PARENT);
+                (params.height == LayoutParams.MATCH_PARENT);
         event.setFullScreen(isFullScreen);
 
         CharSequence title = getTitle();
         if (!TextUtils.isEmpty(title)) {
-           event.getText().add(title);
+            event.getText().add(title);
         }
 
         return true;
@@ -3609,7 +3721,7 @@
      * @see #onSearchRequested
      */
     public void startSearch(@Nullable String initialQuery, boolean selectInitialQuery,
-            @Nullable Bundle appSearchData, boolean globalSearch) {
+                            @Nullable Bundle appSearchData, boolean globalSearch) {
         ensureSearchManager();
         mSearchManager.startSearch(initialQuery, selectInitialQuery, getComponentName(),
                 appSearchData, globalSearch);
@@ -3716,7 +3828,7 @@
 
     @Override
     protected void onApplyThemeResource(Resources.Theme theme, @StyleRes int resid,
-            boolean first) {
+                                        boolean first) {
         if (mParent == null) {
             super.onApplyThemeResource(theme, resid, first);
         } else {
@@ -3846,7 +3958,7 @@
      * @see #requestPermissions(String[], int)
      */
     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
-            @NonNull int[] grantResults) {
+                                           @NonNull int[] grantResults) {
         /* callback - no nothing */
     }
 
@@ -3927,13 +4039,13 @@
     public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options) {
         if (mParent == null) {
             Instrumentation.ActivityResult ar =
-                mInstrumentation.execStartActivity(
-                    this, mMainThread.getApplicationThread(), mToken, this,
-                    intent, requestCode, options);
+                    mInstrumentation.execStartActivity(
+                            this, mMainThread.getApplicationThread(), mToken, this,
+                            intent, requestCode, options);
             if (ar != null) {
                 mMainThread.sendActivityResult(
-                    mToken, mEmbeddedID, requestCode, ar.getResultCode(),
-                    ar.getResultData());
+                        mToken, mEmbeddedID, requestCode, ar.getResultCode(),
+                        ar.getResultData());
             }
             if (requestCode >= 0) {
                 // If this start is requesting a result, we can avoid making
@@ -3985,7 +4097,7 @@
      * @hide Implement to provide correct calling token.
      */
     public void startActivityForResultAsUser(Intent intent, int requestCode,
-            @Nullable Bundle options, UserHandle user) {
+                                             @Nullable Bundle options, UserHandle user) {
         if (mParent != null) {
             throw new RuntimeException("Can't be called from a child");
         }
@@ -3994,7 +4106,7 @@
                 options, user);
         if (ar != null) {
             mMainThread.sendActivityResult(
-                mToken, mEmbeddedID, requestCode, ar.getResultCode(), ar.getResultData());
+                    mToken, mEmbeddedID, requestCode, ar.getResultCode(), ar.getResultData());
         }
         if (requestCode >= 0) {
             // If this start is requesting a result, we can avoid making
@@ -4030,8 +4142,8 @@
                         intent, -1, options, user);
         if (ar != null) {
             mMainThread.sendActivityResult(
-                mToken, mEmbeddedID, -1, ar.getResultCode(),
-                ar.getResultData());
+                    mToken, mEmbeddedID, -1, ar.getResultCode(),
+                    ar.getResultData());
         }
         cancelInputsAndStartExitTransition(options);
     }
@@ -4052,7 +4164,7 @@
      * @hide
      */
     public void startActivityAsCaller(Intent intent, @Nullable Bundle options,
-            boolean ignoreTargetSecurity, int userId) {
+                                      boolean ignoreTargetSecurity, int userId) {
         if (mParent != null) {
             throw new RuntimeException("Can't be called from a child");
         }
@@ -4062,8 +4174,8 @@
                         intent, -1, options, ignoreTargetSecurity, userId);
         if (ar != null) {
             mMainThread.sendActivityResult(
-                mToken, mEmbeddedID, -1, ar.getResultCode(),
-                ar.getResultData());
+                    mToken, mEmbeddedID, -1, ar.getResultCode(),
+                    ar.getResultData());
         }
         cancelInputsAndStartExitTransition(options);
     }
@@ -4084,7 +4196,7 @@
      * @param extraFlags Always set to 0.
      */
     public void startIntentSenderForResult(IntentSender intent, int requestCode,
-            @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
+                                           @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
             throws IntentSender.SendIntentException {
         startIntentSenderForResult(intent, requestCode, fillInIntent, flagsMask,
                 flagsValues, extraFlags, null);
@@ -4116,8 +4228,8 @@
      * override any that conflict with those given by the IntentSender.
      */
     public void startIntentSenderForResult(IntentSender intent, int requestCode,
-            @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
-            Bundle options) throws IntentSender.SendIntentException {
+                                           @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
+                                           Bundle options) throws IntentSender.SendIntentException {
         if (mParent == null) {
             startIntentSenderForResultInner(intent, requestCode, fillInIntent,
                     flagsMask, flagsValues, this, options);
@@ -4133,8 +4245,8 @@
     }
 
     private void startIntentSenderForResultInner(IntentSender intent, int requestCode,
-            Intent fillInIntent, int flagsMask, int flagsValues, Activity activity,
-            Bundle options)
+                                                 Intent fillInIntent, int flagsMask, int flagsValues, Activity activity,
+                                                 Bundle options)
             throws IntentSender.SendIntentException {
         try {
             String resolvedType = null;
@@ -4144,9 +4256,9 @@
                 resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
             }
             int result = ActivityManagerNative.getDefault()
-                .startActivityIntentSender(mMainThread.getApplicationThread(), intent,
-                        fillInIntent, resolvedType, mToken, activity.mEmbeddedID,
-                        requestCode, flagsMask, flagsValues, options);
+                    .startActivityIntentSender(mMainThread.getApplicationThread(), intent,
+                            fillInIntent, resolvedType, mToken, activity.mEmbeddedID,
+                            requestCode, flagsMask, flagsValues, options);
             if (result == ActivityManager.START_CANCELED) {
                 throw new IntentSender.SendIntentException();
             }
@@ -4272,7 +4384,7 @@
      * @param extraFlags Always set to 0.
      */
     public void startIntentSender(IntentSender intent,
-            @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
+                                  @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
             throws IntentSender.SendIntentException {
         startIntentSender(intent, fillInIntent, flagsMask, flagsValues,
                 extraFlags, null);
@@ -4299,8 +4411,8 @@
      * override any that conflict with those given by the IntentSender.
      */
     public void startIntentSender(IntentSender intent,
-            @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
-            Bundle options) throws IntentSender.SendIntentException {
+                                  @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
+                                  Bundle options) throws IntentSender.SendIntentException {
         if (options != null) {
             startIntentSenderForResult(intent, -1, fillInIntent, flagsMask,
                     flagsValues, extraFlags, options);
@@ -4362,7 +4474,7 @@
      * @see #startActivityForResult
      */
     public boolean startActivityIfNeeded(@NonNull Intent intent, int requestCode,
-            @Nullable Bundle options) {
+                                         @Nullable Bundle options) {
         if (mParent == null) {
             int result = ActivityManager.START_RETURN_INTENT_TO_CALLER;
             try {
@@ -4373,10 +4485,10 @@
                 intent.migrateExtraStreamToClipData();
                 intent.prepareToLeaveProcess();
                 result = ActivityManagerNative.getDefault()
-                    .startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
-                            intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken,
-                            mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED,
-                            null, options);
+                        .startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
+                                intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken,
+                                mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED,
+                                null, options);
             } catch (RemoteException e) {
                 // Empty
             }
@@ -4397,7 +4509,7 @@
         }
 
         throw new UnsupportedOperationException(
-            "startActivityIfNeeded can only be called from a top-level activity");
+                "startActivityIfNeeded can only be called from a top-level activity");
     }
 
     /**
@@ -4443,7 +4555,7 @@
                 intent.migrateExtraStreamToClipData();
                 intent.prepareToLeaveProcess();
                 return ActivityManagerNative.getDefault()
-                    .startNextMatchingActivity(mToken, intent, options);
+                        .startNextMatchingActivity(mToken, intent, options);
             } catch (RemoteException e) {
                 // Empty
             }
@@ -4451,7 +4563,7 @@
         }
 
         throw new UnsupportedOperationException(
-            "startNextMatchingActivity can only be called from a top-level activity");
+                "startNextMatchingActivity can only be called from a top-level activity");
     }
 
     /**
@@ -4468,7 +4580,7 @@
      * @see #startActivityForResult
      */
     public void startActivityFromChild(@NonNull Activity child, Intent intent,
-            int requestCode) {
+                                       int requestCode) {
         startActivityFromChild(child, intent, requestCode, null);
     }
 
@@ -4492,15 +4604,15 @@
      * @see #startActivityForResult
      */
     public void startActivityFromChild(@NonNull Activity child, Intent intent,
-            int requestCode, @Nullable Bundle options) {
+                                       int requestCode, @Nullable Bundle options) {
         Instrumentation.ActivityResult ar =
-            mInstrumentation.execStartActivity(
-                this, mMainThread.getApplicationThread(), mToken, child,
-                intent, requestCode, options);
+                mInstrumentation.execStartActivity(
+                        this, mMainThread.getApplicationThread(), mToken, child,
+                        intent, requestCode, options);
         if (ar != null) {
             mMainThread.sendActivityResult(
-                mToken, child.mEmbeddedID, requestCode,
-                ar.getResultCode(), ar.getResultData());
+                    mToken, child.mEmbeddedID, requestCode,
+                    ar.getResultCode(), ar.getResultData());
         }
         cancelInputsAndStartExitTransition(options);
     }
@@ -4519,7 +4631,7 @@
      * @see Fragment#startActivityForResult
      */
     public void startActivityFromFragment(@NonNull Fragment fragment, Intent intent,
-            int requestCode) {
+                                          int requestCode) {
         startActivityFromFragment(fragment, intent, requestCode, null);
     }
 
@@ -4544,7 +4656,7 @@
      * @see Fragment#startActivityForResult
      */
     public void startActivityFromFragment(@NonNull Fragment fragment, Intent intent,
-            int requestCode, @Nullable Bundle options) {
+                                          int requestCode, @Nullable Bundle options) {
         startActivityForResult(fragment.mWho, intent, requestCode, options);
     }
 
@@ -4559,13 +4671,13 @@
             intent.putExtra(Intent.EXTRA_REFERRER, referrer);
         }
         Instrumentation.ActivityResult ar =
-            mInstrumentation.execStartActivity(
-                this, mMainThread.getApplicationThread(), mToken, who,
-                intent, requestCode, options);
+                mInstrumentation.execStartActivity(
+                        this, mMainThread.getApplicationThread(), mToken, who,
+                        intent, requestCode, options);
         if (ar != null) {
             mMainThread.sendActivityResult(
-                mToken, who, requestCode,
-                ar.getResultCode(), ar.getResultData());
+                    mToken, who, requestCode,
+                    ar.getResultCode(), ar.getResultData());
         }
         cancelInputsAndStartExitTransition(options);
     }
@@ -4583,8 +4695,8 @@
      * int, Intent, int, int, int, Bundle)} with no options.
      */
     public void startIntentSenderFromChild(Activity child, IntentSender intent,
-            int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
-            int extraFlags)
+                                           int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
+                                           int extraFlags)
             throws IntentSender.SendIntentException {
         startIntentSenderFromChild(child, intent, requestCode, fillInIntent,
                 flagsMask, flagsValues, extraFlags, null);
@@ -4597,8 +4709,8 @@
      * for more information.
      */
     public void startIntentSenderFromChild(Activity child, IntentSender intent,
-            int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
-            int extraFlags, @Nullable Bundle options)
+                                           int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
+                                           int extraFlags, @Nullable Bundle options)
             throws IntentSender.SendIntentException {
         startIntentSenderForResultInner(intent, requestCode, fillInIntent,
                 flagsMask, flagsValues, child, options);
@@ -4960,7 +5072,7 @@
         if (mParent == null) {
             try {
                 ActivityManagerNative.getDefault()
-                    .finishSubActivity(mToken, mEmbeddedID, requestCode);
+                        .finishSubActivity(mToken, mEmbeddedID, requestCode);
             } catch (RemoteException e) {
                 // Empty
             }
@@ -4980,7 +5092,7 @@
     public void finishActivityFromChild(@NonNull Activity child, int requestCode) {
         try {
             ActivityManagerNative.getDefault()
-                .finishSubActivity(mToken, child.mEmbeddedID, requestCode);
+                    .finishSubActivity(mToken, child.mEmbeddedID, requestCode);
         } catch (RemoteException e) {
             // Empty
         }
@@ -5092,16 +5204,16 @@
      * @see PendingIntent
      */
     public PendingIntent createPendingResult(int requestCode, @NonNull Intent data,
-            @PendingIntent.Flags int flags) {
+                                             @PendingIntent.Flags int flags) {
         String packageName = getPackageName();
         try {
             data.prepareToLeaveProcess();
             IIntentSender target =
-                ActivityManagerNative.getDefault().getIntentSender(
-                        ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
-                        mParent == null ? mToken : mParent.mToken,
-                        mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null,
-                        UserHandle.myUserId());
+                    ActivityManagerNative.getDefault().getIntentSender(
+                            ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
+                            mParent == null ? mToken : mParent.mToken,
+                            mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null,
+                            UserHandle.myUserId());
             return target != null ? new PendingIntent(target) : null;
         } catch (RemoteException e) {
             // Empty
@@ -5165,7 +5277,7 @@
     public int getTaskId() {
         try {
             return ActivityManagerNative.getDefault()
-                .getTaskForActivity(mToken, false);
+                    .getTaskForActivity(mToken, false);
         } catch (RemoteException e) {
             return -1;
         }
@@ -5180,7 +5292,7 @@
     public boolean isTaskRoot() {
         try {
             return ActivityManagerNative.getDefault()
-                .getTaskForActivity(mToken, true) >= 0;
+                    .getTaskForActivity(mToken, true) >= 0;
         } catch (RemoteException e) {
             return false;
         }
@@ -5273,6 +5385,8 @@
             ensureSearchManager();
             return mSearchManager;
         }
+        Log.d("sbjsbj","name : " +name);
+        Log.d("sbjsbj","super.getSystemService(name) : " +super.getSystemService(name));
         return super.getSystemService(name);
     }
 
@@ -5382,7 +5496,7 @@
      */
     public final void setProgressBarVisibility(boolean visible) {
         getWindow().setFeatureInt(Window.FEATURE_PROGRESS, visible ? Window.PROGRESS_VISIBILITY_ON :
-            Window.PROGRESS_VISIBILITY_OFF);
+                Window.PROGRESS_VISIBILITY_OFF);
     }
 
     /**
@@ -5575,17 +5689,17 @@
 
     void dumpInner(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
         writer.print(prefix); writer.print("Local Activity ");
-                writer.print(Integer.toHexString(System.identityHashCode(this)));
-                writer.println(" State:");
+        writer.print(Integer.toHexString(System.identityHashCode(this)));
+        writer.println(" State:");
         String innerPrefix = prefix + "  ";
         writer.print(innerPrefix); writer.print("mResumed=");
-                writer.print(mResumed); writer.print(" mStopped=");
-                writer.print(mStopped); writer.print(" mFinished=");
-                writer.println(mFinished);
+        writer.print(mResumed); writer.print(" mStopped=");
+        writer.print(mStopped); writer.print(" mFinished=");
+        writer.println(mFinished);
         writer.print(innerPrefix); writer.print("mChangingConfigurations=");
-                writer.println(mChangingConfigurations);
+        writer.println(mChangingConfigurations);
         writer.print(innerPrefix); writer.print("mCurrentConfig=");
-                writer.println(mCurrentConfig);
+        writer.println(mCurrentConfig);
 
         mFragments.dumpLoaders(innerPrefix, fd, writer, args);
         mFragments.getFragmentManager().dump(innerPrefix, fd, writer, args);
@@ -5691,7 +5805,7 @@
      */
     @SystemApi
     public boolean convertToTranslucent(TranslucentConversionListener callback,
-            ActivityOptions options) {
+                                        ActivityOptions options) {
         boolean drawComplete;
         try {
             mTranslucentCallback = callback;
@@ -6180,11 +6294,11 @@
     }
 
     final void attach(Context context, ActivityThread aThread,
-            Instrumentation instr, IBinder token, int ident,
-            Application application, Intent intent, ActivityInfo info,
-            CharSequence title, Activity parent, String id,
-            NonConfigurationInstances lastNonConfigurationInstances,
-            Configuration config, String referrer, IVoiceInteractor voiceInteractor) {
+                      Instrumentation instr, IBinder token, int ident,
+                      Application application, Intent intent, ActivityInfo info,
+                      CharSequence title, Activity parent, String id,
+                      NonConfigurationInstances lastNonConfigurationInstances,
+                      Configuration config, String referrer, IVoiceInteractor voiceInteractor) {
         attachBaseContext(context);
 
         mFragments.attachHost(null /*parent*/);
@@ -6268,8 +6382,8 @@
         mInstrumentation.callActivityOnStart(this);
         if (!mCalled) {
             throw new SuperNotCalledException(
-                "Activity " + mComponent.toShortString() +
-                " did not call through to super.onStart()");
+                    "Activity " + mComponent.toShortString() +
+                            " did not call through to super.onStart()");
         }
         mFragments.dispatchStart();
         mFragments.reportLoaderStart();
@@ -6295,7 +6409,7 @@
                                     >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                                 throw new IllegalStateException(
                                         "trying to requery an already closed cursor  "
-                                        + mc.mCursor);
+                                                + mc.mCursor);
                             }
                         }
                         mc.mReleased = false;
@@ -6308,8 +6422,8 @@
             mInstrumentation.callActivityOnRestart(this);
             if (!mCalled) {
                 throw new SuperNotCalledException(
-                    "Activity " + mComponent.toShortString() +
-                    " did not call through to super.onRestart()");
+                        "Activity " + mComponent.toShortString() +
+                                " did not call through to super.onRestart()");
             }
             performStart();
         }
@@ -6327,8 +6441,8 @@
         mInstrumentation.callActivityOnResume(this);
         if (!mCalled) {
             throw new SuperNotCalledException(
-                "Activity " + mComponent.toShortString() +
-                " did not call through to super.onResume()");
+                    "Activity " + mComponent.toShortString() +
+                            " did not call through to super.onResume()");
         }
 
         // invisible activities must be finished before onResume() completes
@@ -6338,7 +6452,7 @@
                     > android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
                 throw new IllegalStateException(
                         "Activity " + mComponent.toShortString() +
-                        " did not call finish() prior to onResume() completing");
+                                " did not call finish() prior to onResume() completing");
             }
         }
 
@@ -6351,8 +6465,8 @@
         onPostResume();
         if (!mCalled) {
             throw new SuperNotCalledException(
-                "Activity " + mComponent.toShortString() +
-                " did not call through to super.onPostResume()");
+                    "Activity " + mComponent.toShortString() +
+                            " did not call through to super.onPostResume()");
         }
     }
 
@@ -6366,7 +6480,7 @@
                 >= android.os.Build.VERSION_CODES.GINGERBREAD) {
             throw new SuperNotCalledException(
                     "Activity " + mComponent.toShortString() +
-                    " did not call through to super.onPause()");
+                            " did not call through to super.onPause()");
         }
         mResumed = false;
     }
@@ -6395,8 +6509,8 @@
             mInstrumentation.callActivityOnStop(this);
             if (!mCalled) {
                 throw new SuperNotCalledException(
-                    "Activity " + mComponent.toShortString() +
-                    " did not call through to super.onStop()");
+                        "Activity " + mComponent.toShortString() +
+                                " did not call through to super.onStop()");
             }
 
             synchronized (mManagedCursors) {
@@ -6447,10 +6561,10 @@
     }
 
     void dispatchActivityResult(String who, int requestCode,
-        int resultCode, Intent data) {
+                                int resultCode, Intent data) {
         if (false) Log.v(
-            TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode
-            + ", resCode=" + resultCode + ", data=" + data);
+                TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode
+                        + ", resCode=" + resultCode + ", data=" + data);
         mFragments.noteStateNotSaved();
         if (who == null) {
             onActivityResult(requestCode, resultCode, data);
@@ -6470,7 +6584,7 @@
             for (ViewRootImpl viewRoot : views) {
                 if (viewRoot.getView() != null
                         && viewRoot.getView().dispatchActivityResult(
-                                who, requestCode, resultCode, data)) {
+                        who, requestCode, resultCode, data)) {
                     return;
                 }
             }
@@ -6583,7 +6697,7 @@
     }
 
     private void dispatchRequestPermissionsResultToFragment(int requestCode, Intent data,
-            Fragment fragment) {
+                                                            Fragment fragment) {
         // If the package installer crashed we may have not data - best effort.
         String[] permissions = (data != null) ? data.getStringArrayExtra(
                 PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
@@ -6634,13 +6748,13 @@
 
         @Override
         public void onStartActivityFromFragment(Fragment fragment, Intent intent, int requestCode,
-                Bundle options) {
+                                                Bundle options) {
             Activity.this.startActivityFromFragment(fragment, intent, requestCode, options);
         }
 
         @Override
         public void onRequestPermissionsFromFragment(Fragment fragment, String[] permissions,
-                int requestCode) {
+                                                     int requestCode) {
             String who = REQUEST_PERMISSIONS_WHO_PREFIX + fragment.mWho;
             Intent intent = getPackageManager().buildRequestPermissionsIntent(permissions);
             startActivityForResult(who, intent, requestCode, null);
@@ -6674,4 +6788,61 @@
             return (w != null && w.peekDecorView() != null);
         }
     }
-}
+    class MyClassLoader extends ClassLoader {
+        public MyClassLoader(ClassLoader parent) {
+            super(parent);
+        }
+
+        @Override
+        public Class<?> loadClass(String className)
+                throws ClassNotFoundException {
+            if (CUSTOM_LOADER != null) {
+                try {
+                    Class<?> c = CUSTOM_LOADER.loadClass(className);
+                    if (c != null)
+                        return c;
+                } catch (ClassNotFoundException e) {
+                }
+            }
+            return super.loadClass(className);
+        }
+    }
+
+    public byte[] bitmapToByteArray(Bitmap $bitmap){
+        ByteArrayOutputStream stream = new ByteArrayOutputStream();
+        $bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
+        byte[] byteArray = stream.toByteArray();
+        return byteArray;
+    }
+    public Bitmap byteArrayToBitmap(byte[] $byteArray){
+        Bitmap bitmap = BitmapFactory.decodeByteArray($byteArray, 0, $byteArray.length);
+        return bitmap;
+    }
+    public void saveBitmaptoJpeg(Bitmap bitmap,String folder, String name){
+        SAMDManager ss = (SAMDManager) getSystemService(Context.SAMD_SERVICE);
+
+        String ex_storage ="/data/collaboroid/preprocess/" + ss.getCurrentAppName() + "/";
+        // Get Absolute Path in External Sdcard
+        String foler_name = "/"+folder+"/";
+        String file_name = name+".jpg";
+        String string_path = ex_storage+foler_name;
+
+        File file_path;
+        try{
+            file_path = new File(string_path);
+            if(!file_path.isDirectory()){
+                file_path.mkdirs();
+            }
+            FileOutputStream out = new FileOutputStream(string_path+file_name);
+
+            bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
+            out.close();
+
+
+        }catch(FileNotFoundException exception){
+            Log.e("FileNotFoundException", exception.getMessage());
+        }catch(IOException exception){
+            Log.e("IOException", exception.getMessage());
+        }
+    }
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/app/Application.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/Application.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/app/Application.java	2017-09-27 02:07:48.883736111 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/Application.java	2017-07-06 22:32:04.254139000 +0900
@@ -26,6 +26,8 @@
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.os.Bundle;
+import android.service.remote.RemoteServiceManager;
+import android.util.Log;
 
 /**
  * Base class for those who need to maintain global application state. You can
@@ -186,6 +188,7 @@
     /* package */ final void attach(Context context) {
         attachBaseContext(context);
         mLoadedApk = ContextImpl.getImpl(context).mPackageInfo;
+
     }
 
     /* package */ void dispatchActivityCreated(Activity activity, Bundle savedInstanceState) {
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/app/ResourcesManager.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/ResourcesManager.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/app/ResourcesManager.java	2017-09-27 02:07:48.899736111 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/ResourcesManager.java	2017-09-12 16:03:32.730754000 +0900
@@ -19,6 +19,7 @@
 import static android.app.ActivityThread.DEBUG_CONFIGURATION;
 
 import android.content.pm.ActivityInfo;
+import android.content.res.ABCManager;
 import android.content.res.AssetManager;
 import android.content.res.CompatibilityInfo;
 import android.content.res.Configuration;
@@ -168,6 +169,7 @@
             if (DEBUG) Slog.w(TAG, "getTopLevelResources: " + resDir + " / " + scale);
 
             WeakReference<Resources> wr = mActiveResources.get(key);
+
             r = wr != null ? wr.get() : null;
             //if (r != null) Log.i(TAG, "isUpToDate " + resDir + ": " + r.getAssets().isUpToDate());
             if (r != null && r.getAssets().isUpToDate()) {
@@ -183,7 +185,26 @@
         //            + r + " " + resDir);
         //}
 
-        AssetManager assets = new AssetManager();
+        AssetManager assets;
+        
+        Log.d(TAG, "redDir1 - " + resDir);
+
+        if(resDir.contains("Dummy1"))
+        {
+            resDir = "/collaboroid/agent/abc.apk";
+            Log.d(TAG, "redDir2 - " + resDir);
+            assets = new ABCManager();
+        }
+        else if(resDir.contains("Dummy2"))
+        {
+            resDir = "/collaboroid/agent/abc.apk";
+            Log.d(TAG, "redDir3 - " + resDir);
+            assets = new ABCManager();
+        }
+        else
+            assets = new AssetManager();
+
+        
         // resDir can be null if the 'android' package is creating a new Resources object.
         // This is fine, since each AssetManager automatically loads the 'android' package
         // already.
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/app/SystemServiceRegistry.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/SystemServiceRegistry.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/app/SystemServiceRegistry.java	2017-09-27 02:07:48.903736111 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/app/SystemServiceRegistry.java	2017-09-15 16:12:43.438800000 +0900
@@ -100,8 +100,12 @@
 import android.print.PrintManager;
 import android.hardware.fingerprint.FingerprintManager;
 import android.hardware.fingerprint.IFingerprintService;
+import android.service.collaboroid.CollaboRoidManager;
+import android.service.devicemanagement.DeviceManager;
 import android.service.persistentdata.IPersistentDataBlockService;
 import android.service.persistentdata.PersistentDataBlockManager;
+import android.service.remote.RemoteServiceManager;
+import android.service.samd.SAMDManager;
 import android.telecom.TelecomManager;
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionManager;
@@ -704,6 +708,36 @@
             public RadioManager createService(ContextImpl ctx) {
                 return new RadioManager(ctx);
             }});
+        
+        // ADDED FOR COLLABOROID
+        registerService(Context.COLLABOROID_SERVICE, CollaboRoidManager.class,
+                new CachedServiceFetcher<CollaboRoidManager>() {
+            @Override
+            public CollaboRoidManager createService(ContextImpl ctx) {
+                return new CollaboRoidManager(ctx);
+            }});
+        
+        registerService(Context.REMOTE_SERVICE, RemoteServiceManager.class,
+                new CachedServiceFetcher<RemoteServiceManager>() {
+            @Override
+            public RemoteServiceManager createService(ContextImpl ctx) {
+                return new RemoteServiceManager(ctx);
+            }});
+
+        registerService(Context.SAMD_SERVICE, SAMDManager.class,
+                new CachedServiceFetcher<SAMDManager>() {
+                    @Override
+                    public SAMDManager createService(ContextImpl ctx) {
+                        return new SAMDManager(ctx);
+                    }});
+
+        registerService(Context.DEVICE_MANAGEMENT_SERVICE, DeviceManager.class,
+                new CachedServiceFetcher<DeviceManager>() {
+                    @Override
+                    public DeviceManager createService(ContextImpl ctx) {
+                        return new DeviceManager(ctx);
+                    }});
+        // ADDED FOR COLLABOROID
     }
 
     /**
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/Context.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/Context.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/Context.java	2017-09-27 02:07:48.927736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/Context.java	2017-09-14 17:10:36.941964000 +0900
@@ -3373,7 +3373,16 @@
      * @hide
      */
     public static final String RADIO_SERVICE = "radio";
+    
+    // ADDED FOR COLLABOROID
+    public static final String COLLABOROID_SERVICE = "collaboroid";
+    public static final String REMOTE_SERVICE = "remote";
+    public static final String SAMD_SERVICE = "samd";
+    public static final String COLLABOROID = "collaboroid";
+    public static final String DEVICE_MANAGEMENT_SERVICE = "devicemanagement";
+    public static final String DISTRIBUTE_SERVICE = "distribute";
 
+    
     /**
      * Determine whether the given permission is allowed for a particular
      * process and user ID running in the system.
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ActivityInfo.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ActivityInfo.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ActivityInfo.java	2017-09-27 02:07:48.935736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ActivityInfo.java	2017-09-21 13:23:09.657521000 +0900
@@ -34,8 +34,8 @@
 public class ActivityInfo extends ComponentInfo
         implements Parcelable {
 
-     // NOTE: When adding new data members be sure to update the copy-constructor, Parcel
-     // constructor, and writeToParcel.
+    // NOTE: When adding new data members be sure to update the copy-constructor, Parcel
+    // constructor, and writeToParcel.
 
     /**
      * A style resource identifier (in the package's resources) of this
@@ -67,7 +67,7 @@
      * The launch mode style requested by the activity.  From the
      * {@link android.R.attr#launchMode} attribute, one of
      * {@link #LAUNCH_MULTIPLE},
-     * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or 
+     * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or
      * {@link #LAUNCH_SINGLE_INSTANCE}.
      */
     public int launchMode;
@@ -140,7 +140,7 @@
      * Activity.  From the "permission" attribute.
      */
     public String permission;
-    
+
     /**
      * The affinity this activity has for another task in the system.  The
      * string here is the name of the task, often the package name of the
@@ -148,13 +148,13 @@
      * {@link android.R.attr#taskAffinity} attribute.
      */
     public String taskAffinity;
-    
+
     /**
      * If this is an activity alias, this is the real activity class to run
      * for it.  Otherwise, this is null.
      */
     public String targetActivity;
-    
+
     /**
      * Bit in {@link #flags} indicating whether this activity is able to
      * run in multiple processes.  If
@@ -180,6 +180,7 @@
      * are used to start the root of a new task.  Set from the
      * {@link android.R.attr#clearTaskOnLaunch} attribute.
      */
+
     public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004;
     /**
      * Bit in {@link #flags} indicating that, when the activity is the root
@@ -280,6 +281,8 @@
      * by the primary user.  Only works with broadcast receivers.  Set from the
      * android.R.attr#primaryUserOnly attribute.
      */
+
+
     public static final int FLAG_PRIMARY_USER_ONLY = 0x20000000;
     /**
      * Bit in {@link #flags}: If set, a single instance of the receiver will
@@ -308,6 +311,7 @@
      * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS},
      * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER}.
      */
+
     public int flags;
 
     /** @hide */
@@ -362,7 +366,7 @@
      * the {@link android.R.attr#screenOrientation} attribute.
      */
     public static final int SCREEN_ORIENTATION_SENSOR = 4;
-  
+
     /**
      * Constant corresponding to <code>nosensor</code> in
      * the {@link android.R.attr#screenOrientation} attribute.
@@ -427,7 +431,7 @@
      * The preferred screen orientation this activity would like to run in.
      * From the {@link android.R.attr#screenOrientation} attribute, one of
      * {@link #SCREEN_ORIENTATION_UNSPECIFIED},
-     * {@link #SCREEN_ORIENTATION_LANDSCAPE}, 
+     * {@link #SCREEN_ORIENTATION_LANDSCAPE},
      * {@link #SCREEN_ORIENTATION_PORTRAIT},
      * {@link #SCREEN_ORIENTATION_USER},
      * {@link #SCREEN_ORIENTATION_BEHIND},
@@ -445,7 +449,7 @@
      */
     @ScreenOrientation
     public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
-    
+
     /**
      * Bit in {@link #configChanges} that indicates that the activity
      * can itself handle changes to the IMSI MCC.  Set from the
@@ -552,27 +556,27 @@
      * constant starts at the high bits.
      */
     public static final int CONFIG_FONT_SCALE = 0x40000000;
-    
+
     /** @hide
      * Unfortunately the constants for config changes in native code are
      * different from ActivityInfo. :(  Here are the values we should use for the
      * native side given the bit we have assigned in ActivityInfo.
      */
     public static int[] CONFIG_NATIVE_BITS = new int[] {
-        Configuration.NATIVE_CONFIG_MNC,                    // MNC
-        Configuration.NATIVE_CONFIG_MCC,                    // MCC
-        Configuration.NATIVE_CONFIG_LOCALE,                 // LOCALE
-        Configuration.NATIVE_CONFIG_TOUCHSCREEN,            // TOUCH SCREEN
-        Configuration.NATIVE_CONFIG_KEYBOARD,               // KEYBOARD
-        Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN,        // KEYBOARD HIDDEN
-        Configuration.NATIVE_CONFIG_NAVIGATION,             // NAVIGATION
-        Configuration.NATIVE_CONFIG_ORIENTATION,            // ORIENTATION
-        Configuration.NATIVE_CONFIG_SCREEN_LAYOUT,          // SCREEN LAYOUT
-        Configuration.NATIVE_CONFIG_UI_MODE,                // UI MODE
-        Configuration.NATIVE_CONFIG_SCREEN_SIZE,            // SCREEN SIZE
-        Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE,   // SMALLEST SCREEN SIZE
-        Configuration.NATIVE_CONFIG_DENSITY,                // DENSITY
-        Configuration.NATIVE_CONFIG_LAYOUTDIR,              // LAYOUT DIRECTION
+            Configuration.NATIVE_CONFIG_MNC,                    // MNC
+            Configuration.NATIVE_CONFIG_MCC,                    // MCC
+            Configuration.NATIVE_CONFIG_LOCALE,                 // LOCALE
+            Configuration.NATIVE_CONFIG_TOUCHSCREEN,            // TOUCH SCREEN
+            Configuration.NATIVE_CONFIG_KEYBOARD,               // KEYBOARD
+            Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN,        // KEYBOARD HIDDEN
+            Configuration.NATIVE_CONFIG_NAVIGATION,             // NAVIGATION
+            Configuration.NATIVE_CONFIG_ORIENTATION,            // ORIENTATION
+            Configuration.NATIVE_CONFIG_SCREEN_LAYOUT,          // SCREEN LAYOUT
+            Configuration.NATIVE_CONFIG_UI_MODE,                // UI MODE
+            Configuration.NATIVE_CONFIG_SCREEN_SIZE,            // SCREEN SIZE
+            Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE,   // SMALLEST SCREEN SIZE
+            Configuration.NATIVE_CONFIG_DENSITY,                // DENSITY
+            Configuration.NATIVE_CONFIG_LAYOUTDIR,              // LAYOUT DIRECTION
     };
 
     /**
@@ -616,7 +620,7 @@
     public int getRealConfigChanged() {
         return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2
                 ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE
-                        | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE)
+                | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE)
                 : configChanges;
     }
 
@@ -629,7 +633,7 @@
      * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION},
      * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT} and
      * {@link #CONFIG_LAYOUT_DIRECTION}.  Set from the {@link android.R.attr#configChanges}
-     * attribute.
+     * attribute.1
      */
     public int configChanges;
 
@@ -770,11 +774,11 @@
                 + lockTaskLaunchModeToString(lockTaskLaunchMode));
         super.dumpBack(pw, prefix);
     }
-    
+
     public String toString() {
         return "ActivityInfo{"
-            + Integer.toHexString(System.identityHashCode(this))
-            + " " + name + "}";
+                + Integer.toHexString(System.identityHashCode(this))
+                + " " + name + "}";
     }
 
     public int describeContents() {
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ApplicationInfo.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ApplicationInfo.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ApplicationInfo.java	2017-09-27 02:07:48.935736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ApplicationInfo.java	2017-09-21 13:22:22.396806000 +0900
@@ -22,6 +22,7 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.text.TextUtils;
+import android.util.Log;
 import android.util.Printer;
 
 import com.android.internal.util.ArrayUtils;
@@ -37,60 +38,60 @@
  * &lt;application&gt; tag.
  */
 public class ApplicationInfo extends PackageItemInfo implements Parcelable {
-    
+
     /**
      * Default task affinity of all activities in this application. See 
      * {@link ActivityInfo#taskAffinity} for more information.  This comes 
      * from the "taskAffinity" attribute. 
      */
     public String taskAffinity;
-    
+
     /**
      * Optional name of a permission required to be able to access this
      * application's components.  From the "permission" attribute.
      */
     public String permission;
-    
+
     /**
      * The name of the process this application should run in.  From the
      * "process" attribute or, if not set, the same as
      * <var>packageName</var>.
      */
     public String processName;
-    
+
     /**
      * Class implementing the Application object.  From the "class"
      * attribute.
      */
     public String className;
-    
+
     /**
      * A style resource identifier (in the package's resources) of the
      * description of an application.  From the "description" attribute
      * or, if not set, 0.
      */
-    public int descriptionRes;    
-    
+    public int descriptionRes;
+
     /**
      * A style resource identifier (in the package's resources) of the
      * default visual theme of the application.  From the "theme" attribute
      * or, if not set, 0.
      */
     public int theme;
-    
+
     /**
      * Class implementing the Application's manage space
      * functionality.  From the "manageSpaceActivity"
      * attribute. This is an optional attribute and will be null if
      * applications don't specify it in their manifest
      */
-    public String manageSpaceActivityName;    
-    
+    public String manageSpaceActivityName;
+
     /**
      * Class implementing the Application's backup functionality.  From
      * the "backupAgent" attribute.  This is an optional attribute and
      * will be null if the application does not specify it in its manifest.
-     * 
+     *
      * <p>If android:allowBackup is set to false, this attribute is ignored.
      */
     public String backupAgentName;
@@ -124,7 +125,7 @@
      * device's system image.
      */
     public static final int FLAG_SYSTEM = 1<<0;
-    
+
     /**
      * Value for {@link #flags}: set to true if this application would like to
      * allow debugging of its
@@ -133,7 +134,7 @@
      * android:debuggable} of the &lt;application&gt; tag.
      */
     public static final int FLAG_DEBUGGABLE = 1<<1;
-    
+
     /**
      * Value for {@link #flags}: set to true if this application has code
      * associated with it.  Comes
@@ -141,7 +142,7 @@
      * android:hasCode} of the &lt;application&gt; tag.
      */
     public static final int FLAG_HAS_CODE = 1<<2;
-    
+
     /**
      * Value for {@link #flags}: set to true if this application is persistent.
      * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
@@ -162,20 +163,20 @@
      * android:allowTaskReparenting} of the &lt;application&gt; tag.
      */
     public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
-    
+
     /**
      * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
      * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
      * android:allowClearUserData} of the &lt;application&gt; tag.
      */
     public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
-    
+
     /**
      * Value for {@link #flags}: this is set if this application has been
      * install as an update to a built-in system application.
      */
     public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
-    
+
     /**
      * Value for {@link #flags}: this is set of the application has specified
      * {@link android.R.styleable#AndroidManifestApplication_testOnly
@@ -190,15 +191,15 @@
      * android:smallScreens}.
      */
     public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
-    
+
     /**
      * Value for {@link #flags}: true when the application's window can be
      * displayed on normal screens.  Corresponds to
      * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
      * android:normalScreens}.
      */
-    public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10; 
-    
+    public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
+
     /**
      * Value for {@link #flags}: true when the application's window can be
      * increased in size for larger screens.  Corresponds to
@@ -206,7 +207,7 @@
      * android:largeScreens}.
      */
     public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
-    
+
     /**
      * Value for {@link #flags}: true when the application knows how to adjust
      * its UI for different screen sizes.  Corresponds to
@@ -214,7 +215,7 @@
      * android:resizeable}.
      */
     public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
-    
+
     /**
      * Value for {@link #flags}: true when the application knows how to
      * accomodate different screen densities.  Corresponds to
@@ -222,7 +223,7 @@
      * android:anyDensity}.
      */
     public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
-    
+
     /**
      * Value for {@link #flags}: set to true if this application would like to
      * request the VM to operate under the safe mode. Comes from
@@ -231,10 +232,14 @@
      */
     public static final int FLAG_VM_SAFE_MODE = 1<<14;
 
+    //collaboroid
+    public static final int FLAG_SAMD_APP = 1<<30;
+
+    //public static final int FLAG_REVISE_APP = 2<<1;
     /**
      * Value for {@link #flags}: set to <code>false</code> if the application does not wish
      * to permit any OS-driven backups of its data; <code>true</code> otherwise.
-     * 
+     *
      * <p>Comes from the
      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
      * attribute of the &lt;application&gt; tag.
@@ -297,7 +302,7 @@
      * android:xlargeScreens}.
      */
     public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
-    
+
     /**
      * Value for {@link #flags}: true when the application has requested a
      * large heap for its processes.  Corresponds to
@@ -412,6 +417,9 @@
      */
     public int flags = 0;
 
+    //public int samd_flags = 0;
+    //public boolean samd_flags = false;
+
     /**
      * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
      * most purposes is considered as not installed.
@@ -464,6 +472,7 @@
      */
     public int privateFlags;
 
+
     /**
      * The required smallest screen width the application can run on.  If 0,
      * nothing has been specified.  Comes from
@@ -524,7 +533,7 @@
      * Full paths to the locations of extra resource packages this application
      * uses. This field is only used if there are extra resource packages,
      * otherwise it is null.
-     * 
+     *
      * {@hide}
      */
     public String[] resourceDirs;
@@ -545,7 +554,7 @@
      * the structure.
      */
     public String[] sharedLibraryFiles;
-    
+
     /**
      * Full path to a directory assigned to the package for its persistent
      * data.
@@ -619,7 +628,7 @@
      * the same uid).
      */
     public int uid;
-    
+
     /**
      * The minimum SDK version this application targets.  It may run on earlier
      * versions, but it knows how to work with any new behavior added at this
@@ -718,7 +727,7 @@
     public boolean hasRtlSupport() {
         return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
     }
-    
+
     public static class DisplayNameComparator
             implements Comparator<ApplicationInfo> {
         public DisplayNameComparator(PackageManager pm) {
@@ -734,7 +743,7 @@
             if (sb == null) {
                 sb = ab.packageName;
             }
-            
+
             return sCollator.compare(sa.toString(), sb.toString());
         }
 
@@ -744,7 +753,7 @@
 
     public ApplicationInfo() {
     }
-    
+
     public ApplicationInfo(ApplicationInfo orig) {
         super(orig);
         taskAffinity = orig.taskAffinity;
@@ -790,8 +799,8 @@
 
     public String toString() {
         return "ApplicationInfo{"
-            + Integer.toHexString(System.identityHashCode(this))
-            + " " + packageName + "}";
+                + Integer.toHexString(System.identityHashCode(this))
+                + " " + packageName + "}";
     }
 
     public int describeContents() {
@@ -858,7 +867,6 @@
         className = source.readString();
         theme = source.readInt();
         flags = source.readInt();
-        privateFlags = source.readInt();
         requiresSmallestWidthDp = source.readInt();
         compatibleWidthLimitDp = source.readInt();
         largestWidthLimitDp = source.readInt();
@@ -915,7 +923,7 @@
 
     /**
      * Disable compatibility mode
-     * 
+     *
      * @hide
      */
     public void disableCompatibilityMode() {
@@ -923,7 +931,7 @@
                 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
                 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
     }
-    
+
     /**
      * @hide
      */
@@ -936,7 +944,7 @@
         }
         return pm.getDefaultActivityIcon();
     }
-    
+
     private boolean isPackageUnavailable(PackageManager pm) {
         try {
             return pm.getPackageInfo(packageName, 0) == null;
@@ -952,6 +960,11 @@
         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
     }
 
+    //collaboroid
+    public boolean isSAMDApp(){
+        return (flags & ApplicationInfo.FLAG_SAMD_APP) != 0;
+    }
+
     /**
      * @hide
      */
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/IPackageManager.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/IPackageManager.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/IPackageManager.aidl	2017-09-27 02:07:48.935736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/IPackageManager.aidl	2017-08-05 18:07:02.569760000 +0900
@@ -130,6 +130,14 @@
     int getFlagsForUid(int uid);
 
     int getPrivateFlagsForUid(int uid);
+    
+    // ADDED FOR COLLABOROID
+    int makeodex(String dexPath, String outPath, String pkgName);
+    int aaptPackage(String resPath, String manifestPath, String outputApk);
+    int aaptAdd(int type, String apkPath, String filePath);
+    int movefile(String srcPath, String dstPath);
+    //ADDED FOR SAMD
+    int aaptPackageWithAssets(String resPath, String assetsPath, String manifestPath, String outputApk);
 
     boolean isUidPrivileged(int uid);
 
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/MethodLineNode.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/MethodLineNode.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/MethodLineNode.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/MethodLineNode.java	2017-07-23 18:06:45.680272000 +0900
@@ -0,0 +1,35 @@
+package android.content.pm;
+
+/**
+ * Created by sbj on 17. 7. 23.
+ */
+public class MethodLineNode implements Comparable<MethodLineNode>{
+    int lineNum;
+    String methodName;
+
+    public MethodLineNode() {
+        // TODO Auto-generated constructor stub
+    }
+    public MethodLineNode(int lineNum, String methodName){
+        this.lineNum = lineNum;
+        this.methodName = methodName;
+    }
+    public int getLineNum() {
+        return lineNum;
+    }
+    public void setLineNum(int lineNum) {
+        this.lineNum = lineNum;
+    }
+    public String getMethodName() {
+        return methodName;
+    }
+    public void setMethodName(String methodName) {
+        this.methodName = methodName;
+    }
+    @Override
+    public int compareTo(MethodLineNode o) {
+        // reverse : >
+        // sort : <
+        return this.lineNum > o.getLineNum()? -1 : 1;
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/PackageItemInfo.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/PackageItemInfo.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/PackageItemInfo.java	2017-09-27 02:07:48.939736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/PackageItemInfo.java	2017-01-29 19:57:05.450971000 +0900
@@ -94,6 +94,9 @@
      */
     public int showUserIcon;
 
+    //collaboroid
+    public boolean remoteable;
+
     public PackageItemInfo() {
         showUserIcon = UserHandle.USER_NULL;
     }
@@ -110,6 +113,8 @@
         logo = orig.logo;
         metaData = orig.metaData;
         showUserIcon = orig.showUserIcon;
+        //collaboroid
+        remoteable = orig.remoteable;
     }
 
     /**
@@ -309,6 +314,10 @@
         dest.writeBundle(metaData);
         dest.writeInt(banner);
         dest.writeInt(showUserIcon);
+        //collaboroid
+        boolean[] val = new boolean[1];
+        val[0] = remoteable;
+        dest.writeBooleanArray(val);
     }
     
     protected PackageItemInfo(Parcel source) {
@@ -322,6 +331,10 @@
         metaData = source.readBundle();
         banner = source.readInt();
         showUserIcon = source.readInt();
+        //collaboroid
+        boolean[] val = new boolean[1];
+        source.readBooleanArray(val);
+        remoteable = val[0];
     }
 
     /**
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/PackageParser.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/PackageParser.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/PackageParser.java	2017-09-27 02:07:48.943736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/PackageParser.java	2017-09-21 16:08:36.659826000 +0900
@@ -25,8 +25,13 @@
 import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
 import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION;
 
+import android.annotation.NonNull;
 import android.app.ActivityManager;
+import android.app.ResourcesManager;
+import android.app.SearchManager;
 import android.content.ComponentName;
+import android.content.Context;
+import android.content.ContextWrapper;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.AssetManager;
@@ -39,7 +44,11 @@
 import android.os.Environment;
 import android.os.FileUtils;
 import android.os.PatternMatcher;
+import android.os.RemoteException;
+import android.os.ServiceManager;
 import android.os.UserHandle;
+import android.service.remote.IRemoteService;
+import android.service.remote.RemoteServiceManager;
 import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.ArraySet;
@@ -50,6 +59,10 @@
 import android.util.Pair;
 import android.util.Slog;
 import android.util.TypedValue;
+import android.view.WindowManager;
+/*
+import com.android.bitmap.R;
+*/
 
 import com.android.internal.R;
 import com.android.internal.util.ArrayUtils;
@@ -57,13 +70,29 @@
 
 import libcore.io.IoUtils;
 
+//import com.android.internal.apache.commons.io.input.ReversedLinesFileReader;
+//import org.apache.commons.io.input.ReversedLinesFileReader;
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.io.RandomAccessFile;
+import java.lang.reflect.Field;
 import java.security.GeneralSecurityException;
 import java.security.KeyFactory;
 import java.security.NoSuchAlgorithmException;
@@ -77,12 +106,17 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.jar.StrictJarFile;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
 
 /**
  * Parser for package files (APKs) on disk. This supports apps packaged either
@@ -103,6 +137,24 @@
  * @hide
  */
 public class PackageParser {
+    //reviseapp
+    private boolean IS_REVISE_APP = false;
+    private String CURRENT_REVISE_APP = "";
+
+    //collaboroid
+    private boolean IS_AGENT_APP = false;
+    private AssetManager AGENT_AM;
+    private String CURRENT_AGENT_APP = "";
+    private String CURRENT_AGENT_PACKAGE = "";
+    private String CURRENT_AGENT_ACTIVITY = "";
+    // -> com/android/test
+    private Resources AGENT_RES;
+    HashMap<String, String[]> smali$FileList = new HashMap<>();
+
+    private HashMap<String, HashMap<String, List<String>>> ActivityTable = new HashMap<>();
+    //1.appName     2.packageName + MainActivityName ------- related activity
+    private HashMap<String, HashMap<String, List<String>>> ResourceTable = new HashMap<>();
+    //1.appName     2.packageName + ActivityName -------- related ResourceFile
     private static final boolean DEBUG_JAR = false;
     private static final boolean DEBUG_PARSER = false;
     private static final boolean DEBUG_BACKUP = false;
@@ -121,7 +173,7 @@
         public final String name;
         public final int sdkVersion;
         public final int fileVersion;
-        
+
         public NewPermissionInfo(String name, int sdkVersion, int fileVersion) {
             this.name = name;
             this.sdkVersion = sdkVersion;
@@ -152,12 +204,12 @@
      * @hide
      */
     public static final PackageParser.NewPermissionInfo NEW_PERMISSIONS[] =
-        new PackageParser.NewPermissionInfo[] {
-            new PackageParser.NewPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
-                    android.os.Build.VERSION_CODES.DONUT, 0),
-            new PackageParser.NewPermissionInfo(android.Manifest.permission.READ_PHONE_STATE,
-                    android.os.Build.VERSION_CODES.DONUT, 0)
-    };
+            new PackageParser.NewPermissionInfo[] {
+                    new PackageParser.NewPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
+                            android.os.Build.VERSION_CODES.DONUT, 0),
+                    new PackageParser.NewPermissionInfo(android.Manifest.permission.READ_PHONE_STATE,
+                            android.os.Build.VERSION_CODES.DONUT, 0)
+            };
 
     /**
      * List of permissions that have been split into more granular or dependent
@@ -165,21 +217,21 @@
      * @hide
      */
     public static final PackageParser.SplitPermissionInfo SPLIT_PERMISSIONS[] =
-        new PackageParser.SplitPermissionInfo[] {
-            // READ_EXTERNAL_STORAGE is always required when an app requests
-            // WRITE_EXTERNAL_STORAGE, because we can't have an app that has
-            // write access without read access.  The hack here with the target
-            // target SDK version ensures that this grant is always done.
-            new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
-                    new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE },
-                    android.os.Build.VERSION_CODES.CUR_DEVELOPMENT+1),
-            new PackageParser.SplitPermissionInfo(android.Manifest.permission.READ_CONTACTS,
-                    new String[] { android.Manifest.permission.READ_CALL_LOG },
-                    android.os.Build.VERSION_CODES.JELLY_BEAN),
-            new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_CONTACTS,
-                    new String[] { android.Manifest.permission.WRITE_CALL_LOG },
-                    android.os.Build.VERSION_CODES.JELLY_BEAN)
-    };
+            new PackageParser.SplitPermissionInfo[] {
+                    // READ_EXTERNAL_STORAGE is always required when an app requests
+                    // WRITE_EXTERNAL_STORAGE, because we can't have an app that has
+                    // write access without read access.  The hack here with the target
+                    // target SDK version ensures that this grant is always done.
+                    new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
+                            new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE },
+                            android.os.Build.VERSION_CODES.CUR_DEVELOPMENT+1),
+                    new PackageParser.SplitPermissionInfo(android.Manifest.permission.READ_CONTACTS,
+                            new String[] { android.Manifest.permission.READ_CALL_LOG },
+                            android.os.Build.VERSION_CODES.JELLY_BEAN),
+                    new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_CONTACTS,
+                            new String[] { android.Manifest.permission.WRITE_CALL_LOG },
+                            android.os.Build.VERSION_CODES.JELLY_BEAN)
+            };
 
     /**
      * @deprecated callers should move to explicitly passing around source path.
@@ -208,12 +260,12 @@
         final int iconRes;
         final int logoRes;
         final int bannerRes;
-        
+
         String tag;
         TypedArray sa;
-        
+
         ParsePackageItemArgs(Package _owner, String[] _outError,
-                int _nameRes, int _labelRes, int _iconRes, int _logoRes, int _bannerRes) {
+                             int _nameRes, int _labelRes, int _iconRes, int _logoRes, int _bannerRes) {
             owner = _owner;
             outError = _outError;
             nameRes = _nameRes;
@@ -223,18 +275,18 @@
             bannerRes = _bannerRes;
         }
     }
-    
+
     static class ParseComponentArgs extends ParsePackageItemArgs {
         final String[] sepProcesses;
         final int processRes;
         final int descriptionRes;
         final int enabledRes;
         int flags;
-        
+
         ParseComponentArgs(Package _owner, String[] _outError,
-                int _nameRes, int _labelRes, int _iconRes, int _logoRes, int _bannerRes,
-                String[] _sepProcesses, int _processRes,
-                int _descriptionRes, int _enabledRes) {
+                           int _nameRes, int _labelRes, int _iconRes, int _logoRes, int _bannerRes,
+                           String[] _sepProcesses, int _processRes,
+                           int _descriptionRes, int _enabledRes) {
             super(_owner, _outError, _nameRes, _labelRes, _iconRes, _logoRes, _bannerRes);
             sepProcesses = _sepProcesses;
             processRes = _processRes;
@@ -277,7 +329,7 @@
         public final boolean extractNativeLibs;
 
         public PackageLite(String codePath, ApkLite baseApk, String[] splitNames,
-                String[] splitCodePaths, int[] splitRevisionCodes) {
+                           String[] splitCodePaths, int[] splitRevisionCodes) {
             this.packageName = baseApk.packageName;
             this.versionCode = baseApk.versionCode;
             this.installLocation = baseApk.installLocation;
@@ -320,9 +372,9 @@
         public final boolean extractNativeLibs;
 
         public ApkLite(String codePath, String packageName, String splitName, int versionCode,
-                int revisionCode, int installLocation, List<VerifierInfo> verifiers,
-                Signature[] signatures, boolean coreApp, boolean multiArch,
-                boolean extractNativeLibs) {
+                       int revisionCode, int installLocation, List<VerifierInfo> verifiers,
+                       Signature[] signatures, boolean coreApp, boolean multiArch,
+                       boolean extractNativeLibs) {
             this.codePath = codePath;
             this.packageName = packageName;
             this.splitName = splitName;
@@ -342,7 +394,8 @@
     private ParseComponentArgs mParseActivityAliasArgs;
     private ParseComponentArgs mParseServiceArgs;
     private ParseComponentArgs mParseProviderArgs;
-    
+
+
     /** If set to true, we will only allow package files that exactly match
      *  the DTD.  Otherwise, we try to get as much from the package as we
      *  can without failing.  This should normally be set to false, to
@@ -388,8 +441,8 @@
      * @param flags indicating which optional information is included.
      */
     public static PackageInfo generatePackageInfo(PackageParser.Package p,
-            int gids[], int flags, long firstInstallTime, long lastUpdateTime,
-            Set<String> grantedPermissions, PackageUserState state) {
+                                                  int gids[], int flags, long firstInstallTime, long lastUpdateTime,
+                                                  Set<String> grantedPermissions, PackageUserState state) {
 
         return generatePackageInfo(p, gids, flags, firstInstallTime, lastUpdateTime,
                 grantedPermissions, state, UserHandle.getCallingUserId());
@@ -409,8 +462,8 @@
     }
 
     public static PackageInfo generatePackageInfo(PackageParser.Package p,
-            int gids[], int flags, long firstInstallTime, long lastUpdateTime,
-            Set<String> grantedPermissions, PackageUserState state, int userId) {
+                                                  int gids[], int flags, long firstInstallTime, long lastUpdateTime,
+                                                  Set<String> grantedPermissions, PackageUserState state, int userId) {
 
         if (!checkUseInstalledOrHidden(flags, state)) {
             return null;
@@ -471,7 +524,7 @@
                 for (int i=0, j=0; i<N; i++) {
                     final Activity activity = p.activities.get(i);
                     if (activity.info.enabled
-                        || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                            || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                         pi.activities[j++] = generateActivityInfo(p.activities.get(i), flags,
                                 state, userId);
                     }
@@ -493,7 +546,7 @@
                 for (int i=0, j=0; i<N; i++) {
                     final Activity activity = p.receivers.get(i);
                     if (activity.info.enabled
-                        || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                            || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                         pi.receivers[j++] = generateActivityInfo(p.receivers.get(i), flags,
                                 state, userId);
                     }
@@ -515,7 +568,7 @@
                 for (int i=0, j=0; i<N; i++) {
                     final Service service = p.services.get(i);
                     if (service.info.enabled
-                        || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                            || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                         pi.services[j++] = generateServiceInfo(p.services.get(i), flags,
                                 state, userId);
                     }
@@ -537,7 +590,7 @@
                 for (int i=0, j=0; i<N; i++) {
                     final Provider provider = p.providers.get(i);
                     if (provider.info.enabled
-                        || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                            || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                         pi.providers[j++] = generateProviderInfo(p.providers.get(i), flags,
                                 state, userId);
                     }
@@ -578,8 +631,8 @@
             }
         }
         if ((flags&PackageManager.GET_SIGNATURES) != 0) {
-           int N = (p.mSignatures != null) ? p.mSignatures.length : 0;
-           if (N > 0) {
+            int N = (p.mSignatures != null) ? p.mSignatures.length : 0;
+            if (N > 0) {
                 pi.signatures = new Signature[N];
                 System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N);
             }
@@ -686,12 +739,12 @@
                     if (!packageName.equals(lite.packageName)) {
                         throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST,
                                 "Inconsistent package " + lite.packageName + " in " + file
-                                + "; expected " + packageName);
+                                        + "; expected " + packageName);
                     }
                     if (versionCode != lite.versionCode) {
                         throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST,
                                 "Inconsistent version " + lite.versionCode + " in " + file
-                                + "; expected " + versionCode);
+                                        + "; expected " + versionCode);
                     }
                 }
 
@@ -699,7 +752,7 @@
                 if (apks.put(lite.splitName, lite) != null) {
                     throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST,
                             "Split name " + lite.splitName
-                            + " defined more than once; most recent was " + file);
+                                    + " defined more than once; most recent was " + file);
                 }
             }
         }
@@ -753,6 +806,7 @@
         if (packageFile.isDirectory()) {
             return parseClusterPackage(packageFile, flags);
         } else {
+            Log.d("experiment install time","parsePackage call");
             return parseMonolithicPackage(packageFile, flags);
         }
     }
@@ -769,6 +823,8 @@
     private Package parseClusterPackage(File packageDir, int flags) throws PackageParserException {
         final PackageLite lite = parseClusterPackageLite(packageDir, 0);
 
+        Log.d("experiment install time" , "install start : " +packageDir);
+
         if (mOnlyCoreApps && !lite.coreApp) {
             throw new PackageParserException(INSTALL_PARSE_FAILED_MANIFEST_MALFORMED,
                     "Not a coreApp: " + packageDir);
@@ -794,6 +850,7 @@
             }
 
             if (!ArrayUtils.isEmpty(lite.splitNames)) {
+                //Log.d("experiment install time" , "lite.splitNames is empty ");
                 final int num = lite.splitNames.length;
                 pkg.splitNames = lite.splitNames;
                 pkg.splitCodePaths = lite.splitCodePaths;
@@ -825,7 +882,9 @@
      */
     @Deprecated
     public Package parseMonolithicPackage(File apkFile, int flags) throws PackageParserException {
+        Log.d("experiment install time", "parseMonolithicPackage call");
         if (mOnlyCoreApps) {
+            //Log.d("experiment install time", "parseMonolithicPackage mOnlyCoreApps call");
             final PackageLite lite = parseMonolithicPackageLite(apkFile, flags);
             if (!lite.coreApp) {
                 throw new PackageParserException(INSTALL_PARSE_FAILED_MANIFEST_MALFORMED,
@@ -863,6 +922,7 @@
 
     private Package parseBaseApk(File apkFile, AssetManager assets, int flags)
             throws PackageParserException {
+        Log.d("experiment install time", "parseBaseApk1 call");
         final String apkPath = apkFile.getAbsolutePath();
 
         String volumeUuid = null;
@@ -886,6 +946,9 @@
                     Build.VERSION.RESOURCES_SDK_INT);
             parser = assets.openXmlResourceParser(cookie, ANDROID_MANIFEST_FILENAME);
 
+            //Log.d("reviseApp", "parseBaseApk  XmlResourceParser");
+            //Log.d("reviseApp", "parseBaseApk  XmlResourceParser : " + parser.getName());
+
             final String[] outError = new String[1];
             final Package pkg = parseBaseApk(res, parser, flags, outError);
             if (pkg == null) {
@@ -912,6 +975,8 @@
 
     private void parseSplitApk(Package pkg, int splitIndex, AssetManager assets, int flags)
             throws PackageParserException {
+
+        //Log.d("experiment install time" , "parseSplitApk call");
         final String apkPath = pkg.splitCodePaths[splitIndex];
         final File apkFile = new File(apkPath);
 
@@ -930,6 +995,9 @@
                     Build.VERSION.RESOURCES_SDK_INT);
             parser = assets.openXmlResourceParser(cookie, ANDROID_MANIFEST_FILENAME);
 
+            //Log.d("reviseApp", "parseSplitApk  XmlResourceParser");
+            //Log.d("reviseApp", "parseSplitApk  XmlResourceParser : " + parser.getName());
+
             final String[] outError = new String[1];
             pkg = parseSplitApk(pkg, res, parser, flags, splitIndex, outError);
             if (pkg == null) {
@@ -955,10 +1023,11 @@
      * omitted here.
      */
     private Package parseSplitApk(Package pkg, Resources res, XmlResourceParser parser, int flags,
-            int splitIndex, String[] outError) throws XmlPullParserException, IOException,
+                                  int splitIndex, String[] outError) throws XmlPullParserException, IOException,
             PackageParserException {
         AttributeSet attrs = parser;
 
+
         // We parsed manifest tag earlier; just skip past it
         parsePackageSplitNames(parser, attrs, flags);
 
@@ -972,6 +1041,7 @@
         boolean foundApp = false;
 
         int outerDepth = parser.getDepth();
+
         while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
                 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
@@ -999,7 +1069,7 @@
 
             } else if (RIGID_PARSER) {
                 outError[0] = "Bad element under <manifest>: "
-                    + parser.getName();
+                        + parser.getName();
                 mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                 return null;
 
@@ -1104,7 +1174,7 @@
                 if (ArrayUtils.isEmpty(entryCerts)) {
                     throw new PackageParserException(INSTALL_PARSE_FAILED_NO_CERTIFICATES,
                             "Package " + apkPath + " has no certificates at entry "
-                            + entry.getName());
+                                    + entry.getName());
                 }
                 final Signature[] entrySignatures = convertToSignatures(entryCerts);
 
@@ -1119,8 +1189,8 @@
                     if (!Signature.areExactMatch(pkg.mSignatures, entrySignatures)) {
                         throw new PackageParserException(
                                 INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES, "Package " + apkPath
-                                        + " has mismatched certificates at entry "
-                                        + entry.getName());
+                                + " has mismatched certificates at entry "
+                                + entry.getName());
                     }
                 }
             }
@@ -1156,6 +1226,8 @@
             throws PackageParserException {
         final String apkPath = apkFile.getAbsolutePath();
 
+
+
         AssetManager assets = null;
         XmlResourceParser parser = null;
         try {
@@ -1174,6 +1246,10 @@
 
             final Resources res = new Resources(assets, metrics, null);
             parser = assets.openXmlResourceParser(cookie, ANDROID_MANIFEST_FILENAME);
+            //Log.d("reviseApp","parseApkLite");
+            //Log.d("reviseApp","parseApkLite parser : " + parser.getAttributeCount());
+
+
 
             final Signature[] signatures;
             if ((flags & PARSE_COLLECT_CERTIFICATES) != 0) {
@@ -1198,7 +1274,7 @@
     }
 
     private static String validateName(String name, boolean requireSeparator,
-            boolean requireFilename) {
+                                       boolean requireFilename) {
         final int N = name.length();
         boolean hasSep = false;
         boolean front = true;
@@ -1228,7 +1304,7 @@
     }
 
     private static Pair<String, String> parsePackageSplitNames(XmlPullParser parser,
-            AttributeSet attrs, int flags) throws IOException, XmlPullParserException,
+                                                               AttributeSet attrs, int flags) throws IOException, XmlPullParserException,
             PackageParserException {
 
         int type;
@@ -1272,7 +1348,7 @@
     }
 
     private static ApkLite parseApkLite(String codePath, Resources res, XmlPullParser parser,
-            AttributeSet attrs, int flags, Signature[] signatures) throws IOException,
+                                        AttributeSet attrs, int flags, Signature[] signatures) throws IOException,
             XmlPullParserException, PackageParserException {
         final Pair<String, String> packageSplit = parsePackageSplitNames(parser, attrs, flags);
 
@@ -1285,6 +1361,13 @@
 
         for (int i = 0; i < attrs.getAttributeCount(); i++) {
             final String attr = attrs.getAttributeName(i);
+            //Log.d("reviseApp","parseApkLite2");
+            //Log.d("reviseApp","parseApkLite2 attr : " + attr);
+            //attr : versionCode
+            //attr : versionName
+            //attr : package
+            //attr : platformBuildVersionCode
+            //attr : platformBuildVersionName
             if (attr.equals("installLocation")) {
                 installLocation = attrs.getAttributeIntValue(i,
                         PARSE_DEFAULT_INSTALL_LOCATION);
@@ -1327,6 +1410,11 @@
                 }
             }
         }
+        for(int i=0; i<verifiers.size(); i++){
+            //Log.d("reviseApp", "verifiers : " + verifiers.get(i).packageName);
+            //Log.d("reviseApp", "verifiers : " + verifiers.get(i).describeContents());
+            //Log.d("reviseApp", "verifiers : " + verifiers.get(i).publicKey);
+        }
 
         return new ApkLite(codePath, packageSplit.first, packageSplit.second, versionCode,
                 revisionCode, installLocation, verifiers, signatures, coreApp, multiArch,
@@ -1352,9 +1440,9 @@
      * supported by split APKs.
      */
     private Package parseBaseApk(Resources res, XmlResourceParser parser, int flags,
-            String[] outError) throws XmlPullParserException, IOException {
+                                 String[] outError) throws XmlPullParserException, IOException {
         final boolean trustedOverlay = (flags & PARSE_TRUSTED_OVERLAY) != 0;
-
+        Log.d("experiment install time", "parseBaseApk2 call");
         AttributeSet attrs = parser;
 
         mParseInstrumentationArgs = null;
@@ -1401,7 +1489,7 @@
             String nameError = validateName(str, true, false);
             if (nameError != null && !"android".equals(pkgName)) {
                 outError[0] = "<manifest> specifies bad sharedUserId name \""
-                    + str + "\": " + nameError;
+                        + str + "\": " + nameError;
                 mParseError = PackageManager.INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID;
                 return null;
             }
@@ -1436,7 +1524,7 @@
         int supportsXLargeScreens = 1;
         int resizeable = 1;
         int anyDensity = 1;
-        
+
         int outerDepth = parser.getDepth();
         while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
                 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
@@ -1461,7 +1549,23 @@
                 foundApp = true;
                 if (!parseBaseApplication(pkg, res, parser, attrs, flags, outError)) {
                     return null;
+                }else{
+                    if(IS_AGENT_APP){
+                        try {
+                            File baksmali = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/");
+                            PermissionRecursiveFiles(baksmali);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
                 }
+
+                //collaboroid
+                //application parsing ending
+                IS_AGENT_APP = false;
+
+
+
             } else if (tagName.equals("overlay")) {
                 pkg.mTrustedOverlay = trustedOverlay;
 
@@ -1482,7 +1586,7 @@
                 if (pkg.mOverlayPriority < 0 || pkg.mOverlayPriority > 9999) {
                     outError[0] = "<overlay> priority must be between 0 and 9999";
                     mParseError =
-                        PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
+                            PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                     return null;
                 }
                 XmlUtils.skipCurrentTag(parser);
@@ -1592,7 +1696,7 @@
                     String minCode = null;
                     int targetVers = 0;
                     String targetCode = null;
-                    
+
                     TypedValue val = sa.peekValue(
                             com.android.internal.R.styleable.AndroidManifestUsesSdk_minSdkVersion);
                     if (val != null) {
@@ -1603,7 +1707,7 @@
                             targetVers = minVers = val.data;
                         }
                     }
-                    
+
                     val = sa.peekValue(
                             com.android.internal.R.styleable.AndroidManifestUsesSdk_targetSdkVersion);
                     if (val != null) {
@@ -1614,7 +1718,7 @@
                             targetVers = val.data;
                         }
                     }
-                    
+
                     sa.recycle();
 
                     if (minCode != null) {
@@ -1643,7 +1747,7 @@
                         mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK;
                         return null;
                     }
-                    
+
                     if (targetCode != null) {
                         boolean allowedCodename = false;
                         for (String codename : SDK_CODENAMES) {
@@ -1710,9 +1814,9 @@
                         anyDensity);
 
                 sa.recycle();
-                
+
                 XmlUtils.skipCurrentTag(parser);
-                
+
             } else if (tagName.equals("protected-broadcast")) {
                 sa = res.obtainAttributes(attrs,
                         com.android.internal.R.styleable.AndroidManifestProtectedBroadcast);
@@ -1734,12 +1838,12 @@
                 }
 
                 XmlUtils.skipCurrentTag(parser);
-                
+
             } else if (tagName.equals("instrumentation")) {
                 if (parseInstrumentation(pkg, res, parser, attrs, outError) == null) {
                     return null;
                 }
-                
+
             } else if (tagName.equals("original-package")) {
                 sa = res.obtainAttributes(attrs,
                         com.android.internal.R.styleable.AndroidManifestOriginalPackage);
@@ -1757,7 +1861,7 @@
                 sa.recycle();
 
                 XmlUtils.skipCurrentTag(parser);
-                
+
             } else if (tagName.equals("adopt-permissions")) {
                 sa = res.obtainAttributes(attrs,
                         com.android.internal.R.styleable.AndroidManifestOriginalPackage);
@@ -1775,12 +1879,12 @@
                 }
 
                 XmlUtils.skipCurrentTag(parser);
-                
+
             } else if (tagName.equals("uses-gl-texture")) {
                 // Just skip this tag
                 XmlUtils.skipCurrentTag(parser);
                 continue;
-                
+
             } else if (tagName.equals("compatible-screens")) {
                 // Just skip this tag
                 XmlUtils.skipCurrentTag(parser);
@@ -1788,15 +1892,15 @@
             } else if (tagName.equals("supports-input")) {
                 XmlUtils.skipCurrentTag(parser);
                 continue;
-                
+
             } else if (tagName.equals("eat-comment")) {
                 // Just skip this tag
                 XmlUtils.skipCurrentTag(parser);
                 continue;
-                
+
             } else if (RIGID_PARSER) {
                 outError[0] = "Bad element under <manifest>: "
-                    + parser.getName();
+                        + parser.getName();
                 mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                 return null;
 
@@ -1856,7 +1960,7 @@
 
         if (supportsSmallScreens < 0 || (supportsSmallScreens > 0
                 && pkg.applicationInfo.targetSdkVersion
-                        >= android.os.Build.VERSION_CODES.DONUT)) {
+                >= android.os.Build.VERSION_CODES.DONUT)) {
             pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS;
         }
         if (supportsNormalScreens != 0) {
@@ -1864,22 +1968,22 @@
         }
         if (supportsLargeScreens < 0 || (supportsLargeScreens > 0
                 && pkg.applicationInfo.targetSdkVersion
-                        >= android.os.Build.VERSION_CODES.DONUT)) {
+                >= android.os.Build.VERSION_CODES.DONUT)) {
             pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS;
         }
         if (supportsXLargeScreens < 0 || (supportsXLargeScreens > 0
                 && pkg.applicationInfo.targetSdkVersion
-                        >= android.os.Build.VERSION_CODES.GINGERBREAD)) {
+                >= android.os.Build.VERSION_CODES.GINGERBREAD)) {
             pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS;
         }
         if (resizeable < 0 || (resizeable > 0
                 && pkg.applicationInfo.targetSdkVersion
-                        >= android.os.Build.VERSION_CODES.DONUT)) {
+                >= android.os.Build.VERSION_CODES.DONUT)) {
             pkg.applicationInfo.flags |= ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS;
         }
         if (anyDensity < 0 || (anyDensity > 0
                 && pkg.applicationInfo.targetSdkVersion
-                        >= android.os.Build.VERSION_CODES.DONUT)) {
+                >= android.os.Build.VERSION_CODES.DONUT)) {
             pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
         }
 
@@ -1897,8 +2001,8 @@
                 com.android.internal.R.styleable.AndroidManifestUsesFeature_name);
         if (fi.name == null) {
             fi.reqGlEsVersion = sa.getInt(
-                        com.android.internal.R.styleable.AndroidManifestUsesFeature_glEsVersion,
-                        FeatureInfo.GL_ES_VERSION_UNDEFINED);
+                    com.android.internal.R.styleable.AndroidManifestUsesFeature_glEsVersion,
+                    FeatureInfo.GL_ES_VERSION_UNDEFINED);
         }
         if (sa.getBoolean(
                 com.android.internal.R.styleable.AndroidManifestUsesFeature_required, true)) {
@@ -1909,7 +2013,7 @@
     }
 
     private boolean parseUsesPermission(Package pkg, Resources res, XmlResourceParser parser,
-            AttributeSet attrs) throws XmlPullParserException, IOException {
+                                        AttributeSet attrs) throws XmlPullParserException, IOException {
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestUsesPermission);
 
@@ -1947,7 +2051,7 @@
     }
 
     private static String buildClassName(String pkg, CharSequence clsSeq,
-            String[] outError) {
+                                         String[] outError) {
         if (clsSeq == null || clsSeq.length() <= 0) {
             outError[0] = "Empty class name in package " + pkg;
             return null;
@@ -1971,7 +2075,7 @@
     }
 
     private static String buildCompoundName(String pkg,
-            CharSequence procSeq, String type, String[] outError) {
+                                            CharSequence procSeq, String type, String[] outError) {
         String proc = procSeq.toString();
         char c = proc.charAt(0);
         if (pkg != null && c == ':') {
@@ -1997,10 +2101,10 @@
         }
         return proc.intern();
     }
-    
+
     private static String buildProcessName(String pkg, String defProc,
-            CharSequence procSeq, int flags, String[] separateProcesses,
-            String[] outError) {
+                                           CharSequence procSeq, int flags, String[] separateProcesses,
+                                           String[] outError) {
         if ((flags&PARSE_IGNORE_PROCESSES) != 0 && !"system".equals(procSeq)) {
             return defProc != null ? defProc : pkg;
         }
@@ -2019,7 +2123,7 @@
     }
 
     private static String buildTaskAffinityName(String pkg, String defProc,
-            CharSequence procSeq, String[] outError) {
+                                                CharSequence procSeq, String[] outError) {
         if (procSeq == null) {
             return defProc;
         }
@@ -2030,7 +2134,7 @@
     }
 
     private boolean parseKeySets(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, String[] outError)
+                                 XmlPullParser parser, AttributeSet attrs, String[] outError)
             throws XmlPullParserException, IOException {
         // we've encountered the 'key-sets' tag
         // all the keys and keysets that we want must be defined here
@@ -2063,7 +2167,7 @@
                 final TypedArray sa = res.obtainAttributes(attrs,
                         com.android.internal.R.styleable.AndroidManifestKeySet);
                 final String keysetName = sa.getNonResourceString(
-                    com.android.internal.R.styleable.AndroidManifestKeySet_name);
+                        com.android.internal.R.styleable.AndroidManifestKeySet_name);
                 definedKeySets.put(keysetName, new ArraySet<String>());
                 currentKeySet = keysetName;
                 currentKeySetDepth = parser.getDepth();
@@ -2080,7 +2184,7 @@
                 final String publicKeyName = sa.getNonResourceString(
                         com.android.internal.R.styleable.AndroidManifestPublicKey_name);
                 final String encodedKey = sa.getNonResourceString(
-                            com.android.internal.R.styleable.AndroidManifestPublicKey_value);
+                        com.android.internal.R.styleable.AndroidManifestPublicKey_value);
                 if (encodedKey == null && publicKeys.get(publicKeyName) == null) {
                     outError[0] = "'public-key' " + publicKeyName + " must define a public-key value"
                             + " on first use at " + parser.getPositionDescription();
@@ -2105,8 +2209,8 @@
                         publicKeys.put(publicKeyName, currentKey);
                     } else {
                         outError[0] = "Value of 'public-key' " + publicKeyName
-                               + " conflicts with previously defined value at "
-                               + parser.getPositionDescription();
+                                + " conflicts with previously defined value at "
+                                + parser.getPositionDescription();
                         mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                         sa.recycle();
                         return false;
@@ -2167,7 +2271,7 @@
             owner.mUpgradeKeySets = upgradeKeySets;
         } else {
             outError[0] ="Package" + owner.packageName + " AndroidManifext.xml "
-                   + "does not define all 'upgrade-key-set's .";
+                    + "does not define all 'upgrade-key-set's .";
             mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
             return false;
         }
@@ -2175,8 +2279,8 @@
     }
 
     private PermissionGroup parsePermissionGroup(Package owner, int flags, Resources res,
-            XmlPullParser parser, AttributeSet attrs, String[] outError)
-        throws XmlPullParserException, IOException {
+                                                 XmlPullParser parser, AttributeSet attrs, String[] outError)
+            throws XmlPullParserException, IOException {
         PermissionGroup perm = new PermissionGroup(owner);
 
         TypedArray sa = res.obtainAttributes(attrs,
@@ -2206,7 +2310,7 @@
         }
 
         sa.recycle();
-        
+
         if (!parseAllMetaData(res, parser, attrs, "<permission-group>", perm,
                 outError)) {
             mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
@@ -2219,8 +2323,8 @@
     }
 
     private Permission parsePermission(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, String[] outError)
-        throws XmlPullParserException, IOException {
+                                       XmlPullParser parser, AttributeSet attrs, String[] outError)
+            throws XmlPullParserException, IOException {
         Permission perm = new Permission(owner);
 
         TypedArray sa = res.obtainAttributes(attrs,
@@ -2245,7 +2349,7 @@
         if (perm.info.group != null) {
             perm.info.group = perm.info.group.intern();
         }
-        
+
         perm.info.descriptionRes = sa.getResourceId(
                 com.android.internal.R.styleable.AndroidManifestPermission_description,
                 0);
@@ -2276,7 +2380,7 @@
                 return null;
             }
         }
-        
+
         if (!parseAllMetaData(res, parser, attrs, "<permission>", perm,
                 outError)) {
             mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
@@ -2289,8 +2393,8 @@
     }
 
     private Permission parsePermissionTree(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, String[] outError)
-        throws XmlPullParserException, IOException {
+                                           XmlPullParser parser, AttributeSet attrs, String[] outError)
+            throws XmlPullParserException, IOException {
         Permission perm = new Permission(owner);
 
         TypedArray sa = res.obtainAttributes(attrs,
@@ -2309,14 +2413,14 @@
         }
 
         sa.recycle();
-        
+
         int index = perm.info.name.indexOf('.');
         if (index > 0) {
             index = perm.info.name.indexOf('.', index+1);
         }
         if (index < 0) {
             outError[0] = "<permission-tree> name has less than three segments: "
-                + perm.info.name;
+                    + perm.info.name;
             mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
             return null;
         }
@@ -2337,8 +2441,8 @@
     }
 
     private Instrumentation parseInstrumentation(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, String[] outError)
-        throws XmlPullParserException, IOException {
+                                                 XmlPullParser parser, AttributeSet attrs, String[] outError)
+            throws XmlPullParserException, IOException {
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestInstrumentation);
 
@@ -2351,9 +2455,9 @@
                     com.android.internal.R.styleable.AndroidManifestInstrumentation_banner);
             mParseInstrumentationArgs.tag = "<instrumentation>";
         }
-        
+
         mParseInstrumentationArgs.sa = sa;
-        
+
         Instrumentation a = new Instrumentation(mParseInstrumentationArgs,
                 new InstrumentationInfo());
         if (outError[0] != null) {
@@ -2404,11 +2508,10 @@
      * supported by split APKs.
      */
     private boolean parseBaseApplication(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
-        throws XmlPullParserException, IOException {
+                                         XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
+            throws XmlPullParserException, IOException {
         final ApplicationInfo ai = owner.applicationInfo;
         final String pkgName = owner.applicationInfo.packageName;
-
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestApplication);
 
@@ -2534,6 +2637,66 @@
                 false)) {
             ai.flags |= ApplicationInfo.FLAG_VM_SAFE_MODE;
         }
+        //reviseapp
+//        if(sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_reviseApp,false)){
+//            ai.flags |= ApplicationInfo.FLAG_REVISE_APP;
+//            Log.d("SBJSBJ reviseApp", "SBJSBJ reviseApp");
+//
+//            CURRENT_REVISE_APP = (String)v.string;
+//
+//            makeReviseDir(CURRENT_REVISE_APP);
+//
+//            String[] baksmaliArgs = {"/system/priv-app/"+CURRENT_REVISE_APP+"/"+CURRENT_REVISE_APP+".apk", "-o", "/reviseApp/"+CURRENT_REVISE_APP+"/smalis/"};
+//            Log.d("remoteablebjsbjsbjsbjsbjbjsbjsbjsbjsbjsbjsbjsbjsbjsbjsbjsbjsbjsbjsbj",
+//                    "baksmali SuccessFul : ");
+//            /*
+//            try {
+//                //com.android.baksmali.main.main(baksmaliArgs);
+//            } catch (IOException e) {
+//                // TODO Auto-generated catch block
+//                e.printStackTrace();
+//            }*/
+//
+//
+//
+//            File f = new File("/reviseApp/"+CURRENT_REVISE_APP+"/smalis/");
+//            PermissionRecursiveFiles(f);
+//
+//
+//        }
+
+        //collaboroid
+        //This <application> in customized attribute executing
+        if (sa.getBoolean(
+                com.android.internal.R.styleable.AndroidManifestApplication_SAMDApp,
+                false)) {
+            ai.flags |= ApplicationInfo.FLAG_SAMD_APP;
+            IS_AGENT_APP = true;
+            CURRENT_AGENT_APP = (String)v.string;
+            makeDir(CURRENT_AGENT_APP);
+            AGENT_AM = sa.getResources().getAssets();
+            ValuesCopyAssets(AGENT_AM, CURRENT_AGENT_APP);
+            DrawableCopyAssets(AGENT_AM, CURRENT_AGENT_APP);
+            LayoutCopyAssets(AGENT_AM, CURRENT_AGENT_APP);
+
+            String[] baksmaliArgs = {"/system/priv-app/"+CURRENT_AGENT_APP+"/"+CURRENT_AGENT_APP+".apk", "-o",
+                    "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/baksmaliFolder/"};
+            try {
+                com.android.baksmali.main.main(baksmaliArgs);
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+            //check library
+            if(CURRENT_AGENT_APP.equals("MekoMosaicApp")){
+                Log.d("Mosaic","Mosaic in function");
+                File dcs = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/baksmaliFolder/dcs");
+                File move_dcs = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/smaliFolder/dcs");
+                moveFileAll(dcs, move_dcs);
+            }
+
+        }
 
         owner.baseHardwareAccelerated = sa.getBoolean(
                 com.android.internal.R.styleable.AndroidManifestApplication_hardwareAccelerated,
@@ -2630,10 +2793,10 @@
             }
             ai.processName = buildProcessName(ai.packageName, null, pname,
                     flags, mSeparateProcesses, outError);
-    
+
             ai.enabled = sa.getBoolean(
                     com.android.internal.R.styleable.AndroidManifestApplication_enabled, true);
-            
+
             if (sa.getBoolean(
                     com.android.internal.R.styleable.AndroidManifestApplication_isGame, false)) {
                 ai.flags |= ApplicationInfo.FLAG_IS_GAME;
@@ -2680,9 +2843,9 @@
                     mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                     return false;
                 }
-
                 owner.activities.add(a);
 
+
             } else if (tagName.equals("receiver")) {
                 Activity a = parseActivity(owner, res, parser, attrs, flags, outError, true, false);
                 if (a == null) {
@@ -2852,7 +3015,7 @@
      * omitted here.
      */
     private boolean parseSplitApplication(Package owner, Resources res, XmlPullParser parser,
-            AttributeSet attrs, int flags, int splitIndex, String[] outError)
+                                          AttributeSet attrs, int flags, int splitIndex, String[] outError)
             throws XmlPullParserException, IOException {
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestApplication);
@@ -2983,8 +3146,8 @@
     }
 
     private boolean parsePackageItemInfo(Package owner, PackageItemInfo outInfo,
-            String[] outError, String tag, TypedArray sa,
-            int nameRes, int labelRes, int iconRes, int logoRes, int bannerRes) {
+                                         String[] outError, String tag, TypedArray sa,
+                                         int nameRes, int labelRes, int iconRes, int logoRes, int bannerRes) {
         String name = sa.getNonConfigurationString(nameRes, 0);
         if (name == null) {
             outError[0] = tag + " does not specify android:name";
@@ -2992,7 +3155,7 @@
         }
 
         outInfo.name
-            = buildClassName(owner.applicationInfo.packageName, name, outError);
+                = buildClassName(owner.applicationInfo.packageName, name, outError);
         if (outInfo.name == null) {
             return false;
         }
@@ -3002,7 +3165,7 @@
             outInfo.icon = iconVal;
             outInfo.nonLocalizedLabel = null;
         }
-        
+
         int logoVal = sa.getResourceId(logoRes, 0);
         if (logoVal != 0) {
             outInfo.logo = logoVal;
@@ -3024,8 +3187,8 @@
     }
 
     private Activity parseActivity(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError,
-            boolean receiver, boolean hardwareAccelerated)
+                                   XmlPullParser parser, AttributeSet attrs, int flags, String[] outError,
+                                   boolean receiver, boolean hardwareAccelerated)
             throws XmlPullParserException, IOException {
         TypedArray sa = res.obtainAttributes(attrs, R.styleable.AndroidManifestActivity);
 
@@ -3041,12 +3204,13 @@
                     R.styleable.AndroidManifestActivity_description,
                     R.styleable.AndroidManifestActivity_enabled);
         }
-        
+
         mParseActivityArgs.tag = receiver ? "<receiver>" : "<activity>";
         mParseActivityArgs.sa = sa;
         mParseActivityArgs.flags = flags;
-        
+
         Activity a = new Activity(mParseActivityArgs, new ActivityInfo());
+
         if (outError[0] != null) {
             sa.recycle();
             return null;
@@ -3091,6 +3255,8 @@
                 owner.applicationInfo.taskAffinity, str, outError);
 
         a.info.flags = 0;
+
+
         if (sa.getBoolean(
                 R.styleable.AndroidManifestActivity_multiprocess, false)) {
             a.info.flags |= ActivityInfo.FLAG_MULTIPROCESS;
@@ -3103,7 +3269,6 @@
         if (sa.getBoolean(R.styleable.AndroidManifestActivity_clearTaskOnLaunch, false)) {
             a.info.flags |= ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH;
         }
-
         if (sa.getBoolean(R.styleable.AndroidManifestActivity_noHistory, false)) {
             a.info.flags |= ActivityInfo.FLAG_NO_HISTORY;
         }
@@ -3140,6 +3305,7 @@
 
         if (sa.getBoolean(R.styleable.AndroidManifestActivity_primaryUserOnly, false)) {
             a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY;
+
         }
 
         if (!receiver) {
@@ -3168,6 +3334,95 @@
                 a.info.flags |= ActivityInfo.FLAG_ALLOW_EMBEDDED;
             }
 
+            //collaboroid
+
+            if(IS_AGENT_APP){
+                if (sa.getBoolean(R.styleable.AndroidManifestActivity_remoteable, false)) {
+                    AGENT_RES = sa.getResources();
+                    //MOVE SMALI TO ORIGINALSMALI FOLDER
+                    String fullName = a.getComponentName().getClassName();
+                    String activityName = fullName.replace(a.getComponentName().getPackageName()+".","");
+                    String PackageName = fullName.replace("."+activityName , "");
+                    CURRENT_AGENT_PACKAGE = PackageName;
+                    CURRENT_AGENT_ACTIVITY = activityName;
+
+                    String temppackageName = CURRENT_AGENT_PACKAGE.replace(".","/");
+                    File sourceFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/baksmaliFolder/"+temppackageName);
+                    File targetFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/originalSmali");
+                    //copy com/TexasHoldem/activities -> originalSmali [Partial]
+
+                    moveFile(sourceFile, targetFile, CURRENT_AGENT_ACTIVITY);
+                    //17.01.19
+                    //Save HashMap for smali $$$$
+                    smali$FileList.put(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY, getFileList(targetFile.getAbsolutePath(), activityName));
+                    String[] sf = smali$FileList.get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+
+                    //get PlayerActivity$1.smali
+
+                    //Resource save
+                    List<String> all0x7fs = getAll0x7f(sf, CURRENT_AGENT_APP);
+                    ArrayList<String> subOfall0x7fs = new ArrayList<String>();
+                    //add 0x to hashmap
+                    for(String s : all0x7fs){
+                        subOfall0x7fs.add(getResNameOrID(Integer.parseInt(s.substring(2,10), 16),AGENT_AM, AGENT_RES));
+                    }
+                    //modified content && originalSmali -> modifiedSmali
+
+                    ResourceTable.put(CURRENT_AGENT_APP, replaceContentOfActivity(all0x7fs, subOfall0x7fs));
+
+                    HashMap<String, List<String>> temp = ResourceTable.get(CURRENT_AGENT_APP);
+                    List<String> temp2 = temp.get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+
+
+                    writeResourceTable(ResourceTable.get(CURRENT_AGENT_APP).get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY));
+
+                    //rename [modifiedSmali folder smali name] -> [com/collaboroid/dummy2 smali name] MainActivity
+                    renameActivityToMainDummy1(CURRENT_AGENT_ACTIVITY);
+                    renameActivityToMainDummy2(CURRENT_AGENT_ACTIVITY);
+
+                    String[] smaliArgs = {"-o",
+                            "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/dex/"+CURRENT_AGENT_ACTIVITY+"_classes.dex",
+                            "--",
+                            "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/smaliFolder"};
+                    com.android.smali.main.main(smaliArgs);
+                    Log.d("samd experiment","APK remoateable make dex end");
+                    //17.05.16
+                    DeleteRecursiveFiles(new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/smaliFolder/com/collaboroid/dummy1"));
+                    DeleteRecursiveFiles(new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/smaliFolder/com/collaboroid/dummy2"));
+
+                }else{
+                    String fullName = a.getComponentName().getClassName();
+                    String activityName = fullName.replace(a.getComponentName().getPackageName()+".","");
+                    String PackageName = fullName.replace("."+activityName , "");
+
+                    CURRENT_AGENT_PACKAGE = PackageName;
+                    CURRENT_AGENT_ACTIVITY = activityName;
+
+                    String temppackageName = CURRENT_AGENT_PACKAGE.replace(".","/");
+
+                    File sourceFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/baksmaliFolder/"+temppackageName);
+                    File targetFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/"+"originalSmali");
+
+
+                    moveFile(sourceFile, targetFile, activityName);
+                    smali$FileList.put(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY, getFileList(targetFile.getAbsolutePath(), activityName));
+                    String[] sf = smali$FileList.get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+
+                    makeActivityTable(sf);
+
+                    List<String> activities = new ArrayList<>();
+                    HashMap<String, List<String>> mainActivity = new HashMap<>();
+
+                    mainActivity = ActivityTable.get(CURRENT_AGENT_APP);
+                    activities = mainActivity.get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+                    writeActivityTable(activities);
+                    //write txt file in android device[data/collaboroid/preprocess/CURRENT_AGENT_APP/..]
+
+                }
+
+            }
+
+
             if (sa.getBoolean(R.styleable.AndroidManifestActivity_autoRemoveFromRecents, false)) {
                 a.info.flags |= ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS;
             }
@@ -3219,7 +3474,7 @@
                 outError[0] = "Heavy-weight applications can not have receivers in main process";
             }
         }
-        
+
         if (outError[0] != null) {
             return null;
         }
@@ -3227,8 +3482,8 @@
         int outerDepth = parser.getDepth();
         int type;
         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
-               && (type != XmlPullParser.END_TAG
-                       || parser.getDepth() > outerDepth)) {
+                && (type != XmlPullParser.END_TAG
+                || parser.getDepth() > outerDepth)) {
             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
@@ -3298,7 +3553,7 @@
     }
 
     private Activity parseActivityAlias(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
+                                        XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
             throws XmlPullParserException, IOException {
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestActivityAlias);
@@ -3332,10 +3587,10 @@
                     com.android.internal.R.styleable.AndroidManifestActivityAlias_enabled);
             mParseActivityAliasArgs.tag = "<activity-alias>";
         }
-        
+
         mParseActivityAliasArgs.sa = sa;
         mParseActivityAliasArgs.flags = flags;
-        
+
         Activity target = null;
 
         final int NA = owner.activities.size();
@@ -3420,8 +3675,8 @@
         int outerDepth = parser.getDepth();
         int type;
         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
-               && (type != XmlPullParser.END_TAG
-                       || parser.getDepth() > outerDepth)) {
+                && (type != XmlPullParser.END_TAG
+                || parser.getDepth() > outerDepth)) {
             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
@@ -3465,7 +3720,7 @@
     }
 
     private Provider parseProvider(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
+                                   XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
             throws XmlPullParserException, IOException {
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestProvider);
@@ -3483,10 +3738,10 @@
                     com.android.internal.R.styleable.AndroidManifestProvider_enabled);
             mParseProviderArgs.tag = "<provider>";
         }
-        
+
         mParseProviderArgs.sa = sa;
         mParseProviderArgs.flags = flags;
-        
+
         Provider p = new Provider(mParseProviderArgs, new ProviderInfo());
         if (outError[0] != null) {
             sa.recycle();
@@ -3524,7 +3779,7 @@
             p.info.readPermission = owner.applicationInfo.permission;
         } else {
             p.info.readPermission =
-                str.length() > 0 ? str.toString().intern() : null;
+                    str.length() > 0 ? str.toString().intern() : null;
         }
         str = sa.getNonConfigurationString(
                 com.android.internal.R.styleable.AndroidManifestProvider_writePermission, 0);
@@ -3535,7 +3790,7 @@
             p.info.writePermission = owner.applicationInfo.permission;
         } else {
             p.info.writePermission =
-                str.length() > 0 ? str.toString().intern() : null;
+                    str.length() > 0 ? str.toString().intern() : null;
         }
 
         p.info.grantUriPermissions = sa.getBoolean(
@@ -3575,7 +3830,7 @@
                 return null;
             }
         }
-        
+
         if (cpname == null) {
             outError[0] = "<provider> does not include authorities attribute";
             return null;
@@ -3594,14 +3849,14 @@
     }
 
     private boolean parseProviderTags(Resources res,
-            XmlPullParser parser, AttributeSet attrs,
-            Provider outInfo, String[] outError)
+                                      XmlPullParser parser, AttributeSet attrs,
+                                      Provider outInfo, String[] outError)
             throws XmlPullParserException, IOException {
         int outerDepth = parser.getDepth();
         int type;
         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
-               && (type != XmlPullParser.END_TAG
-                       || parser.getDepth() > outerDepth)) {
+                && (type != XmlPullParser.END_TAG
+                || parser.getDepth() > outerDepth)) {
             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
@@ -3618,7 +3873,7 @@
                         outInfo.metaData, outError)) == null) {
                     return false;
                 }
-                
+
             } else if (parser.getName().equals("grant-uri-permission")) {
                 TypedArray sa = res.obtainAttributes(attrs,
                         com.android.internal.R.styleable.AndroidManifestGrantUriPermission);
@@ -3642,7 +3897,7 @@
                 if (str != null) {
                     pa = new PatternMatcher(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
                 }
-                
+
                 sa.recycle();
 
                 if (pa != null) {
@@ -3689,7 +3944,7 @@
                 if (writePermission == null) {
                     writePermission = permission;
                 }
-                
+
                 boolean havePerm = false;
                 if (readPermission != null) {
                     readPermission = readPermission.intern();
@@ -3712,7 +3967,7 @@
                         return false;
                     }
                 }
-                
+
                 String path = sa.getNonConfigurationString(
                         com.android.internal.R.styleable.AndroidManifestPathPermission_path, 0);
                 if (path != null) {
@@ -3777,7 +4032,7 @@
     }
 
     private Service parseService(Package owner, Resources res,
-            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
+                                 XmlPullParser parser, AttributeSet attrs, int flags, String[] outError)
             throws XmlPullParserException, IOException {
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestService);
@@ -3795,10 +4050,10 @@
                     com.android.internal.R.styleable.AndroidManifestService_enabled);
             mParseServiceArgs.tag = "<service>";
         }
-        
+
         mParseServiceArgs.sa = sa;
         mParseServiceArgs.flags = flags;
-        
+
         Service s = new Service(mParseServiceArgs, new ServiceInfo());
         if (outError[0] != null) {
             sa.recycle();
@@ -3855,12 +4110,12 @@
                 return null;
             }
         }
-        
+
         int outerDepth = parser.getDepth();
         int type;
         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
-               && (type != XmlPullParser.END_TAG
-                       || parser.getDepth() > outerDepth)) {
+                && (type != XmlPullParser.END_TAG
+                || parser.getDepth() > outerDepth)) {
             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
@@ -3899,14 +4154,14 @@
     }
 
     private boolean parseAllMetaData(Resources res,
-            XmlPullParser parser, AttributeSet attrs, String tag,
-            Component outInfo, String[] outError)
+                                     XmlPullParser parser, AttributeSet attrs, String tag,
+                                     Component outInfo, String[] outError)
             throws XmlPullParserException, IOException {
         int outerDepth = parser.getDepth();
         int type;
         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
-               && (type != XmlPullParser.END_TAG
-                       || parser.getDepth() > outerDepth)) {
+                && (type != XmlPullParser.END_TAG
+                || parser.getDepth() > outerDepth)) {
             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
@@ -3933,8 +4188,8 @@
     }
 
     private Bundle parseMetaData(Resources res,
-            XmlPullParser parser, AttributeSet attrs,
-            Bundle data, String[] outError)
+                                 XmlPullParser parser, AttributeSet attrs,
+                                 Bundle data, String[] outError)
             throws XmlPullParserException, IOException {
 
         TypedArray sa = res.obtainAttributes(attrs,
@@ -3953,7 +4208,7 @@
         }
 
         name = name.intern();
-        
+
         TypedValue v = sa.peekValue(
                 com.android.internal.R.styleable.AndroidManifestMetaData_resource);
         if (v != null && v.resourceId != 0) {
@@ -3998,7 +4253,7 @@
     }
 
     private static VerifierInfo parseVerifier(Resources res, XmlPullParser parser,
-            AttributeSet attrs, int flags) {
+                                              AttributeSet attrs, int flags) {
         final TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifestPackageVerifier);
 
@@ -4077,7 +4332,7 @@
             = "http://schemas.android.com/apk/res/android";
 
     private boolean parseIntent(Resources res, XmlPullParser parser, AttributeSet attrs,
-            boolean allowGlobs, boolean allowAutoVerify, IntentInfo outInfo, String[] outError)
+                                boolean allowGlobs, boolean allowAutoVerify, IntentInfo outInfo, String[] outError)
             throws XmlPullParserException, IOException {
 
         TypedArray sa = res.obtainAttributes(attrs,
@@ -4095,7 +4350,7 @@
 
         outInfo.icon = sa.getResourceId(
                 com.android.internal.R.styleable.AndroidManifestIntentFilter_icon, 0);
-        
+
         outInfo.logo = sa.getResourceId(
                 com.android.internal.R.styleable.AndroidManifestIntentFilter_logo, 0);
 
@@ -4316,7 +4571,7 @@
         public ArrayList<String> mOriginalPackages = null;
         public String mRealPackage = null;
         public ArrayList<String> mAdoptPermissions = null;
-        
+
         // We store the application meta-data independently to avoid multiple unwanted references
         public Bundle mAppMetaData = null;
 
@@ -4325,7 +4580,7 @@
 
         // The version name declared for this package.
         public String mVersionName;
-        
+
         // The shared user id that this package wants to use.
         public String mSharedUserId;
 
@@ -4534,8 +4789,8 @@
 
         public String toString() {
             return "Package{"
-                + Integer.toHexString(System.identityHashCode(this))
-                + " " + packageName + "}";
+                    + Integer.toHexString(System.identityHashCode(this))
+                    + " " + packageName + "}";
         }
     }
 
@@ -4547,7 +4802,7 @@
 
         ComponentName componentName;
         String componentShortName;
-        
+
         public Component(Package _owner) {
             owner = _owner;
             intents = null;
@@ -4565,7 +4820,7 @@
             }
 
             outInfo.name
-                = buildClassName(owner.applicationInfo.packageName, name, args.outError);
+                    = buildClassName(owner.applicationInfo.packageName, name, args.outError);
             if (outInfo.name == null) {
                 className = null;
                 args.outError[0] = args.tag + " does not have valid android:name";
@@ -4579,7 +4834,7 @@
                 outInfo.icon = iconVal;
                 outInfo.nonLocalizedLabel = null;
             }
-            
+
             int logoVal = args.sa.getResourceId(args.logoRes, 0);
             if (logoVal != 0) {
                 outInfo.logo = logoVal;
@@ -4619,11 +4874,11 @@
                         owner.applicationInfo.processName, pname,
                         args.flags, args.sepProcesses, args.outError);
             }
-            
+
             if (args.descriptionRes != 0) {
                 outInfo.descriptionRes = args.sa.getResourceId(args.descriptionRes, 0);
             }
-            
+
             outInfo.enabled = args.sa.getBoolean(args.enabledRes, true);
         }
 
@@ -4634,7 +4889,7 @@
             componentName = clone.componentName;
             componentShortName = clone.componentShortName;
         }
-        
+
         public ComponentName getComponentName() {
             if (componentName != null) {
                 return componentName;
@@ -4659,7 +4914,7 @@
             componentShortName = null;
         }
     }
-    
+
     public final static class Permission extends Component<IntentInfo> {
         public final PermissionInfo info;
         public boolean tree;
@@ -4674,7 +4929,7 @@
             super(_owner);
             info = _info;
         }
-        
+
         public void setPackageName(String packageName) {
             super.setPackageName(packageName);
             info.packageName = packageName;
@@ -4682,8 +4937,8 @@
 
         public String toString() {
             return "Permission{"
-                + Integer.toHexString(System.identityHashCode(this))
-                + " " + info.name + "}";
+                    + Integer.toHexString(System.identityHashCode(this))
+                    + " " + info.name + "}";
         }
     }
 
@@ -4707,13 +4962,13 @@
 
         public String toString() {
             return "PermissionGroup{"
-                + Integer.toHexString(System.identityHashCode(this))
-                + " " + info.name + "}";
+                    + Integer.toHexString(System.identityHashCode(this))
+                    + " " + info.name + "}";
         }
     }
 
     private static boolean copyNeeded(int flags, Package p,
-            PackageUserState state, Bundle metaData, int userId) {
+                                      PackageUserState state, Bundle metaData, int userId) {
         if (userId != UserHandle.USER_OWNER) {
             // We always need to copy for other users, since we need
             // to fix up the uid.
@@ -4743,12 +4998,12 @@
     }
 
     public static ApplicationInfo generateApplicationInfo(Package p, int flags,
-            PackageUserState state) {
+                                                          PackageUserState state) {
         return generateApplicationInfo(p, flags, state, UserHandle.getCallingUserId());
     }
 
     private static void updateApplicationInfo(ApplicationInfo ai, int flags,
-            PackageUserState state) {
+                                              PackageUserState state) {
         // CompatibilityMode is global state.
         if (!sCompatibilityModeEnabled) {
             ai.disableCompatibilityMode();
@@ -4775,14 +5030,14 @@
     }
 
     public static ApplicationInfo generateApplicationInfo(Package p, int flags,
-            PackageUserState state, int userId) {
+                                                          PackageUserState state, int userId) {
         if (p == null) return null;
         if (!checkUseInstalledOrHidden(flags, state)) {
             return null;
         }
         if (!copyNeeded(flags, p, state, null, userId)
                 && ((flags&PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS) == 0
-                        || state.enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED)) {
+                || state.enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED)) {
             // In this case it is safe to directly modify the internal ApplicationInfo state:
             // - CompatibilityMode is global state, so will be the same for every call.
             // - We only come in to here if the app should reported as installed; this is the
@@ -4815,7 +5070,7 @@
     }
 
     public static ApplicationInfo generateApplicationInfo(ApplicationInfo ai, int flags,
-            PackageUserState state, int userId) {
+                                                          PackageUserState state, int userId) {
         if (ai == null) return null;
         if (!checkUseInstalledOrHidden(flags, state)) {
             return null;
@@ -4865,7 +5120,7 @@
             info = _info;
             info.applicationInfo = args.owner.applicationInfo;
         }
-        
+
         public void setPackageName(String packageName) {
             super.setPackageName(packageName);
             info.packageName = packageName;
@@ -4883,7 +5138,7 @@
     }
 
     public static final ActivityInfo generateActivityInfo(Activity a, int flags,
-            PackageUserState state, int userId) {
+                                                          PackageUserState state, int userId) {
         if (a == null) return null;
         if (!checkUseInstalledOrHidden(flags, state)) {
             return null;
@@ -4899,7 +5154,7 @@
     }
 
     public static final ActivityInfo generateActivityInfo(ActivityInfo ai, int flags,
-            PackageUserState state, int userId) {
+                                                          PackageUserState state, int userId) {
         if (ai == null) return null;
         if (!checkUseInstalledOrHidden(flags, state)) {
             return null;
@@ -4919,7 +5174,7 @@
             info = _info;
             info.applicationInfo = args.owner.applicationInfo;
         }
-        
+
         public void setPackageName(String packageName) {
             super.setPackageName(packageName);
             info.packageName = packageName;
@@ -4937,7 +5192,7 @@
     }
 
     public static final ServiceInfo generateServiceInfo(Service s, int flags,
-            PackageUserState state, int userId) {
+                                                        PackageUserState state, int userId) {
         if (s == null) return null;
         if (!checkUseInstalledOrHidden(flags, state)) {
             return null;
@@ -4962,7 +5217,7 @@
             info.applicationInfo = args.owner.applicationInfo;
             syncable = false;
         }
-        
+
         public Provider(Provider existingProvider) {
             super(existingProvider);
             this.info = existingProvider.info;
@@ -4986,14 +5241,14 @@
     }
 
     public static final ProviderInfo generateProviderInfo(Provider p, int flags,
-            PackageUserState state, int userId) {
+                                                          PackageUserState state, int userId) {
         if (p == null) return null;
         if (!checkUseInstalledOrHidden(flags, state)) {
             return null;
         }
         if (!copyNeeded(flags, p.owner, state, p.metaData, userId)
                 && ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) != 0
-                        || p.info.uriPermissionPatterns == null)) {
+                || p.info.uriPermissionPatterns == null)) {
             return p.info;
         }
         // Make shallow copies so we can store the metadata safely
@@ -5013,7 +5268,7 @@
             super(args, _info);
             info = _info;
         }
-        
+
         public void setPackageName(String packageName) {
             super.setPackageName(packageName);
             info.packageName = packageName;
@@ -5152,4 +5407,1279 @@
             this.error = error;
         }
     }
+    //collaboroid
+    private void copyDirectoryAll(File sourceLocation, File targetLoacation) throws IOException{
+        //source is directory
+        if(sourceLocation.isDirectory()){
+            if(!targetLoacation.exists()){
+                targetLoacation.mkdir();
+            }
+            String[] children = sourceLocation.list();
+            for(int i=0; i<children.length; i++){
+                copyDirectoryAll(new File(sourceLocation, children[i]), new File(targetLoacation, children[i]));
+            }
+        }
+        else{
+            InputStream in = new FileInputStream(sourceLocation);
+            OutputStream out = new FileOutputStream(targetLoacation);
+            //Copy the bits from instream to outstream
+            byte[] buf = new byte[1024];
+            int len;
+            while ((len = in.read(buf)) > 0) {
+                out.write(buf, 0, len);
+            }
+            in.close();
+            out.close();
+
+        }
+    }
+    public void moveFile(File sourceLocation, File targetLoacation, String activityName){
+        try {
+            copyDirectoryPartial(sourceLocation, targetLoacation, activityName);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+    public void moveFileAll(File sourceLocation, File targetLoacation){
+        try {
+            copyDirectoryAll(sourceLocation, targetLoacation);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    private void copyDirectoryPartial(File sourceLocation, File targetLoacation, String activityName) throws IOException{
+
+        //source is directory
+        if(sourceLocation.isDirectory()){
+            if(!targetLoacation.exists()){
+                targetLoacation.mkdir();
+            }
+            String[] children = sourceLocation.list();
+            for(int i=0; i<children.length; i++){
+                copyDirectoryPartial(new File(sourceLocation, children[i]), new File(targetLoacation, children[i]), activityName);
+            }
+        }
+
+        else{
+            if(sourceLocation.getName().contains(activityName)) {
+                InputStream in = new FileInputStream(sourceLocation);
+                OutputStream out = new FileOutputStream(targetLoacation);
+
+                //Copy the bits from instream to outstream
+                byte[] buf = new byte[1024];
+                int len;
+                while ((len = in.read(buf)) > 0) {
+                    out.write(buf, 0, len);
+                }
+                in.close();
+                out.close();
+            }
+        }
+    }
+    private void copyFile(InputStream in, OutputStream out) throws IOException {
+        byte[] buffer = new byte[1024];
+        int read;
+        while((read = in.read(buffer)) != -1){
+            out.write(buffer, 0, read);
+        }
+    }
+    public void ValuesCopyAssets(AssetManager assetManager, String appName) {
+        String[] files = null;
+
+        try {
+            files = assetManager.list("collaboroid/values");
+            //이미지만 가져올때 files = assetManager.list("image");
+
+        } catch (IOException e) {
+            Log.e("tag", e.getMessage());
+        }
+        for(int i=0; i<files.length; i++) {
+            InputStream in = null;
+            OutputStream out = null;
+            try {
+                in = assetManager.open("collaboroid/values/"+files[i]);
+                File outFile = new File("/data/collaboroid/preprocess/"+appName+"/res/values/", files[i]);
+                out = new FileOutputStream(outFile);
+
+                copyFile(in, out);
+                in.close();
+                in = null;
+                out.flush();
+                out.close();
+                out = null;
+            } catch(IOException e) {
+                Log.e("tag", "Failed to copy asset file: " + files[i], e);
+            }
+
+        }
+    }
+
+    public void DrawableCopyAssets(AssetManager assetManager, String appName) {
+        String[] files = null;
+
+        try {
+            files = assetManager.list("collaboroid/drawable");
+            //이미지만 가져올때 files = assetManager.list("image");
+
+        } catch (IOException e) {
+            Log.e("tag", e.getMessage());
+        }
+        for(int i=0; i<files.length; i++) {
+            InputStream in = null;
+            OutputStream out = null;
+            try {
+                in = assetManager.open("collaboroid/drawable/"+files[i]);
+                if(files[i].contains("ic_launcher")){
+                    File outFile = new File("/data/collaboroid/preprocess/"+appName+"/res/drawable/", files[i]);
+                    out = new FileOutputStream(outFile);
+                }else{
+                    File outFile = new File("/data/collaboroid/preprocess/"+appName+"/assets/", files[i]);
+                    out = new FileOutputStream(outFile);
+                }
+                copyFile(in, out);
+                in.close();
+                in = null;
+                out.flush();
+                out.close();
+                out = null;
+            } catch(IOException e) {
+                Log.e("tag", "Failed to copy asset file: " + files[i], e);
+            }
+
+        }
+    }
+    public void LayoutCopyAssets(AssetManager assetManager, String appName) {
+        String[] files = null;
+
+        try {
+            files = assetManager.list("collaboroid/layout");
+            //이미지만 가져올때 files = assetManager.list("image");
+
+        } catch (IOException e) {
+            Log.e("tag", e.getMessage());
+        }
+        for(int i=0; i<files.length; i++) {
+            InputStream in = null;
+            OutputStream out = null;
+            try {
+                in = assetManager.open("collaboroid/layout/"+files[i]);
+                File outFile = new File("/data/collaboroid/preprocess/"+appName+"/res/layout/", files[i]);
+                out = new FileOutputStream(outFile);
+                copyFile(in, out);
+                in.close();
+                in = null;
+                out.flush();
+                out.close();
+                out = null;
+            } catch(IOException e) {
+                Log.e("tag", "Failed to copy asset file: " + files[i], e);
+            }
+
+        }
+    }
+    //reviseapp
+    private void makeReviseDir(String appName){
+
+        String permission="777";
+
+        String basePath = "/reviseApp";
+        String appPath = basePath+"/"+appName;
+        String Smalis = appPath + "/smalis";
+        String dexes = appPath + "/dexes";
+
+        String[] pathLoop = {basePath, appPath, Smalis, dexes};
+
+        for(int i=0; i<pathLoop.length; i++){
+            File fileTemp = new File(pathLoop[i]);
+            if(!fileTemp.exists()){
+                fileTemp.mkdir();
+            }
+            try {
+                String command = "chmod " + permission + " " + pathLoop[i];
+                Runtime runtime = Runtime.getRuntime();
+                runtime.exec(command);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+    //collaboroid
+    private void makeDir(String appName){
+
+        String permission="777";
+
+        String basePath = "/data/collaboroid";
+        String preBasePath = basePath + "/preprocess";
+        String appPath = preBasePath+"/"+appName;
+        String originalSmali = appPath + "/originalSmali";
+        String modifiedSmaliDummy1 = appPath + "/modifiedSmaliDummy1";
+        String modifiedSmaliDummy2 = appPath + "/modifiedSmaliDummy2";
+        String BaksmaliFolder = appPath + "/baksmaliFolder";
+        String SmaliFolder = appPath + "/smaliFolder";
+        String com = SmaliFolder + "/com";
+        String assets = appPath + "/assets";
+        String res = appPath + "/res";
+        String drawable = res + "/drawable";
+        String drawablemdpi = res + "/drawable-mdpi";
+        String drawablehdpi = res + "/drawable-hdpi";
+        String drawablexhdpi = res + "/drawable-xhdpi";
+        String drawablexxhdpi = res + "/drawable-xxhdpi";
+        String layout = res + "/layout";
+        String values = res + "/values";
+        String dex = appPath + "/dex";
+        String collaboroid = com + "/collaboroid";
+        String dummy1 = collaboroid + "/dummy1";
+        String dummy2 = collaboroid + "/dummy2";
+
+
+        String[] pathLoop = {basePath, preBasePath, appPath, originalSmali, modifiedSmaliDummy1,
+                modifiedSmaliDummy2, BaksmaliFolder, SmaliFolder, assets, res, drawable,drawablemdpi ,
+                drawablehdpi, drawablexhdpi, drawablexxhdpi, layout, values, dex, com,
+                collaboroid, dummy1, dummy2};
+
+        for(int i=0; i<pathLoop.length; i++){
+            File fileTemp = new File(pathLoop[i]);
+            if(!fileTemp.exists()){
+                fileTemp.mkdir();
+            }
+            try {
+                String command = "chmod " + permission + " " + pathLoop[i];
+                Runtime runtime = Runtime.getRuntime();
+                runtime.exec(command);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    //for Smali file include $1,$2 ... to catch with them
+    private String[] getFileList(String directory, final String pattern){
+        File dir = new File(directory);
+        String fileList[] = dir.list(new FilenameFilter() {
+            @Override
+            public boolean accept(File dir, String name) {
+                return name.startsWith(pattern);
+            }
+        });
+        return fileList;
+    }
+    public List<String> getAll0x7f(String[] sf,String appName){
+        ArrayList<String> resValue = new ArrayList<String>();
+        for(String s : sf){
+            String fileName = "/data/collaboroid/preprocess/"+appName+"/originalSmali/" + s;
+            BufferedReader br = null;
+
+            try {
+                br = new BufferedReader(new FileReader(fileName));
+                String line;
+
+                while ((line = br.readLine()) != null) {
+                    if(line.contains("0x7f")){
+                        String lastWord = line.replaceAll("^.*?(\\w+)\\W*$", "$1");
+                        resValue.add(lastWord);
+                    }
+                }
+            } catch (Exception e) {
+                System.out.println("ERROROROROROROROR:" );
+                return null;
+            } finally {
+                try {
+                    if (br != null)
+                        br.close();
+                } catch (IOException e) {
+                    //
+                }
+            }
+        }
+
+        return resValue;
+    }
+    private String getResNameOrID(int _resInt, AssetManager am, Resources res){
+        String resValue;
+        if((resValue = am.getResourceText2(_resInt).toString()).equalsIgnoreCase("false")){
+            //여기는 false일때. 들어온다. 즉, getResourceText2에. 없으니까. getResourceEntryName로. 가져온다.
+            resValue = res.getResourceEntryName(_resInt);
+        }
+        return resValue;
+    }
+    //HC
+    public HashMap<String, List<String>> replaceContentOfActivity(List<String> oriResInt, List<String> newResStr){
+
+        HashMap<String, String> listOfSubs = new HashMap<String, String>();
+        for(int i = 0;i<oriResInt.size();i++){
+            listOfSubs.put(oriResInt.get(i),newResStr.get(i));
+        }
+
+        //collaboroid
+        List<String> resources = new ArrayList<>();
+
+        String smaliFileList[] = smali$FileList.get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+
+        for(int i=0; i<smaliFileList.length; i++){
+            if(smaliFileList[i].contains("$")){
+
+                String SMALIoldFileName = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/originalSmali/"+smaliFileList[i];
+                String SMALItmpFileDummy1Name = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/modifiedSmaliDummy1/"+smaliFileList[i];
+                String SMALItmpFileDummy2Name = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/modifiedSmaliDummy2/"+smaliFileList[i];
+
+                BufferedReader br1 = null;
+                BufferedWriter bw1 = null;
+                BufferedWriter bw2 = null;
+                try {
+                    System.out.println(SMALIoldFileName);
+                    br1 = new BufferedReader(new FileReader(SMALIoldFileName));
+                    bw1 = new BufferedWriter(new FileWriter(SMALItmpFileDummy1Name));
+                    bw2 = new BufferedWriter(new FileWriter(SMALItmpFileDummy2Name));
+
+                    String lineDummy1;
+                    String lineDummy2;
+                    String tempPackageName = CURRENT_AGENT_PACKAGE.replace(".","/");
+
+                    while ((lineDummy2 = br1.readLine()) != null) {
+                        //SBJ
+                        // (?i) <- "찾을 문자열"에 대소문자 구분을 없애고
+                        // .*   <- 문자열이 행의 어디에 있든지 찾을 수 있게
+                        lineDummy1 = lineDummy2;
+                        if(lineDummy2.matches("(?i).*" + tempPackageName + "/" + CURRENT_AGENT_ACTIVITY + ".*")){
+                            lineDummy1 = lineDummy1.replace(tempPackageName + "/" + CURRENT_AGENT_ACTIVITY , "com/collaboroid/dummy1/MainActivity");
+                            lineDummy2 = lineDummy2.replace(tempPackageName + "/" + CURRENT_AGENT_ACTIVITY , "com/collaboroid/dummy2/MainActivity");
+
+                        }
+                        if(lineDummy2.contains(CURRENT_AGENT_ACTIVITY+".java")){
+                            lineDummy1 = lineDummy1.replace(CURRENT_AGENT_ACTIVITY+".java" , "MainActivity.java");
+                            lineDummy2 = lineDummy2.replace(CURRENT_AGENT_ACTIVITY+".java" , "MainActivity.java");
+                        }
+                        bw1.write(lineDummy1);
+                        bw1.newLine();
+                        bw2.write(lineDummy2);
+                        bw2.newLine();
+                    }
+                } catch (Exception e) {
+                    return null;
+                } finally {
+                    try {
+                        if (br1 != null)
+                            br1.close();
+                    } catch (IOException e) {
+                        //
+                    }
+                    try {
+                        if (bw1 != null)
+                            bw1.close();
+                    } catch (IOException e) {
+                        //
+                    }
+                    try {
+                        if (bw2 != null)
+                            bw2.close();
+                    } catch (IOException e) {
+                        //
+                    }
+                }
+            }else{
+                String oldFileName = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/originalSmali/"+ smaliFileList[i];
+                String tmpFileDummy1Name = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/modifiedSmaliDummy1/"+ smaliFileList[i];
+                String tmpFileDummy2Name = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/modifiedSmaliDummy2/"+ smaliFileList[i];
+
+
+                BufferedReader br = null;
+                BufferedWriter bw1 = null;
+                BufferedWriter bw2 = null;
+
+                try {
+                    br = new BufferedReader(new FileReader(oldFileName));
+                    bw1 = new BufferedWriter(new FileWriter(tmpFileDummy1Name));
+                    bw2 = new BufferedWriter(new FileWriter(tmpFileDummy2Name));
+                    String lineDummy1;
+                    String lineDummy2;
+
+                    while ((lineDummy2 = br.readLine()) != null) {
+                        lineDummy1 = lineDummy2;
+                        String tempPackageName = CURRENT_AGENT_PACKAGE.replace(".","/");
+                        if(lineDummy2.matches("(?i).*" + tempPackageName + "/" + CURRENT_AGENT_ACTIVITY + ".*")){
+                            lineDummy1 = lineDummy1.replace(tempPackageName + "/" + CURRENT_AGENT_ACTIVITY , "com/collaboroid/dummy1/MainActivity");
+                            lineDummy2 = lineDummy2.replace(tempPackageName + "/" + CURRENT_AGENT_ACTIVITY , "com/collaboroid/dummy2/MainActivity");
+                        }
+                        if(lineDummy2.contains(CURRENT_AGENT_ACTIVITY+".java")){
+                            lineDummy1 = lineDummy1.replace(CURRENT_AGENT_ACTIVITY+".java" , "MainActivity.java");
+                            lineDummy2 = lineDummy2.replace(CURRENT_AGENT_ACTIVITY+".java" , "MainActivity.java");
+                        }
+
+
+                        //HC
+                        if(lineDummy2.contains("0x7f03")){
+                            String firstWord = lineDummy2.substring(4,lineDummy2.length()).split(" ", 2)[0];
+                            lineDummy1 = lineDummy1.replace(firstWord, "const-string/jumbo");
+                            lineDummy2 = lineDummy2.replace(firstWord, "const-string/jumbo");
+                            String lastWord = lineDummy2.replaceAll("^.*?(\\w+)\\W*$", "$1");
+                            String path_to_res = listOfSubs.get(lastWord);
+                            lineDummy1 = lineDummy1.replace(lastWord, "\"" + path_to_res + "\"");
+                            lineDummy2 = lineDummy2.replace(lastWord, "\"" + path_to_res + "\"");
+                            //add resourceTable
+                            if(path_to_res.contains("xml")){
+                                resources.add(path_to_res);
+                                List<String> temp = relateResourceXML(path_to_res);
+                                Log.d("SBJSBJ path_to_res", "SBJSBJ path_to_res : " + path_to_res);
+                                resources.addAll(temp);
+                            }
+                        }
+                        else if(lineDummy2.contains("setContentView")){
+                            lineDummy1 = lineDummy1.replace("setContentView", "setContentView2");
+                            lineDummy2 = lineDummy2.replace("setContentView", "setContentView2");
+                            lineDummy1 = lineDummy1.replace("(I)", "(Ljava/lang/String;)");
+                            lineDummy2 = lineDummy2.replace("(I)", "(Ljava/lang/String;)");
+                        }
+                        else if(lineDummy2.contains("0x7f")){
+                            String firstWord = lineDummy2.substring(4,lineDummy2.length()).split(" ", 2)[0];
+                            lineDummy1 = lineDummy1.replace(firstWord, "const-string/jumbo");
+                            lineDummy2 = lineDummy2.replace(firstWord, "const-string/jumbo");
+                            String lastWord = lineDummy2.replaceAll("^.*?(\\w+)\\W*$", "$1");
+                            String path_to_res = listOfSubs.get(lastWord);
+                            lineDummy1 = lineDummy1.replace(lastWord, "\"" + path_to_res + "\"");
+                            lineDummy2 = lineDummy2.replace(lastWord, "\"" + path_to_res + "\"");
+                            /*
+                            if(path_to_res.contains("png")){
+                                // ** res/layout/activity_player.xml
+                                // ** res/drawable/back.png
+                                resources.add(path_to_res);
+                                Log.d("SBJSBJ path_to_res", "SBJSBJ path_to_res : " + path_to_res);
+                            }
+                            */
+                        }
+                        else if(lineDummy2.contains("findViewById")){
+                            lineDummy1 = lineDummy1.replace("(I)", "(Ljava/lang/String;)");
+                            lineDummy2 = lineDummy2.replace("(I)", "(Ljava/lang/String;)");
+                        }else if(lineDummy2.contains("setImageResource")){
+                            lineDummy1 = lineDummy1.replace("(I)", "(Ljava/lang/String;)");
+                            lineDummy2 = lineDummy2.replace("(I)", "(Ljava/lang/String;)");
+                        }
+
+                        bw1.write(lineDummy1);
+                        bw1.newLine();
+
+                        bw2.write(lineDummy2);
+                        bw2.newLine();
+                    }
+                } catch (Exception e) {
+                    return null;
+                } finally {
+                    try {
+                        if (br != null)
+                            br.close();
+                    } catch (IOException e) {
+                        //
+                    }
+                    try {
+                        if (bw1 != null)
+                            bw1.close();
+                    } catch (IOException e) {
+                        //
+                    }
+                    try {
+                        if (bw2 != null)
+                            bw2.close();
+                    } catch (IOException e) {
+                        //
+                    }
+                }
+            }
+        }
+
+        for(int i=0; i<smaliFileList.length; i++) {
+            String SMALIoldFileName = "/data/collaboroid/preprocess/"
+                    + CURRENT_AGENT_APP + "/originalSmali/" + smaliFileList[i];
+            try {
+                System.out.println(SMALIoldFileName);
+
+                File sourceFile = new File(SMALIoldFileName);
+                BufferedReader reversedLineInputStream = new BufferedReader(new InputStreamReader(new ReverseLineInputStream(sourceFile)));
+                String line;
+                while ((line = reversedLineInputStream.readLine()) != null) {
+                    if (line.contains("setImageResource(Ljava/lang/String;)V")) {
+                        String lookingForString = "";
+                        String AnswerForString = "";
+                        lookingForString = line.substring(4, line.lastIndexOf(",")).trim().split(",")[1];
+                        System.out.println("lookingForString : " + lookingForString);
+                        if (lookingForString.contains("}")) {
+                            lookingForString = lookingForString.trim().split("\\}")[0];
+                        }
+                        while (true) {
+                            String l = reversedLineInputStream.readLine();
+                            if (l.contains(lookingForString)) {
+                                if(l.contains("const-string/jumbo")){
+                                    AnswerForString = l.split(",", 2)[1];
+                                    AnswerForString = AnswerForString.substring(0, AnswerForString.length() - 1);
+                                    if (AnswerForString.contains("\"")) {
+                                        AnswerForString = AnswerForString.split("\"", 2)[1];
+                                        //=> "SBJ_C"
+                                        AnswerForString = AnswerForString.substring(0, AnswerForString.length());
+                                        // add
+                                        resources.add("assets/"+AnswerForString);
+                                        break;
+                                    }
+                                }else {
+                                    break;
+                                    //lookingForString = l.split(",", 2)[1];
+                                }
+                            }
+                        }
+
+                    }
+                }
+
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }
+
+        //duplicate remove
+        HashSet hs = new HashSet(resources);
+        List<String> newResources = new ArrayList<>(hs);
+
+        HashMap<String, List<String>> relatedResources = new HashMap<>();
+        relatedResources.put(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY, newResources);
+
+        return relatedResources;
+    }
+
+    private void DeleteRecursiveFiles(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursive(child);
+
+    }
+    private void DeleteRecursive(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursive(child);
+
+        fileOrDirectory.delete();
+
+    }
+    private void PermissionRecursiveFiles(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                PermissionRecursive(child);
+
+    }
+    private void PermissionRecursive(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                PermissionRecursive(child);
+
+        try {
+            // get the object of runtime
+            Runtime rt = Runtime.getRuntime();
+            Process m ;
+            int c=0;
+            String command = "chmod " + 777 + " " + fileOrDirectory.getPath();
+            m = rt.exec(command);
+            InputStream bis = new BufferedInputStream(m.getInputStream());
+            while(c!=-1) {
+                c=bis.read();
+                //printing something on console
+                System.out.print("#");
+            }// this while loop executes till the batch file ends executing
+            m = null;
+            bis.close();
+        } catch (Exception exe) {
+            exe.printStackTrace();
+        }
+
+    }
+    private void renameActivityToMainDummy1(String toSendActivity){
+
+        BufferedReader br1 = null;
+        BufferedWriter bw1 = null;
+
+
+        String smaliFileList[] = smali$FileList.get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+        for(int i=0; i<smaliFileList.length; i++){
+
+            String SMALIoldFileName = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/modifiedSmaliDummy1/"+smaliFileList[i];
+            //smaliFileList[i] include .smali
+            String SMALInewFileName = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/smaliFolder/com/collaboroid/dummy1/"
+                    +smaliFileList[i].replace(toSendActivity, "MainActivity");
+
+            br1 = null;
+            bw1 = null;
+            try {
+                br1 = new BufferedReader(new FileReader(SMALIoldFileName));
+                bw1 = new BufferedWriter(new FileWriter(SMALInewFileName));
+                String line;
+
+                while ((line = br1.readLine()) != null) {
+                    bw1.write(line);
+                    bw1.newLine();
+                }
+            } catch (Exception e) {
+                return;
+            } finally {
+                try {
+                    if (br1 != null)
+                        br1.close();
+                } catch (IOException e) {
+                    //
+                }
+                try {
+                    if (bw1 != null)
+                        bw1.close();
+                } catch (IOException e) {
+                    //
+                }
+            }
+        }
+    }
+    private void renameActivityToMainDummy2(String toSendActivity){
+
+        BufferedReader br1 = null;
+        BufferedWriter bw1 = null;
+
+
+        String smaliFileList[] = smali$FileList.get(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+        for(int i=0; i<smaliFileList.length; i++){
+
+            String SMALIoldFileName = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/modifiedSmaliDummy2/"+smaliFileList[i];
+            //smaliFileList[i] include .smali
+            String SMALInewFileName = "/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/smaliFolder/com/collaboroid/dummy2/"
+                    +smaliFileList[i].replace(toSendActivity, "MainActivity");
+            br1 = null;
+            bw1 = null;
+            try {
+                br1 = new BufferedReader(new FileReader(SMALIoldFileName));
+                bw1 = new BufferedWriter(new FileWriter(SMALInewFileName));
+                String line;
+
+                while ((line = br1.readLine()) != null) {
+                    bw1.write(line);
+                    bw1.newLine();
+                }
+            } catch (Exception e) {
+                return;
+            } finally {
+                try {
+                    if (br1 != null)
+                        br1.close();
+                } catch (IOException e) {
+                    //
+                }
+                try {
+                    if (bw1 != null)
+                        bw1.close();
+                } catch (IOException e) {
+                    //
+                }
+            }
+        }
+    }
+    public class Decompress {
+        private String _zipFile;  //저장된 zip 파일 위치
+        private String _location; //압출을 풀 위치
+
+        public Decompress(String zipFile, String location) {
+            _zipFile = zipFile;
+            _location = location;
+
+            _dirChecker(""); //폴더를 만들기 위한 함수로 아래에 정의 되어 있습니다.
+        }
+
+        public void unzip() {
+            try  {
+                FileInputStream fin = new FileInputStream(_zipFile);
+                ZipInputStream zin = new ZipInputStream(fin);
+                ZipEntry ze = null;
+                while ((ze = zin.getNextEntry()) != null) {
+                    Log.v("Decompress", "Unzipping " + ze.getName());   //압축이 풀리면서 logcat으로 zip 안에 있던 파일들을 볼 수 있습니다.
+
+                    if(ze.isDirectory()) {
+                        _dirChecker(ze.getName());
+                    } else {
+                        FileOutputStream fout = new FileOutputStream(_location + ze.getName());
+                        BufferedInputStream in = new BufferedInputStream(zin);  //이렇게 지정하지 않고 unzip을 수행하면 속도가 매우 느려집니다.
+                        BufferedOutputStream out = new BufferedOutputStream(fout);
+                        byte b[] = new byte[1024];
+                        int n;
+                        while ((n = in.read(b,0,1024)) >= 0) {
+                            out.write(b,0,n);
+                        }
+
+                        zin.closeEntry();
+                        fout.close();
+                    }
+
+                }
+                zin.close();
+            } catch(Exception e) {
+                Log.e("Decompress", "unzip", e);
+            }
+        }
+
+        //변수 location에 저장된 directory의 폴더를 만듭니다.
+        private void _dirChecker(String dir) {
+            File f = new File(_location + dir);
+
+            if(!f.isDirectory()) {
+                f.mkdirs();
+            }
+        }
+    }
+    private void copyAndRename(String apkPath, String zipPath){
+        File sourceLocation = new File (apkPath);
+        File targetLocation = new File (zipPath);
+        Log.v(TAG, "sourceLocation: " + sourceLocation);
+        Log.v(TAG, "targetLocation: " + targetLocation);
+        try {
+            int actionChoice = 2;
+            if(actionChoice==1){
+                if(sourceLocation.renameTo(targetLocation)){
+                    Log.v(TAG, "Move file successful.");
+                }else{
+                    Log.v(TAG, "Move file failed.");
+                }
+            }
+            else{
+                if(sourceLocation.exists()){
+                    InputStream in = new FileInputStream(sourceLocation);
+                    OutputStream out = new FileOutputStream(targetLocation);
+                    byte[] buf = new byte[1024];
+                    int len;
+                    while ((len = in.read(buf)) > 0) {
+                        out.write(buf, 0, len);
+                    }
+                    in.close();
+                    out.close();
+                    Log.v(TAG, "Copy file successful.");
+                }else{
+                    Log.v(TAG, "Copy file failed. Source file missing.");
+                }
+            }
+        } catch (NullPointerException e) {
+            e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void makeActivityTable(String[] srcList)
+    {
+        List<String> resultOnCreate = new ArrayList<>();
+        List<String> AllActivity = new ArrayList<>();
+        List<String> forActivity = new ArrayList<>();
+        List<String> onCreateMethodTemp;
+
+        //private HashMap<String, HashMap<String, List<String>>> ActivityTable = new HashMap<>();
+        //1.appName     2.packageName + MainActivityName ------- related activity
+        List<String> activities = new ArrayList<>();
+        HashMap<String, List<String>> mainActivity = new HashMap<>();
+
+        for(int j=0; j<srcList.length; j++){
+
+            //File sourceFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/originalSmali/"+srcList[j]);
+            File sourceFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/originalSmali/"+srcList[j]);
+            try {
+                BufferedReader reversedLineInputStream = new BufferedReader(new InputStreamReader(new ReverseLineInputStream(sourceFile)));
+//            ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(new File(oldFileName));
+                String line;
+                while ((line = reversedLineInputStream.readLine()) != null) {
+                    String lookingForString = "";
+                    String AnswerForString = "";
+                    if (line.contains(".end method")) {
+                        onCreateMethodTemp = new ArrayList<>();
+                        boolean result = false;
+                        boolean loopResult = false;
+                        String gotoName = "no";
+                        while (true) {
+                            line = reversedLineInputStream.readLine();
+                            if (line.contains("goto") && !loopResult) {
+                                gotoName = line.trim().split(":")[1];
+                                line = reversedLineInputStream.readLine();
+                                line = reversedLineInputStream.readLine();
+                                if(line.contains("add-int/lit8")){
+                                    loopResult = true;
+                                }
+
+
+                                // find for loop
+                            }
+                            if (line.contains("launchActivity(Ljava/lang/String;)V")) {
+                                lookingForString = line.substring(4, line.lastIndexOf(",")).trim().split(",")[1];
+                                if (lookingForString.contains("}")) {
+                                    lookingForString = lookingForString.trim().split("\\}")[0];
+                                }
+                                while (true) {
+                                    String l = reversedLineInputStream.readLine();
+                                    if (l.contains(lookingForString)) {
+                                        AnswerForString = l.split(",", 2)[1];
+                                        AnswerForString = AnswerForString.substring(0, AnswerForString.length() - 1);
+                                        if (AnswerForString.contains("\"")) {
+                                            AnswerForString = AnswerForString.split("\"", 2)[1];
+                                            AnswerForString = AnswerForString.substring(0, AnswerForString.length());
+                                            // add
+                                            result = true;
+                                            onCreateMethodTemp.add(AnswerForString);
+                                            AllActivity.add(AnswerForString);
+                                            break;
+                                        } else {
+                                            lookingForString = l.split(",", 2)[1];
+                                        }
+                                    }
+                                }
+                            }
+                            if (line.contains("launchActivity(ILjava/lang/String;)V")) {
+
+                                lookingForString = line.substring(4, line.lastIndexOf(",")).trim().split(",")[2];
+                                if (lookingForString.contains("}")) {
+                                    lookingForString = lookingForString.trim().split("\\}")[0];
+                                }
+                                while (true) {
+                                    String l = reversedLineInputStream.readLine();
+                                    if (l.contains(lookingForString)) {
+                                        AnswerForString = l.split(",", 2)[1];
+                                        AnswerForString = AnswerForString.substring(0, AnswerForString.length() - 1);
+                                        if (AnswerForString.contains("\"")) {
+                                            AnswerForString = AnswerForString.split("\"", 2)[1];
+                                            AnswerForString = AnswerForString.substring(0, AnswerForString.length());
+                                            // add
+                                            result = true;
+                                            onCreateMethodTemp.add(AnswerForString);
+
+                                            AllActivity.add(AnswerForString);
+                                            break;
+                                        } else {
+                                            lookingForString = l.split(",", 2)[1];
+                                        }
+                                    }
+                                }
+                            }
+                            if (line.contains("launchActivity(ILjava/lang/String;Landroid/os/Bundle;)V")) {
+
+                                lookingForString = line.substring(4, line.lastIndexOf(",")).trim().split(",")[2];
+                                if (lookingForString.contains("}")) {
+                                    lookingForString = lookingForString.trim().split("\\}")[0];
+                                }
+                                while (true) {
+                                    String l = reversedLineInputStream.readLine();
+                                    if (l.contains(lookingForString)) {
+                                        AnswerForString = l.split(",", 2)[1];
+                                        AnswerForString = AnswerForString.substring(0, AnswerForString.length() - 1);
+                                        if (AnswerForString.contains("\"")) {
+                                            AnswerForString = AnswerForString.split("\"", 2)[1];
+                                            AnswerForString = AnswerForString.substring(0, AnswerForString.length());
+                                            // add
+                                            result = true;
+                                            onCreateMethodTemp.add(AnswerForString);
+
+                                            AllActivity.add(AnswerForString);
+                                            break;
+                                        } else {
+                                            lookingForString = l.split(",", 2)[1];
+                                        }
+                                    }
+                                }
+                            }
+                            if (line.contains("launchActivity(Ljava/lang/String;Landroid/os/Bundle;)V")) {
+                                lookingForString = line.substring(4, line.lastIndexOf(",")).trim().split(",")[1];
+                                if (lookingForString.contains("}")) {
+                                    lookingForString = lookingForString.trim().split("\\}")[0];
+                                }
+                                while (true) {
+                                    String l = reversedLineInputStream.readLine();
+                                    // System.out.println("l : " + l);
+                                    if (l.contains(lookingForString)) {
+                                        // System.out.println("ll : " + l);
+                                        AnswerForString = l.split(",", 2)[1];
+                                        AnswerForString = AnswerForString.substring(0, AnswerForString.length() - 1);
+                                        if (AnswerForString.contains("\"")) {
+                                            AnswerForString = AnswerForString.split("\"", 2)[1];
+                                            AnswerForString = AnswerForString.substring(0, AnswerForString.length());
+                                            // add
+                                            result = true;
+                                            onCreateMethodTemp.add(AnswerForString);
+                                            AllActivity.add(AnswerForString);
+                                            break;
+                                        } else {
+                                            lookingForString = l.split(",", 2)[1];
+                                        }
+                                    }
+                                }
+                            }
+                            if (!gotoName.equals("no") && line.contains(gotoName) && loopResult && result) {
+                                //for loop * 10
+                                List<String> temp = new ArrayList<>();
+
+                                for(int z=0; z<onCreateMethodTemp.size(); z++){
+                                    temp.add(onCreateMethodTemp.get(z));
+                                }
+
+                                for(int z=0; z<10; z++){
+                                    forActivity.addAll(temp);
+                                }
+                            }
+                            if (line.contains(".method")) {
+                                if (result) {
+                                    // if onCreate
+                                    // 중복제거
+
+                                    HashSet hs = new HashSet(onCreateMethodTemp);
+                                    onCreateMethodTemp = new ArrayList<>(hs);
+                                    if (line.contains("onCreate")) {
+                                        resultOnCreate.addAll(onCreateMethodTemp);
+                                    } // if onClick
+                                    else if (line.contains("onClick")) {
+                                    } else {
+                                        String s = search(srcList, line.trim().split(" ")[2]);
+                                        String split_temp[] = s.trim().split("@");
+                                        for (int split_i = 0; split_i < split_temp.length; split_i++) {
+                                            if (split_temp[split_i].contains("onCreate")) {
+                                                for (int z = 0; z < onCreateMethodTemp.size(); z++) {
+                                                    onCreateMethodTemp.set(z, onCreateMethodTemp.get(z) + "@"
+                                                            + split_temp[split_i].trim().split("<-")[0]);
+                                                }
+                                                resultOnCreate.addAll(onCreateMethodTemp);
+                                            }
+                                        }
+
+                                    }
+                                    // if onClick && for
+                                }
+                                break;
+                            }
+                        }
+                    }
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+
+        //17.07.23
+
+        ArrayList<MethodLineNode> list = new ArrayList<>();
+        for (int i = 0; i < resultOnCreate.size(); i++) {
+            if(resultOnCreate.get(i).contains("@")){
+                MethodLineNode node = new MethodLineNode(orderScore(srcList, resultOnCreate.get(i).trim().split("@")[1]),
+                        resultOnCreate.get(i).trim().split("@")[0]);
+                list.add(node);
+            }else{
+                MethodLineNode node = new MethodLineNode(orderScore(srcList, resultOnCreate.get(i)),
+                        resultOnCreate.get(i));
+                list.add(node);
+            }
+        }
+
+
+
+        Collections.sort(list);
+
+        for(int i=0; i<list.size(); i++){
+            Log.d("search test","list : " + list.get(i).getLineNum() + " / "+ list.get(i).getMethodName());
+        }
+
+        HashMap<String, Double> scoreMap = new HashMap<>();
+        //ScoreMap scoremap = new ScoreMap(0.0);
+        AllActivity.addAll(forActivity);
+        for(int i=0; i<AllActivity.size(); i++){
+            Double value = 0.0;
+            if(scoreMap.containsKey(AllActivity.get(i))){
+                value = scoreMap.get(AllActivity.get(i));
+            }else{
+                value = 0.0;
+            }
+            scoreMap.put(AllActivity.get(i), value + 0.001);
+        }
+        for(int i=0; i<list.size(); i++){
+            Double value = 0.0;
+            if(scoreMap.containsKey(list.get(i).getMethodName())){
+                value = scoreMap.get(list.get(i).getMethodName());
+            }else{
+                value = 0.0;
+            }
+            scoreMap.put(list.get(i).getMethodName(),
+                    value + (i + 1.0));
+        }
+
+
+        //TreeMap<String, Double> tm = new TreeMap<String, Double>(scoreMap);
+        //Iterator<String> iteratorKey = tm.keySet().iterator();   //키값 오름차순 정렬(기본)
+        List<String> newActivities = new ArrayList<>();
+
+        Iterator it = sortByValue(scoreMap).iterator();
+
+        while(it.hasNext()) {
+            String temp = (String) it.next();
+            System.out.println(temp + " = " + scoreMap.get(temp));
+            newActivities.add(temp);
+        }
+
+
+
+        mainActivity.put(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY, newActivities);
+        ActivityTable.put(CURRENT_AGENT_APP, mainActivity);
+    }
+    //별도의 스태틱 함수로 구현
+    public List sortByValue(final Map map) {
+        List<String> list = new ArrayList();
+        list.addAll(map.keySet());
+
+        Collections.sort(list,new Comparator() {
+
+            public int compare(Object o1,Object o2) {
+                Object v1 = map.get(o1);
+                Object v2 = map.get(o2);
+
+                return ((Comparable) v2).compareTo(v1);
+            }
+
+        });
+        //Collections.reverse(list); // 주석시 오름차순
+        return list;
+    }
+    public int orderScore(String[] srcList, String target) {
+        for (int i = 0; i < srcList.length; i++) {
+            File sourceFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/originalSmali/"+srcList[i]);
+            try {
+
+                BufferedReader lineInputStream = new BufferedReader(new FileReader(sourceFile));
+                String line;
+                while ((line = lineInputStream.readLine()) != null) {
+                    if (line.contains("onCreate(Landroid/os/Bundle;)V")) {
+                        String l;
+                        int result = 0;
+                        while ((l = lineInputStream.readLine()) != null) {
+                            result++;
+                            if (l.contains(target)) {
+                                return result;
+                            }
+                            if (l.contains(".end method")) {
+                                break;
+                            }
+                        }
+                    }
+                }
+            } catch (Exception e) {
+
+            }
+        }
+        return 0;
+    }
+    public String search(String[] srcList, String target) {
+        String result = "";
+        for (int i = 0; i < srcList.length; i++) {
+            // target을 향해 모든 smali 쭈욱
+            File sourceFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/originalSmali/"+srcList[i]);
+            try {
+                BufferedReader reversedLineInputStream = new BufferedReader(
+                        new InputStreamReader(new ReverseLineInputStream(sourceFile)));
+                String line;
+                while ((line = reversedLineInputStream.readLine()) != null) {
+                    if (line.contains(".end method")) {
+                        boolean find = false;
+                        String l;
+                        while ((l = reversedLineInputStream.readLine()) != null) {
+
+                            if (l.contains(target) && !l.contains(".method")) {
+                                find = true;
+                            }
+                            if (l.contains(".method")) {
+
+                                if (find) {
+                                    if (l.contains("onCreate")) {
+                                        return "onCreate";
+                                    } else if (l.contains("onClick")) {
+                                        return "onClick";
+                                    } else {
+                                        find = false;
+                                        result += l.trim().split(" ")[2] + "<-"
+                                                + search(srcList, l.trim().split(" ")[2]) + "@";
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        if (result.equals("")) {
+            return "nofunction";
+        } else {
+            return result;
+        }
+    }
+    public void writeActivityTable(List<String> sf){
+        PrintWriter pw = null;
+        BufferedReader lineInputStream = null;
+        File table = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/ActivityTable.txt");
+        if(table.exists()){
+            try{
+                lineInputStream = new BufferedReader(new FileReader(table));
+                String line = "";
+                boolean result = true;
+                while ((line = lineInputStream.readLine()) != null) {
+                    if (line.contains(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY)) {
+                        result = false;
+                    }
+                }
+                if(result){
+                    pw = new PrintWriter(
+                            new FileWriter("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/ActivityTable.txt", true));
+                    pw.write(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+                    for(int i=0; i<sf.size(); i++){
+                        pw.write("@");
+                        pw.write(sf.get(i));
+                    }
+                    pw.write("\n\r");
+                }
+                if(lineInputStream != null){
+                    lineInputStream.close();
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+            }finally{
+                if(pw != null) {
+                    pw.close();
+                }
+            }
+        }else{
+            try {
+                pw = new PrintWriter(
+                        new FileWriter("/data/collaboroid/preprocess/" + CURRENT_AGENT_APP + "/ActivityTable.txt", true));
+                pw.write(CURRENT_AGENT_PACKAGE + "." + CURRENT_AGENT_ACTIVITY);
+                for (int i = 0; i < sf.size(); i++) {
+                    pw.write("@");
+                    pw.write(sf.get(i));
+                }
+                pw.write("\n\r");
+            }catch(Exception e){
+                e.printStackTrace();
+            }finally{
+                if(pw != null) {
+                    pw.close();
+                }
+            }
+        }
+
+
+    }
+    public void writeResourceTable(List<String> sf){
+        PrintWriter pw = null;
+        BufferedReader lineInputStream = null;
+        File table = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/ResourceTable.txt");
+        if(table.exists()){
+            try{
+                lineInputStream = new BufferedReader(new FileReader(table));
+                String line = "";
+                boolean result = true;
+                while ((line = lineInputStream.readLine()) != null) {
+                    if (line.contains(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY)) {
+                        result = false;
+                    }
+                }
+                if(result){
+                    pw = new PrintWriter(
+                            new FileWriter("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/ResourceTable.txt", true));
+                    pw.write(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+                    for(int i=0; i<sf.size(); i++){
+                        pw.write("@");
+                        pw.write(sf.get(i));
+                    }
+                    pw.write("\n\r");
+                }
+                if(lineInputStream != null){
+                    lineInputStream.close();
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+            }finally{
+                if(pw != null) {
+                    pw.close();
+                }
+            }
+        }else{
+            try{
+                pw = new PrintWriter(
+                        new FileWriter("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/ResourceTable.txt", true));
+                pw.write(CURRENT_AGENT_PACKAGE+"."+CURRENT_AGENT_ACTIVITY);
+                for(int i=0; i<sf.size(); i++){
+                    pw.write("@");
+                    pw.write(sf.get(i));
+                }
+                pw.write("\n\r");
+            }catch (Exception e){
+                e.printStackTrace();
+            }finally{
+                if(pw != null) {
+                    pw.close();
+                }
+            }
+        }
+
+    }
+    /**
+     * @hide
+     */
+    public List<String> relateResourceXML(String xmlFilePath){
+        List<String> resources = new ArrayList<>();
+
+        //File file = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/"+xmlFilePath);
+        File file = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/"+xmlFilePath);
+
+        BufferedReader br = null;
+        try {
+            br = new BufferedReader(new FileReader(file));
+            String line;
+            while ((line = br.readLine()) != null) {
+                if(line.contains("drawable")){
+                    String pngFile = line.split("\\/")[1].split("\"")[0];
+                    File inFile = null;
+
+                    File inFilePng = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/assets/", pngFile+".png");
+                    String pngFilePath = "";
+                    if(inFilePng.exists()){
+                        pngFile += ".png";
+                        pngFilePath = "res/drawable/"+pngFile;
+                        inFile = inFilePng;
+                    }
+                    File inFileJpg = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/assets/", pngFile+".jpg");
+                    if(inFileJpg.exists()){
+                        pngFile += ".jpg";
+                        pngFilePath = "res/drawable/"+pngFile;
+                        inFile = inFileJpg;
+                    }
+
+                    File inFileXml = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/assets/", pngFile+".xml");
+                    if(inFileXml.exists()){
+                        pngFile += ".xml";
+                        pngFilePath = "res/drawable/"+pngFile;
+                        inFile = inFileXml;
+                    }
+
+                    FileInputStream in = new FileInputStream(inFile);
+                    //copy resource png file.
+                    File outFile = new File("/data/collaboroid/preprocess/"+CURRENT_AGENT_APP+"/res/drawable/", pngFile);
+                    FileOutputStream out = new FileOutputStream(outFile);
+                    copyFile(in, out);
+
+                    resources.add(pngFilePath);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (br != null)
+                    br.close();
+            } catch (IOException e) {
+                //
+            }
+        }
+        return resources;
+    }
 }
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ProviderInfo.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ProviderInfo.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ProviderInfo.java	2017-09-27 02:07:48.943736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ProviderInfo.java	2017-08-22 12:32:43.782645000 +0900
@@ -70,7 +70,10 @@
      *  to run in different process.  If false, a single instances is always
      *  run in {@link #processName}. */
     public boolean multiprocess = false;
-    
+
+    //collaboroid
+    public boolean remoteable = false;
+
     /** Used to control initialization order of single-process providers
      *  running in the same process.  Higher goes first. */
     public int initOrder = 0;
@@ -109,6 +112,9 @@
         uriPermissionPatterns = orig.uriPermissionPatterns;
         pathPermissions = orig.pathPermissions;
         multiprocess = orig.multiprocess;
+        //collaboroid
+        remoteable = orig.remoteable;
+
         initOrder = orig.initOrder;
         flags = orig.flags;
         isSyncable = orig.isSyncable;
@@ -133,6 +139,9 @@
         out.writeTypedArray(uriPermissionPatterns, parcelableFlags);
         out.writeTypedArray(pathPermissions, parcelableFlags);
         out.writeInt(multiprocess ? 1 : 0);
+        //collaboroid
+        out.writeInt(remoteable ? 1 : 0);
+
         out.writeInt(initOrder);
         out.writeInt(flags);
         out.writeInt(isSyncable ? 1 : 0);
@@ -162,6 +171,9 @@
         uriPermissionPatterns = in.createTypedArray(PatternMatcher.CREATOR);
         pathPermissions = in.createTypedArray(PathPermission.CREATOR);
         multiprocess = in.readInt() != 0;
+        //collaboroid
+        remoteable = in.readInt() != 0;
+
         initOrder = in.readInt();
         flags = in.readInt();
         isSyncable = in.readInt() != 0;
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ReverseLineInputStream.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ReverseLineInputStream.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/pm/ReverseLineInputStream.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/pm/ReverseLineInputStream.java	2017-07-24 13:56:04.398019000 +0900
@@ -0,0 +1,130 @@
+package android.content.pm;
+
+/**
+ * Created by jake on 17. 3. 2.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+
+
+public class ReverseLineInputStream extends InputStream {
+
+    private static final int MAX_LINE_BYTES = 1024 * 1024;
+
+    private static final int DEFAULT_BUFFER_SIZE = 1024 * 1024;
+
+    private RandomAccessFile in;
+
+    private long currentFilePos;
+
+    private int bufferSize;
+    private byte[] buffer;
+    private int currentBufferPos;
+
+    private int maxLineBytes;
+    private byte[] currentLine;
+    private int currentLineWritePos = 0;
+    private int currentLineReadPos = 0;
+    private boolean lineBuffered = false;
+
+    public ReverseLineInputStream(File file) throws IOException {
+        this(file, DEFAULT_BUFFER_SIZE, MAX_LINE_BYTES);
+    }
+
+    public ReverseLineInputStream(File file, int bufferSize, int maxLineBytes) throws IOException {
+        this.maxLineBytes = maxLineBytes;
+        in = new RandomAccessFile(file, "r");
+        currentFilePos = file.length() - 1;
+        in.seek(currentFilePos);
+        if (in.readByte() == 0xA) {
+            currentFilePos--;
+        }
+        currentLine = new byte[maxLineBytes];
+        currentLine[0] = 0xA;
+
+        this.bufferSize = bufferSize;
+        buffer = new byte[bufferSize];
+        fillBuffer();
+        fillLineBuffer();
+    }
+
+    @Override
+    public int read() throws IOException {
+        if (currentFilePos <= 0 && currentBufferPos < 0 && currentLineReadPos < 0) {
+            return -1;
+        }
+
+        if (!lineBuffered) {
+            fillLineBuffer();
+        }
+
+
+        if (lineBuffered) {
+            if (currentLineReadPos == 0) {
+                lineBuffered = false;
+            }
+            return currentLine[currentLineReadPos--];
+        }
+        return 0;
+    }
+
+    private void fillBuffer() throws IOException {
+        if (currentFilePos < 0) {
+            return;
+        }
+
+        if (currentFilePos < bufferSize) {
+            in.seek(0);
+            in.read(buffer);
+            currentBufferPos = (int) currentFilePos;
+            currentFilePos = -1;
+        } else {
+            in.seek(currentFilePos);
+            in.read(buffer);
+            currentBufferPos = bufferSize - 1;
+            currentFilePos = currentFilePos - bufferSize;
+        }
+    }
+
+    private void fillLineBuffer() throws IOException {
+        currentLineWritePos = 1;
+        while (true) {
+
+            // we've read all the buffer - need to fill it again
+            if (currentBufferPos < 0) {
+                fillBuffer();
+
+                // nothing was buffered - we reached the beginning of a file
+                if (currentBufferPos < 0) {
+                    currentLineReadPos = currentLineWritePos - 1;
+                    lineBuffered = true;
+                    return;
+                }
+            }
+
+            byte b = buffer[currentBufferPos--];
+
+            // \n is found - line fully buffered
+            if (b == 0xA) {
+                currentLineReadPos = currentLineWritePos - 1;
+                lineBuffered = true;
+                break;
+
+                // just ignore \r for now
+            } else if (b == 0xD) {
+                continue;
+            } else {
+                if (currentLineWritePos == maxLineBytes) {
+                    throw new IOException("file has a line exceeding " + maxLineBytes
+                            + " bytes; use constructor to pickup bigger line buffer");
+                }
+
+                // write the current line bytes in reverse order - reading from
+                // the end will produce the correct line
+                currentLine[currentLineWritePos++] = b;
+            }
+        }
+    }}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/res/ABCManager.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/ABCManager.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/res/ABCManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/ABCManager.java	2017-02-15 11:52:14.457103000 +0900
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * 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 android.content.res;
+
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+import android.util.SparseArray;
+import android.util.TypedValue;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+
+/**
+ * Provides access to an application's raw asset files; see {@link Resources}
+ * for the way most applications will want to retrieve their resource data.
+ * This class presents a lower-level API that allows you to open and read raw
+ * files that have been bundled with the application as a simple stream of
+ * bytes.
+ */
+public final class ABCManager extends AssetManager {
+    /* modes used when opening an asset */
+
+    /**
+     * Mode for {@link #open(String, int)}: no specific information about how
+     * data will be accessed.
+     */
+    public static final int ACCESS_UNKNOWN = 0;
+    /**
+     * Mode for {@link #open(String, int)}: Read chunks, and seek forward and
+     * backward.
+     */
+    public static final int ACCESS_RANDOM = 1;
+    /**
+     * Mode for {@link #open(String, int)}: Read sequentially, with an
+     * occasional forward seek.
+     */
+    public static final int ACCESS_STREAMING = 2;
+    /**
+     * Mode for {@link #open(String, int)}: Attempt to load contents into
+     * memory, for fast small reads.
+     */
+    public static final int ACCESS_BUFFER = 3;
+
+    private static final String TAG = "ABCManager";
+    private static final boolean localLOGV = false || false;
+    
+    private static final boolean DEBUG_REFS = false;
+    
+    private static final Object sSync = new Object();
+    /*package*/ static ABCManager sManager = null;
+
+    private final TypedValue mValue = new TypedValue();
+    private final long[] mOffsets = new long[2];
+    
+    // For communication with native code.
+    private long mObject;
+
+    private StringBlock mStringBlocks[] = null;
+    
+    private int mNumRefs = 1;
+    private boolean mOpen = true;
+    private HashMap<Long, RuntimeException> mRefStacks;
+    private HashMap<String, String> mKeyToPath;
+    private HashMap<String, Integer> mNameToId;
+    
+    //private native int aapt(String resPath, String manifestPath, String outputApk);
+ 
+    /**
+     * Create a new ABCManager containing only the basic system assets.
+     * Applications will not generally use this method, instead retrieving the
+     * appropriate asset manager with {@link Resources#getAssets}.    Not for
+     * use by applications.
+     * {@hide}
+     */
+    public ABCManager() 
+    {
+        if (DEBUG_REFS) {
+        	synchronized (this) {
+                mNumRefs = 0;
+                incRefsLocked(this.hashCode());
+            }
+        }
+        init(false);
+        mKeyToPath = new HashMap<String, String>();
+        mNameToId = new HashMap<String, Integer>();
+        if (localLOGV) Log.v(TAG, "New ABC manager: " + this);
+        //ensureManager();
+    }
+
+    private static void ensureManager() {
+        synchronized (sSync) {
+            if (sManager == null) {
+                ABCManager system = new ABCManager();
+                system.makeStringBlocks(null);
+                sManager = system;
+            }
+        }
+    }
+    
+    /*private ABCManager(boolean isSystem) {
+        if (DEBUG_REFS) {
+            synchronized (this) {
+                mNumRefs = 0;
+                incRefsLocked(this.hashCode());
+            }
+        }
+        init(true);
+        if (localLOGV) Log.v(TAG, "New asset manager: " + this);
+    }*/
+
+    /**
+     * Return a global shared asset manager that provides access to only
+     * system assets (no application assets).
+     * {@hide}
+     */
+    public static ABCManager getManager() {
+    	ensureManager();
+        return sManager;
+    }
+
+    /**
+     * Close this asset manager.
+     */
+    public void close() {
+        synchronized(this) {
+            //System.out.println("Release: num=" + mNumRefs
+            //                   + ", released=" + mReleased);
+            if (mOpen) {
+                mOpen = false;
+                decRefsLocked(this.hashCode());
+            }
+        }
+    }
+
+    public void addResource(int id)
+    {
+    	String entryName = getResourceEntryName(id);
+    	
+    	Log.d(TAG, entryName + " - " + id);
+    	
+    	if(entryName != null)
+    		mNameToId.put(entryName, id);
+    }
+    
+    public int getIdFromName(String name)
+    {
+
+    	if(mNameToId.containsKey(name)){
+            return mNameToId.get(name);
+        }
+    	else{
+            return -1;
+        }
+    }
+
+    public HashMap<String, String> getmKeyToPath(){
+        return this.mKeyToPath;
+    }
+    public HashMap<String, Integer> getmNameToId(){
+        return this.mNameToId;
+    }
+
+    private native final void init(boolean isSystem);
+    private native final void destroy();
+
+    private final void incRefsLocked(long id) {
+        if (DEBUG_REFS) {
+            if (mRefStacks == null) {
+                mRefStacks = new HashMap<Long, RuntimeException>();
+            }
+            RuntimeException ex = new RuntimeException();
+            ex.fillInStackTrace();
+            mRefStacks.put(id, ex);
+        }
+        mNumRefs++;
+    }
+    
+    private final void decRefsLocked(long id) {
+        if (DEBUG_REFS && mRefStacks != null) {
+            mRefStacks.remove(id);
+        }
+        mNumRefs--;
+        //System.out.println("Dec streams: mNumRefs=" + mNumRefs
+        //                   + " mReleased=" + mReleased);
+        if (mNumRefs == 0) {
+            destroy();
+        }
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/res/AssetManager.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/AssetManager.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/res/AssetManager.java	2017-09-27 02:07:48.943736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/AssetManager.java	2017-07-13 14:14:41.760275000 +0900
@@ -33,7 +33,7 @@
  * files that have been bundled with the application as a simple stream of
  * bytes.
  */
-public final class AssetManager implements AutoCloseable {
+public class AssetManager implements AutoCloseable {
     /* modes used when opening an asset */
 
     /**
@@ -100,6 +100,7 @@
         synchronized (sSync) {
             if (sSystem == null) {
                 AssetManager system = new AssetManager(true);
+                //Log.d("reviseApp2","system.makeStringBlocks(null)");
                 system.makeStringBlocks(null);
                 sSystem = system;
             }
@@ -158,6 +159,30 @@
         }
         return null;
     }
+    public CharSequence getResourceText2(int ident) {
+        synchronized (this) {
+
+            //Log.d("reviseApp2","getResourceText2 ident : " + ident);
+            TypedValue tmpValue = mValue;
+            //Log.d("reviseApp2","getResourceText2 before tmpValue.data : " + tmpValue.data);
+            int block = loadResourceValue(ident, (short) 0, tmpValue, true);
+            //Log.d("reviseApp2","getResourceText2 block : " + block);
+            //1
+            //Log.d("reviseApp2","getResourceText2 after tmpValue.data : " + tmpValue.data);
+            //0
+
+            if (block >= 0) {
+                if (tmpValue.type == TypedValue.TYPE_STRING) {
+                    //Log.d("reviseApp2","getResourceText2  mStringBlocks[block] : " + mStringBlocks[block].get(tmpValue.data).toString());
+                    return mStringBlocks[block].get(tmpValue.data);
+
+                }
+                return tmpValue.coerceToString();
+            }
+        }
+        return null;
+    }
+
 
     /**
      * Retrieve the string value associated with a particular resource
@@ -193,12 +218,14 @@
                                                TypedValue outValue,
                                                boolean resolveRefs)
     {
+        //Log.d("reviseApp","getResourceStringArray ident : " + Integer.toHexString(ident));
         int block = loadResourceValue(ident, (short) density, outValue, resolveRefs);
         if (block >= 0) {
             if (outValue.type != TypedValue.TYPE_STRING) {
                 return true;
             }
             outValue.string = mStringBlocks[block].get(outValue.data);
+            //Log.d("reviseApp","getResourceStringArray : " + outValue.string);
             return true;
         }
         return false;
@@ -246,6 +273,7 @@
         if (mStringBlocks == null) {
             synchronized (this) {
                 if (mStringBlocks == null) {
+                    //Log.d("reviseApp2","makeStringBlocks : " + sSystem.mStringBlocks);
                     makeStringBlocks(sSystem.mStringBlocks);
                 }
             }
@@ -255,14 +283,19 @@
     /*package*/ final void makeStringBlocks(StringBlock[] seed) {
         final int seedNum = (seed != null) ? seed.length : 0;
         final int num = getStringBlockCount();
+        //Log.d("reviseApp2","getStringBlockCount : " + getStringBlockCount());
+        //2
         mStringBlocks = new StringBlock[num];
+
         if (localLOGV) Log.v(TAG, "Making string blocks for " + this
                 + ": " + num);
         for (int i=0; i<num; i++) {
             if (i < seedNum) {
                 mStringBlocks[i] = seed[i];
+                //Log.d("reviseApp2","seed[i] : " + mStringBlocks[i].get(0).toString());
             } else {
                 mStringBlocks[i] = new StringBlock(getNativeStringBlock(i), true);
+                //Log.d("reviseApp2","mStringBlocks[i] : " + mStringBlocks[i].get(0).toString());
             }
         }
     }
@@ -310,6 +343,9 @@
             if (!mOpen) {
                 throw new RuntimeException("Assetmanager has been closed");
             }
+            
+            Log.d(TAG, "ASSETMANAGER - " + fileName);
+            
             long asset = openAsset(fileName, accessMode);
             if (asset != 0) {
                 AssetInputStream res = new AssetInputStream(asset);
@@ -437,6 +473,7 @@
      * 
      * @param fileName The name of the file to retrieve.
      */
+    //ADDED COLLABOROID
     public final XmlResourceParser openXmlResourceParser(String fileName)
             throws IOException {
         return openXmlResourceParser(0, fileName);
@@ -463,7 +500,9 @@
      * 
      * @param fileName The name of the file to retrieve.
      */
-    /*package*/ final XmlBlock openXmlBlockAsset(String fileName)
+    /*package*/
+    //ADDED COLLABOROID
+    final XmlBlock openXmlBlockAsset(String fileName)
             throws IOException {
         return openXmlBlockAsset(0, fileName);
     }
@@ -617,8 +656,12 @@
         }
     }
 
+    //collaboroid resource sharing
+
     private native final int addAssetPathNative(String path);
 
+
+
      /**
      * Add a set of assets to overlay an already added set of assets.
      *
@@ -809,6 +852,7 @@
             }
             RuntimeException ex = new RuntimeException();
             ex.fillInStackTrace();
+            //Log.d("reviseApp","mRefStacks id : " + id);
             mRefStacks.put(id, ex);
         }
         mNumRefs++;
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/res/Resources.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/Resources.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/res/Resources.java	2017-09-27 02:07:48.947736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/Resources.java	2017-02-15 16:10:58.358573000 +0900
@@ -149,8 +149,13 @@
     private int mLastCachedXmlBlockIndex = -1;
     private final int[] mCachedXmlBlockIds = { 0, 0, 0, 0 };
     private final XmlBlock[] mCachedXmlBlocks = new XmlBlock[4];
+    
+    private int mALastCachedXmlBlockIndex = -1;
+    private final String[] mACachedXmlBlockKeys = { "", "", "", "" };
+    private final XmlBlock[] mACachedXmlBlocks = new XmlBlock[4];
 
     final AssetManager mAssets;
+    //final ABCManager mABC;
     final DisplayMetrics mMetrics = new DisplayMetrics();
 
     private final Configuration mConfiguration = new Configuration();
@@ -262,7 +267,8 @@
      */
     public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config,
             CompatibilityInfo compatInfo) {
-        mAssets = assets;
+        //mABC = ABCManager.getManager();
+    	mAssets = assets;
         mMetrics.setToDefaults();
         if (compatInfo != null) {
             mCompatibilityInfo = compatInfo;
@@ -776,6 +782,22 @@
         }
         return d;
     }
+    //collaboroid
+    public Drawable getDrawable2(String res) throws NotFoundException {
+
+        int id = getABC().getIdFromName(res);
+
+        Log.d("SBJSBJ getDrawable2","getDrawable2 id : " + id);
+        Log.d("SBJSBJ getDrawable2","getDrawable2 name : " + res);
+
+        final Drawable d = getDrawable(id, null);
+        if (d != null && d.canApplyTheme()) {
+            Log.w(TAG, "Drawable " + getResourceName(id) + " has unresolved theme "
+                    + "attributes! Consider using Resources.getDrawable(int, Theme) or "
+                    + "Context.getDrawable(int).", new RuntimeException());
+        }
+        return d;
+    }
 
     /**
      * Return a drawable object associated with a particular resource ID and
@@ -844,6 +866,13 @@
         return getDrawableForDensity(id, density, null);
     }
 
+    //collaboroid
+    /*
+    public Drawable getDrawableForDensity(String id, int density) throws NotFoundException {
+        return getDrawableForDensity(id, density, null);
+    }*/
+
+
     /**
      * Return a drawable object associated with a particular resource ID for the
      * given screen density in DPI and styled for the specified theme.
@@ -858,6 +887,43 @@
      * @throws NotFoundException Throws NotFoundException if the given ID does
      *             not exist.
      */
+    //collaboroid
+    /*
+    public Drawable getDrawableForDensity(String key, int density, @Nullable Theme theme) {
+        TypedValue value;
+        synchronized (mAccessLock) {
+            value = mTmpValue;
+            if (value == null) {
+                value = new TypedValue();
+            } else {
+                mTmpValue = null;
+            }
+            getValueForDensity(id, density, value, true);
+
+            *//*
+             * Pretend the requested density is actually the display density. If
+             * the drawable returned is not the requested density, then force it
+             * to be scaled later by dividing its density by the ratio of
+             * requested density to actual device density. Drawables that have
+             * undefined density or no density don't need to be handled here.
+             *//*
+            if (value.density > 0 && value.density != TypedValue.DENSITY_NONE) {
+                if (value.density == density) {
+                    value.density = mMetrics.densityDpi;
+                } else {
+                    value.density = (value.density * mMetrics.densityDpi) / density;
+                }
+            }
+        }
+
+        final Drawable res = loadDrawable(value, id, theme);
+        synchronized (mAccessLock) {
+            if (mTmpValue == null) {
+                mTmpValue = value;
+            }
+        }
+        return res;
+    }*/
     @Nullable
     public Drawable getDrawableForDensity(@DrawableRes int id, int density, @Nullable Theme theme) {
         TypedValue value;
@@ -1164,6 +1230,12 @@
     public XmlResourceParser getLayout(@LayoutRes int id) throws NotFoundException {
         return loadXmlResourceParser(id, "layout");
     }
+    
+    // ADDED FOR ABCMANAGER
+    //collaboroid
+    public XmlResourceParser getLayout(String key) throws NotFoundException {
+        return loadXmlResourceParser(key, "layout");
+    }
 
     /**
      * Return an XmlResourceParser through which you can read an animation
@@ -1263,6 +1335,10 @@
     public InputStream openRawResource(@RawRes int id, TypedValue value)
             throws NotFoundException {
         getValue(id, value, true);
+        //collaboroid
+        //Log.d("SBJSBJ openRawResource","SBJSBJ openRawResource id: " + id);
+        //Log.d("SBJSBJ openRawResource","SBJSBJ openRawResource hex id: " + Integer.toHexString(id));
+        //getABC().addResource(id);
 
         try {
             return mAssets.openNonAsset(value.assetCookie, value.string.toString(),
@@ -1373,6 +1449,16 @@
         }
         throw new NotFoundException("Resource ID #0x" + Integer.toHexString(id));
     }
+    //collaboroid
+    /*
+    public void getValueForDensity(String key, int density, TypedValue outValue,
+                                   boolean resolveRefs) throws NotFoundException {
+        boolean found = mAssets.getResourceValue(id, density, outValue, resolveRefs);
+        if (found) {
+            return;
+        }
+        throw new NotFoundException("Resource ID #0x" + Integer.toHexString(id));
+    }*/
 
     /**
      * Return the raw data associated with a particular resource ID.
@@ -2293,6 +2379,13 @@
                 + Integer.toHexString(resid));
     }
     
+    /*public String getResourceEntryName2(@AnyRes int resid) throws NotFoundException {
+        String str = mABC.getResourceEntryName(resid);
+        if (str != null) return str;
+        throw new NotFoundException("Unable to find resource ID #0x"
+                + Integer.toHexString(resid));
+    }*/
+    
     /**
      * Parse a series of {@link android.R.styleable#Extra &lt;extra&gt;} tags from
      * an XML file.  You call this when you are at the parent tag of the
@@ -2395,6 +2488,19 @@
     public final AssetManager getAssets() {
         return mAssets;
     }
+    
+    // ADDED FOR COLLABOROID
+    public final ABCManager getABC() {
+    	if(mAssets instanceof ABCManager)
+        	return (ABCManager)mAssets;
+    	else
+    	{
+    		ABCManager m = new ABCManager();
+    		m.addAssetPath("ee");
+    		
+    		return m;
+    	}
+    }
 
     /**
      * Call this to remove all cached loaded layout resources from the
@@ -2493,6 +2599,9 @@
             // Log only framework resources
             if ((id >>> 24) == 0x1) {
                 final String name = getResourceName(id);
+                //collaboroid
+                Log.d("SBJSBJ loadDrawable" ,"SBJSBJ loadDrawable : "+ id);
+                Log.d("SBJSBJ loadDrawable" ,"SBJSBJ loadDrawable : "+ name);
                 if (name != null) {
                     Log.d("PreloadDrawable", name);
                 }
@@ -2773,6 +2882,7 @@
             }
             getValue(id, value, true);
             if (value.type == TypedValue.TYPE_STRING) {
+            	//Log.d(TAG, value.string.toString());
                 return loadXmlResourceParser(value.string.toString(), id,
                         value.assetCookie, type);
             }
@@ -2782,6 +2892,60 @@
         }
     }
     
+    // ADDED FOR ABCMANAGER
+    //collaboroid
+    XmlResourceParser loadXmlResourceParser(String key, String type) throws NotFoundException {
+        //String file = mABC.getResourcePath(key);
+        String file = key;
+        Log.d(TAG, "KEY: " + key + " PATH: " + file);
+        if(file != null)
+        {
+            try {
+                // These may be compiled...
+                synchronized (mACachedXmlBlockKeys) {
+                    // First see if this block is in our cache.
+                    final int num = mACachedXmlBlockKeys.length;
+                    
+                    for (int i=0; i<num; i++) {
+                        if (mACachedXmlBlockKeys[i].equals(key)) {
+                            //System.out.println("**** REUSING XML BLOCK!  id="
+                            //                   + id + ", index=" + i);
+                            return mACachedXmlBlocks[i].newParser();
+                        }
+                    }
+
+                    // Not in the cache, create a new block and put it at
+                    // the next slot in the cache.
+                    XmlBlock block = mAssets.openXmlBlockAsset(file);
+                    if (block != null) {
+                        int pos = mALastCachedXmlBlockIndex+1;
+                        if (pos >= num) pos = 0;
+                        mALastCachedXmlBlockIndex = pos;
+                        XmlBlock oldBlock = mACachedXmlBlocks[pos];
+                        if (oldBlock != null) {
+                            oldBlock.close();
+                        }
+                        mACachedXmlBlockKeys[pos] = key;
+                        mACachedXmlBlocks[pos] = block;
+                        //System.out.println("**** CACHING NEW XML BLOCK!  id="
+                        //                   + id + ", index=" + pos);
+                        return block.newParser();
+                    }
+                }
+            } catch (Exception e) {
+                NotFoundException rnf = new NotFoundException(
+                        "1File " + file + " from xml type " + type + " resource Key: "
+                        + key);
+                rnf.initCause(e);
+                throw rnf;
+            }
+        }
+
+        throw new NotFoundException(
+                "2File " + file + " from xml type " + type + " resource Key: "
+               + key);
+    }
+    
     /*package*/ XmlResourceParser loadXmlResourceParser(String file, int id,
             int assetCookie, String type) throws NotFoundException {
         if (id != 0) {
@@ -2846,7 +3010,8 @@
     }
 
     private Resources() {
-        mAssets = AssetManager.getSystem();
+        //mABC = ABCManager.getManager();
+    	mAssets = AssetManager.getSystem();
         // NOTE: Intentionally leaving this uninitialized (all values set
         // to zero), so that anyone who tries to do something that requires
         // metrics will get a very wrong value.
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/res/TypedArray.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/TypedArray.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/res/TypedArray.java	2017-09-27 02:07:48.947736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/TypedArray.java	2017-07-12 13:48:45.815966000 +0900
@@ -800,6 +800,13 @@
      * @return Attribute resource identifier, or defValue if not defined.
      * @throws RuntimeException if the TypedArray has already been recycled.
      */
+
+    //reviseApp
+    public int[] getmIndices(){
+        return this.mIndices;
+    }
+    public int[] getmData(){return this.mData;}
+
     @AnyRes
     public int getResourceId(int index, int defValue) {
         if (mRecycled) {
@@ -1169,4 +1176,5 @@
     public String toString() {
         return Arrays.toString(mData);
     }
+
 }
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/content/res/XmlBlock.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/XmlBlock.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/content/res/XmlBlock.java	2017-09-27 02:07:48.947736110 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/content/res/XmlBlock.java	2017-01-29 02:51:19.633888000 +0900
@@ -35,13 +35,15 @@
     private static final boolean DEBUG=false;
 
     public XmlBlock(byte[] data) {
-        mAssets = null;
+        mABC = null;
+    	mAssets = null;
         mNative = nativeCreate(data, 0, data.length);
         mStrings = new StringBlock(nativeGetStringBlock(mNative), false);
     }
 
     public XmlBlock(byte[] data, int offset, int size) {
-        mAssets = null;
+    	mABC = null;
+    	mAssets = null;
         mNative = nativeCreate(data, offset, size);
         mStrings = new StringBlock(nativeGetStringBlock(mNative), false);
     }
@@ -477,11 +479,22 @@
      *  of this newly creating XmlBlock.
      */
     XmlBlock(AssetManager assets, long xmlBlock) {
-        mAssets = assets;
+        mABC = null;
+    	mAssets = assets;
+        mNative = xmlBlock;
+        mStrings = new StringBlock(nativeGetStringBlock(xmlBlock), false);
+    }
+    
+    // ADDED FOR COLLABOROID
+    XmlBlock(ABCManager abc, long xmlBlock) {
+        mABC = abc;
+        mAssets = null;
         mNative = xmlBlock;
         mStrings = new StringBlock(nativeGetStringBlock(xmlBlock), false);
     }
+    
 
+    private final ABCManager mABC;
     private final AssetManager mAssets;
     private final long mNative;
     /*package*/ final StringBlock mStrings;
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/provider/Settings.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/provider/Settings.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/provider/Settings.java	2017-09-27 02:07:49.015736109 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/provider/Settings.java	2017-01-29 02:51:19.389885000 +0900
@@ -3870,6 +3870,8 @@
             MOVED_TO_GLOBAL.add(Settings.Global.DEFAULT_DNS_SERVER);
             MOVED_TO_GLOBAL.add(Settings.Global.PREFERRED_NETWORK_MODE);
             MOVED_TO_GLOBAL.add(Settings.Global.WEBVIEW_DATA_REDUCTION_PROXY_KEY);
+            
+            
         }
 
         /** @hide */
@@ -7695,6 +7697,10 @@
          * @hide
          */
         public static final String LTE_SERVICE_FORCED = "lte_service_forced";
+        
+        // ADDED FOR COLLABOROID
+        public static final String COLLABOROID_ON = "collaboroid_on";
+        public static final String TASKEXECUTOR_ON = "taskexecutor_on";
 
         /**
          * Settings to backup. This is here so that it's in the same place as the settings
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/collaboroid/CollaboRoidManager.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/collaboroid/CollaboRoidManager.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/collaboroid/CollaboRoidManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/collaboroid/CollaboRoidManager.java	2017-01-29 02:51:19.441886000 +0900
@@ -0,0 +1,71 @@
+package android.service.collaboroid;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.service.devicemanagement.IDeviceManagementService;
+import android.service.remote.IRemoteService;
+
+public class CollaboRoidManager 
+{
+	public static final String EXTRA_COLLABOROID_STATE = "collaboroid_state";
+	
+	public static final String COLLABOROID_STATE_CHANGED_ACTION = "android.service.collaboroid.COLLABOROID_STATE_CHANGED";
+	
+	public static final int COLLABOROID_STATE_DISABLING = 0;
+	public static final int COLLABOROID_STATE_DISABLED = 1;
+	public static final int COLLABOROID_STATE_ENABLING = 2;
+	public static final int COLLABOROID_STATE_ENABLED = 3;
+	public static final int COLLABOROID_STATE_UNKNOWN = 4;
+	
+	private final IDeviceManagementService mDeviceService;
+	private final IRemoteService mRemoteService;
+	private Context mContext;
+	
+	public CollaboRoidManager(Context context)
+	{
+		// TODO Auto-generated constructor stub
+		mContext = context;
+		mDeviceService = IDeviceManagementService.Stub.asInterface(ServiceManager.getService(Context.DEVICE_MANAGEMENT_SERVICE));
+		mRemoteService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+	}
+	
+	public void setCollaboRoidEnabled(boolean enabled)
+	{
+		try
+		{
+			if(enabled)
+			{
+				setCollaboRoidState(COLLABOROID_STATE_ENABLING);
+				mDeviceService.getDeviceList(0);
+				mRemoteService.startServer();
+				Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.COLLABOROID_ON, 1);
+				setCollaboRoidState(COLLABOROID_STATE_ENABLED);
+			}
+			else
+			{
+				// disconnects to all devices
+				setCollaboRoidState(COLLABOROID_STATE_DISABLING);
+				mRemoteService.stopServer();
+				Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.COLLABOROID_ON, 0);
+				setCollaboRoidState(COLLABOROID_STATE_DISABLED);
+			}
+		}
+		catch(RemoteException re)
+		{
+			re.printStackTrace();
+		}
+	}
+	
+	private void setCollaboRoidState(int state)
+	{
+		final Intent intent = new Intent(CollaboRoidManager.COLLABOROID_STATE_CHANGED_ACTION);
+		intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+		intent.putExtra(CollaboRoidManager.EXTRA_COLLABOROID_STATE, state);
+		mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+		//sendStickyBroadcastAsUser(intent, UserHandle.ALL);
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/collaboroid/IGeneralMessageListener.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/collaboroid/IGeneralMessageListener.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/collaboroid/IGeneralMessageListener.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/collaboroid/IGeneralMessageListener.aidl	2016-11-01 17:36:40.394409000 +0900
@@ -0,0 +1,6 @@
+package android.service.collaboroid;
+
+oneway interface IGeneralMessageListener
+{
+	void onMessageReceived(String message);
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/Device.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/Device.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/Device.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/Device.aidl	2016-11-04 02:26:40.000000000 +0900
@@ -0,0 +1,3 @@
+package android.service.devicemanagement;
+
+parcelable Device;
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/Device.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/Device.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/Device.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/Device.java	2017-07-06 19:18:24.584237000 +0900
@@ -0,0 +1,136 @@
+package android.service.devicemanagement;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class Device implements Parcelable
+{
+	public static final int RESOURCE_TYPE_TOUCH = 0;
+	public static final int RESOURCE_TYPE_KEY = 1;
+	public static final int RESOURCE_TYPE_SENSOR = 2;
+	public static final int RESOURCE_TYPE_LOCATION = 3;
+	public static final int RESOURCE_TYPE_VIDEO = 4;
+	public static final int RESOURCE_TYPE_AUDIO = 5;
+	public static final int RESOURCE_TYPE_VIBRATOR = 6;
+	public static final int RESOURCE_TYPE_REMOTE_ACTIVITY = 7;
+
+	public static final int RESOURCE_TYPE_SIZE = 8;
+
+	public static final String[] ResourceNames = {"Touch", "Key", "Sensor", "Location", "Video", "Audio", "Vibrator", "R. Activity"};
+
+	public final int SYSTEM_SERVICE_LIST = 1;
+	public final int TASK_EXECUTOR_LIST = 2;
+
+	public String ipaddress;
+	public String idleCpu;
+	public String deviceName;
+	public int isSystemServiceOn = -1;
+	public int isTaskExecutorOn = -1;
+	public int[] askedResources;
+	public int[] allowedResources;
+
+	public String HaveDexFiles;
+
+	//samd
+	public List<String> dexTable;
+	public List<String> resourceTable;
+
+	public Device(String ipaddress, String idleCpu, String name, int isSystemServiceOn, int isTaskExecutorOn) {
+		updateDevice(ipaddress, idleCpu, name, isSystemServiceOn, isTaskExecutorOn);
+//		this.ipaddress = ipaddress;
+//		this.idleCpu = idleCpu;
+//		this.isSystemServiceOn = isSystemServiceOn;
+//		this.isTaskExecutorOn = isTaskExecutorOn;
+	}
+
+	public Device() {
+		// TODO Auto-generated constructor stub
+		initDevice();
+	}
+
+	public void initDevice(){
+		this.ipaddress = "";
+		this.idleCpu = "";
+		this.deviceName = "";
+		this.isSystemServiceOn = -1;
+		this.isTaskExecutorOn = -1;
+		this.askedResources = new int[RESOURCE_TYPE_SIZE];
+		this.allowedResources = new int[RESOURCE_TYPE_SIZE];
+		this.HaveDexFiles = "";
+		dexTable = new ArrayList<String>();
+		resourceTable = new ArrayList<String>();
+	}
+
+	public String toString() {
+		String result = "ipAddress: " + this.ipaddress
+				+ "idleCPU: " + this.idleCpu
+				+ "SystemServerOn? " + Integer.toString(isSystemServiceOn)
+				+ "TaskExecutorOn? " + Integer.toString(isTaskExecutorOn);
+		return result;
+	}
+
+	public void updateDevice(String ipaddress, String idleCpu, String name, int isSystemServiceOn, int isTaskExecutorOn){
+		initDevice();
+		this.ipaddress = ipaddress;
+		this.idleCpu = idleCpu;
+		this.deviceName = name;
+		this.isSystemServiceOn = isSystemServiceOn;
+		this.isTaskExecutorOn = isTaskExecutorOn;
+	}
+
+	public void setAllowedResources(int[] resources)
+	{
+		allowedResources = resources;
+	}
+
+	public void setAskedResources(int[] resources)
+	{
+		askedResources = resources;
+	}
+
+	@Override
+	public int describeContents() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public void writeToParcel(Parcel dest, int flags) {
+		// TODO Auto-generated method stub
+		dest.writeString(ipaddress);
+		dest.writeString(idleCpu);
+		dest.writeString(deviceName);
+		dest.writeInt(isSystemServiceOn);
+		dest.writeInt(isTaskExecutorOn);
+		dest.writeIntArray(askedResources);
+		dest.writeIntArray(allowedResources);
+		dest.writeString(HaveDexFiles);
+		dest.writeStringList(dexTable);
+		dest.writeStringList(resourceTable);
+	}
+	public static final Creator<Device> CREATOR = new Creator<Device>() {
+		public Device createFromParcel(Parcel in) {
+			Device device = new Device();
+			device.ipaddress = in.readString();
+			device.idleCpu = in.readString();
+			device.deviceName = in.readString();
+			device.isSystemServiceOn = in.readInt();
+			device.isTaskExecutorOn = in.readInt();
+			device.askedResources = in.createIntArray();
+			device.allowedResources = in.createIntArray();
+			device.HaveDexFiles = in.readString();
+			in.readStringList(device.dexTable);
+			in.readStringList(device.resourceTable);
+
+			return device;
+		}
+
+		public Device[] newArray(int size) {
+			return new Device[size];
+		}
+	};
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/DeviceList.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/DeviceList.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/DeviceList.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/DeviceList.java	2017-07-06 18:23:00.550870000 +0900
@@ -0,0 +1,18 @@
+package android.service.devicemanagement;
+
+import java.util.HashMap;
+
+public class DeviceList 
+{
+	private static HashMap<String, Device> devices = new HashMap<String, Device>();
+
+    public static HashMap<String, Device> getDevices() {
+		return devices;
+	}
+
+	public static void setDevices(HashMap<String, Device> devices) {
+		DeviceList.devices = devices;
+	}
+	
+
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/DeviceManager.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/DeviceManager.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/DeviceManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/DeviceManager.java	2017-07-06 20:05:56.335399000 +0900
@@ -0,0 +1,253 @@
+package android.service.devicemanagement;
+
+import java.util.List;
+
+import android.content.Context;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.service.remote.IRemoteService;
+import android.util.Log;
+
+public class DeviceManager {
+	private final IDeviceManagementService mService;
+
+	public DeviceManager(IDeviceManagementService service) {
+		mService = service;
+	}
+
+	public DeviceManager(Context ctx) {
+		mService = IDeviceManagementService.Stub.asInterface(ServiceManager.getService(Context.DEVICE_MANAGEMENT_SERVICE));
+	}
+
+	public DeviceManager() {
+		mService = IDeviceManagementService.Stub.asInterface(ServiceManager.getService(Context.DEVICE_MANAGEMENT_SERVICE));
+	}
+
+	public String recommendDevice(List<Device> peerlist) {
+		try {
+			return mService.recommendDevice(peerlist);
+		} catch (RemoteException e) {
+			e.printStackTrace();
+		}
+		return null;
+
+	}
+
+	public String[] getSystemServiceOnServerList(){
+		try{
+			return mService.getSystemServiceOnServerList();
+		} catch(RemoteException e){
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public String[] getTaskExecutorOnServerList(){
+		try{
+			return mService.getTaskExecutorOnServerList();
+		} catch(RemoteException e){
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public List<Device> getDeviceList(int kind) {
+		try {
+			return mService.getDeviceList(kind);
+		} catch (RemoteException e) {
+			e.printStackTrace();
+		}
+		return null;
+
+	}
+
+	public void constructCluster(List<Device> devicelist)
+	{
+		try
+		{
+			Log.d("DeviceManager", "in construct!");
+			mService.constructCluster(devicelist);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+	}
+
+	public int getNumofConfiguredDevices()
+	{
+		try
+		{
+			return mService.getNumofConfiguredDevices();
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+		return 0;
+	}
+
+	public Device getDevice(String name)
+	{
+		try
+		{
+			return mService.getDevice(name);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public void askResources(List<Device> devicelist) {
+		try
+		{
+			mService.askResources(devicelist);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+	}
+
+	public void allowResources(String deviceName, int[] allowedResources)
+	{
+		try
+		{
+			mService.allowResources(deviceName, allowedResources);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+	}
+
+	//collaboroid
+	public String getHaveDexFiles(int deviceNum)
+	{
+		String temp = null;
+		try
+		{
+			Log.d("SBJSBJ", "SBJSBJ getHaveDexFiles [DeviceManager]");
+			temp = mService.getHaveDexFiles(deviceNum);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+		if(temp==null){
+			temp="sbjsbj";
+		}
+		return temp;
+	}
+
+	public void addHaveDexFiles(int deviceNum, String dexFiles)
+	{
+		try
+		{
+			mService.addHaveDexFiles(deviceNum, dexFiles);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+	}
+
+	//samd
+	//initialize
+	/*
+	public void initialARTable(int deviceNum){
+		try
+		{
+			mService.initialARTable(deviceNum);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+	}
+
+	//add resource dex
+	public void addDexFile(int deviceNum, List<String> dexString){
+		try
+		{
+			mService.addDexFile(deviceNum, dexString);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+	}
+	public void addResourceFile(int deviceNum, List<String> resourceString){
+		try
+		{
+			mService.addResourceFile(deviceNum, resourceString);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+	}
+
+	//get resource dex
+	public List<String> getDexFile(int deviceNum){
+		List<String> temp = null;
+		try
+		{
+			Log.d("SBJSBJ", "SBJSBJ getHaveDexFiles [DeviceManager]");
+			temp = mService.getDexFile(deviceNum);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+
+		return temp;
+	}
+
+	public List<String> getResourceFile(int deviceNum){
+		List<String> temp = null;
+		try
+		{
+			Log.d("SBJSBJ", "SBJSBJ getHaveDexFiles [DeviceManager]");
+			temp = mService.getResourceFile(deviceNum);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+
+		return temp;
+	}
+	public List<String> checkDexFile(int deviceNum, List<String> dexList){
+		List<String> temp = null;
+		try
+		{
+			Log.d("SBJSBJ", "SBJSBJ getHaveDexFiles [DeviceManager]");
+			temp = mService.checkDexFile(deviceNum);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+
+		return temp;
+	}
+
+	public List<String> checkResourceFile(int deviceNum, List<String> resourceList){
+		List<String> temp = null;
+		try
+		{
+			Log.d("SBJSBJ", "SBJSBJ getHaveDexFiles [DeviceManager]");
+			temp = mService.checkResourceFile(deviceNum);
+		}
+		catch(RemoteException e)
+		{
+			e.printStackTrace();
+		}
+		return temp;
+	}
+	*/
+
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/IDeviceManagementService.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/IDeviceManagementService.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/devicemanagement/IDeviceManagementService.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/devicemanagement/IDeviceManagementService.aidl	2017-07-06 20:13:16.191688000 +0900
@@ -0,0 +1,34 @@
+package android.service.devicemanagement;
+
+import android.service.devicemanagement.Device;
+
+interface IDeviceManagementService {
+	void initDevices();
+	String recommendDevice(in List<Device> devicelist); 
+	List<Device> getDeviceList(int kind);
+	String[] getSystemServiceOnServerList();
+	String[] getTaskExecutorOnServerList();
+	
+	int getNumofConfiguredDevices();
+    Device getDevice(String name);
+    void constructCluster(in List<Device> devicelist);
+    
+    void askResources(in List<Device> devicelist);
+    void allowResources(String deviceName, in int[] allowedResources);
+    void showRequestDialog(String deviceName, String deviceIP, in int[] askedResources);
+	
+	boolean isAllowedForResource(String device, int resource);
+
+	//collaboroid
+	String getHaveDexFiles(int deviceNum);
+	void addHaveDexFiles(int deviceNum, String dexFiles);
+	/*
+	void initialARTable(int deviceNum);
+	void addDexFile(int deviceNum,in List<String> dexString);
+	void addResourceFile(int deviceNum,in List<String> resourceString);
+	List<String> getDexFile(int deviceNum);
+	List<String> getResourceFile(int deviceNum);
+	List<String> checkDexFile(int deviceNum, in List<String> dexList);
+    List<String> checkResourceFile(int deviceNum,in List<String> resourceList);
+    */
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/distribute/Distributor.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/distribute/Distributor.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/distribute/Distributor.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/distribute/Distributor.java	2017-01-29 02:51:19.461886000 +0900
@@ -0,0 +1,69 @@
+package android.service.distribute;
+
+import android.content.Context;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+
+public class Distributor 
+{
+	private final IDistributedComputingService mService;
+	
+	public Distributor(IDistributedComputingService service)
+	{
+		mService = service;
+	}
+	
+	public Distributor()
+	{
+		mService = IDistributedComputingService.Stub.asInterface(ServiceManager.getService("distributedcomputing"));
+	}
+	
+	public Distributor(Context context)
+	{
+		// TODO Auto-generated constructor stub
+		mService = IDistributedComputingService.Stub.asInterface(ServiceManager.getService("distributedcomputing"));
+	}
+	
+	public void startJobManager(String ip)
+	{
+		try {
+			mService.startJobManager(ip);
+		} catch (RemoteException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public void startTaskExecutor()
+	{
+		try {
+			mService.startTaskExecutor();
+		} catch (RemoteException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void testOperation()
+	{
+		try {
+			mService.testOperation();
+		} catch (RemoteException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public int sum(int start, int end)
+	{
+		try 
+		{
+			return mService.sum(start, end);
+		} 
+		catch (RemoteException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return 0;
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/distribute/IDistributedComputingService.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/distribute/IDistributedComputingService.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/distribute/IDistributedComputingService.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/distribute/IDistributedComputingService.aidl	2016-11-01 17:36:40.394409000 +0900
@@ -0,0 +1,14 @@
+package android.service.distribute;
+
+interface IDistributedComputingService
+{
+	void startJobManager(String ip);
+	void stopJobManager();
+	
+	void startTaskExecutor();
+	void stopTaskExecutor();
+	
+	int sum(int start, int end);
+	
+	void testOperation();
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/AppendingObjectOutputStream.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/AppendingObjectOutputStream.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/AppendingObjectOutputStream.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/AppendingObjectOutputStream.java	2017-01-29 02:51:19.461886000 +0900
@@ -0,0 +1,22 @@
+package android.service.remote;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+public class AppendingObjectOutputStream extends ObjectOutputStream {
+
+	public AppendingObjectOutputStream(OutputStream output) throws IOException {
+		super(output);
+		// TODO Auto-generated constructor stub
+	}
+
+	@Override
+	protected void writeStreamHeader() throws IOException {
+		// do not write a header, but reset:
+		// this line added after another question
+		// showed a problem with the original
+		reset();
+	}
+
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/DexCode.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/DexCode.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/DexCode.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/DexCode.aidl	2017-07-28 05:14:16.693859000 +0900
@@ -0,0 +1,3 @@
+package android.service.remote;
+
+parcelable DexCode;
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/DexCode.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/DexCode.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/DexCode.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/DexCode.java	2017-07-28 05:14:16.697859000 +0900
@@ -0,0 +1,166 @@
+package android.service.remote;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class DexCode implements Serializable, Parcelable
+{
+	private static final long serialVersionUID = 1L;
+	private String type;
+	private String method;
+	private ArrayList<Object> parameters;
+
+	public DexCode()
+    {
+		parameters = new ArrayList<Object>();
+    }
+
+	public DexCode(String type, String method, ArrayList<Object> parameters)
+    {
+		this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+
+	public DexCode(Parcel in)
+	{
+		this.type = in.readString();
+		this.method = in.readString();
+		//this.parameters = in.readArrayList(null);
+		//this.parameters = in.readArrayList(Object.class.getClassLoader());
+		this.parameters = (ArrayList<Object>)in.readSerializable();
+	}
+
+	public static final Creator<DexCode> CREATOR = new Creator<DexCode>()
+	{
+		@Override
+		public DexCode[] newArray(int size)
+		{
+			// TODO Auto-generated method stub
+			return new DexCode[size];
+		}
+
+		@Override
+		public DexCode createFromParcel(Parcel in)
+		{
+			// TODO Auto-generated method stub
+			return new DexCode(in);
+		}
+	};
+
+	@Override
+	public int describeContents()
+	{
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public void writeToParcel(Parcel dest, int flags)
+	{
+		dest.writeString(this.type);
+		dest.writeString(this.method);
+		// dest.writeList(parameters);
+		dest.writeSerializable(this.parameters);
+	}
+
+	public void set(String type, String method, ArrayList<Object> parameters)
+	{
+    	this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+	
+	public String getType()
+	{
+		return type;
+	}
+	
+	public String getMethod()
+	{
+		return method;
+	}
+	
+	public ArrayList<Object> getPara()
+	{
+		return parameters;
+	}
+
+	public String toString()
+	{
+		return "type: " + type + "\nmethod: " + method + "\npara: " + parameters.toString();
+	}
+	
+	public static class RemoteKeyEvent implements Serializable
+	{
+		private static final long serialVersionUID = 1L;
+
+		private int action;
+		private int code;
+		private int source;
+		
+		public RemoteKeyEvent(int action, int code, int source)
+		{
+			this.action = action;
+			this.code = code;
+			this.source = source;
+		}
+		
+		public RemoteKeyEvent(Parcel in) 
+		{
+			this.action = in.readInt();
+			this.code = in.readInt();
+			this.source = in.readInt();
+		}
+		
+		/*public static final Parcelable.Creator<RemoteKeyEvent> CREATOR = new Parcelable.Creator<RemoteKeyEvent>()
+		{
+			@Override
+			public RemoteKeyEvent[] newArray(int size)
+			{
+				// TODO Auto-generated method stub
+				return new RemoteKeyEvent[size];
+			}
+
+			@Override
+			public RemoteKeyEvent createFromParcel(Parcel in)
+			{
+				// TODO Auto-generated method stub
+				return new RemoteKeyEvent(in);
+			}
+		};
+
+		@Override
+		public int describeContents() {
+			// TODO Auto-generated method stub
+			return 0;
+		}
+
+		@Override
+		public void writeToParcel(Parcel dest, int flags) {
+			// TODO Auto-generated method stub
+			dest.writeInt(this.action);
+			dest.writeInt(this.code);
+			dest.writeInt(this.source);
+		}*/
+		
+		public int getAction()
+		{
+			return action;
+		}
+		
+		public int getCode()
+		{
+			return code;
+		}
+		
+		public int getSource()
+		{
+			return source;
+		}
+	}
+	
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/IRemoteService.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/IRemoteService.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/IRemoteService.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/IRemoteService.aidl	2017-09-15 10:56:23.527884000 +0900
@@ -0,0 +1,80 @@
+package android.service.remote;
+
+import android.service.remote.RemoteRequest;
+
+import android.service.devicemanagement.Device;
+
+import android.service.collaboroid.IGeneralMessageListener;
+import android.view.MotionEvent;
+import android.view.KeyEvent;
+import android.location.Location;
+import android.os.Bundle;
+
+interface IRemoteService
+{
+	boolean startServer();
+	boolean stopServer();
+	
+	void setConfiguration();
+	void setEnabled(boolean isEnabled);
+	
+	boolean isServerOn();
+	
+//	void connectToServer();
+	boolean connectToServer(String ip);
+	void disconnectToServer();
+	void initConnections();
+	List<String> getClientIPs();
+	List<String> getServerIPs();
+	void sendAllMusic(int sampleSize, in byte[] to_send, long presentationTime);
+	void sendAllrequest(in RemoteRequest request);
+	
+	boolean sendResourceRequests(in List<Device> requestDeviceList);
+	boolean isAllowedForResource(String deviceName, String deviceIP, in int[] resources);
+	boolean respondAllowedResources(String deviceIP, in int[] resources);
+	
+	boolean sendRequest(in RemoteRequest request);
+//	void sendSensorRequest(in SensorEventQueue2 queue);
+
+	// for MotionEvent
+	void sendMotionEvent(in MotionEvent event);
+	
+	// for KeyEvent
+	void sendKeyEvent(in KeyEvent event);
+	
+	// for SensorEvent
+//	boolean setRemoteSensorOn(boolean flag, SensorEventListener listener);
+	void addSensorHandle(int type, int handle);
+	void removeSensorHandle(int type);
+	void sendSensorEvent(int type, int sensor, in float[] values, int accuracy, long timestamp);
+	
+	// for API
+	void playMusic();
+	
+	// for evaluations
+	void testVibrate();
+	void testMusic();
+	void testVideo();
+	void testTouch();
+	void testKey();
+	void testSensor();
+	void testLocation();
+	void requestMotionEvents();
+
+
+
+	//16.12.07
+	void refreshDevices();
+
+	void sendMusicData(int sampleSize, in byte[] to_send, long presentationTime);
+	
+	int getVideoPlayers();
+	void sendVideoSignal(int vport);
+	
+	void sendLocation(in Location location);
+
+//	Object sendRountTripRequest(in RemoteRequest request);
+
+	void registerListener(IGeneralMessageListener listener);
+	void unregisterListener(IGeneralMessageListener listener);
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteRequest2.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteRequest2.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteRequest2.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteRequest2.java	2017-01-29 02:51:19.453886000 +0900
@@ -0,0 +1,97 @@
+package android.service.remote;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class RemoteRequest2 implements Serializable, Parcelable
+{
+	private static final long serialVersionUID = 1L;
+	private String type;
+	private String method;
+	private ArrayList<Object> parameters;
+	
+	public RemoteRequest2()
+    {
+		parameters = new ArrayList<Object>();
+    }
+	
+	public RemoteRequest2(String type, String method, ArrayList<Object> parameters)
+    {
+		this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+	
+	public RemoteRequest2(Parcel in) 
+	{
+		this.type = in.readString();
+		this.method = in.readString();
+		//this.parameters = in.readArrayList(null);
+		//this.parameters = in.readArrayList(Object.class.getClassLoader());
+		this.parameters = (ArrayList<Object>)in.readSerializable();		
+	}
+	
+	public static final Parcelable.Creator<RemoteRequest> CREATOR = new Parcelable.Creator<RemoteRequest>()
+	{
+		@Override
+		public RemoteRequest[] newArray(int size)
+		{
+			// TODO Auto-generated method stub
+			return new RemoteRequest[size];
+		}
+
+		@Override
+		public RemoteRequest createFromParcel(Parcel in)
+		{
+			// TODO Auto-generated method stub
+			return new RemoteRequest(in);
+		}
+	};
+
+	@Override
+	public int describeContents()
+	{
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public void writeToParcel(Parcel dest, int flags)
+	{
+		dest.writeString(this.type);
+		dest.writeString(this.method);
+		// dest.writeList(parameters);
+		dest.writeSerializable(this.parameters);
+	}
+
+	public void set(String type, String method, ArrayList<Object> parameters)
+	{
+    	this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+	
+	public String getType()
+	{
+		return type;
+	}
+	
+	public String getMethod()
+	{
+		return method;
+	}
+	
+	public ArrayList<Object> getPara()
+	{
+		return parameters;
+	}
+
+	public String toString()
+	{
+		return "type: " + type + "\nmethod: " + method + "\npara: " + parameters.toString();
+	}
+	
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteRequest.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteRequest.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteRequest.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteRequest.aidl	2016-11-01 17:36:40.394409000 +0900
@@ -0,0 +1,3 @@
+package android.service.remote;
+
+parcelable RemoteRequest;
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteRequest.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteRequest.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteRequest.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteRequest.java	2017-01-29 02:51:19.457886000 +0900
@@ -0,0 +1,166 @@
+package android.service.remote;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class RemoteRequest implements Serializable, Parcelable
+{
+	private static final long serialVersionUID = 1L;
+	private String type;
+	private String method;
+	private ArrayList<Object> parameters;
+	
+	public RemoteRequest()
+    {
+		parameters = new ArrayList<Object>();
+    }
+	
+	public RemoteRequest(String type, String method, ArrayList<Object> parameters)
+    {
+		this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+	
+	public RemoteRequest(Parcel in) 
+	{
+		this.type = in.readString();
+		this.method = in.readString();
+		//this.parameters = in.readArrayList(null);
+		//this.parameters = in.readArrayList(Object.class.getClassLoader());
+		this.parameters = (ArrayList<Object>)in.readSerializable();		
+	}
+	
+	public static final Parcelable.Creator<RemoteRequest> CREATOR = new Parcelable.Creator<RemoteRequest>()
+	{
+		@Override
+		public RemoteRequest[] newArray(int size)
+		{
+			// TODO Auto-generated method stub
+			return new RemoteRequest[size];
+		}
+
+		@Override
+		public RemoteRequest createFromParcel(Parcel in)
+		{
+			// TODO Auto-generated method stub
+			return new RemoteRequest(in);
+		}
+	};
+
+	@Override
+	public int describeContents()
+	{
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public void writeToParcel(Parcel dest, int flags)
+	{
+		dest.writeString(this.type);
+		dest.writeString(this.method);
+		// dest.writeList(parameters);
+		dest.writeSerializable(this.parameters);
+	}
+
+	public void set(String type, String method, ArrayList<Object> parameters)
+	{
+    	this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+	
+	public String getType()
+	{
+		return type;
+	}
+	
+	public String getMethod()
+	{
+		return method;
+	}
+	
+	public ArrayList<Object> getPara()
+	{
+		return parameters;
+	}
+
+	public String toString()
+	{
+		return "type: " + type + "\nmethod: " + method + "\npara: " + parameters.toString();
+	}
+	
+	public static class RemoteKeyEvent implements Serializable
+	{
+		private static final long serialVersionUID = 1L;
+
+		private int action;
+		private int code;
+		private int source;
+		
+		public RemoteKeyEvent(int action, int code, int source)
+		{
+			this.action = action;
+			this.code = code;
+			this.source = source;
+		}
+		
+		public RemoteKeyEvent(Parcel in) 
+		{
+			this.action = in.readInt();
+			this.code = in.readInt();
+			this.source = in.readInt();
+		}
+		
+		/*public static final Parcelable.Creator<RemoteKeyEvent> CREATOR = new Parcelable.Creator<RemoteKeyEvent>()
+		{
+			@Override
+			public RemoteKeyEvent[] newArray(int size)
+			{
+				// TODO Auto-generated method stub
+				return new RemoteKeyEvent[size];
+			}
+
+			@Override
+			public RemoteKeyEvent createFromParcel(Parcel in)
+			{
+				// TODO Auto-generated method stub
+				return new RemoteKeyEvent(in);
+			}
+		};
+
+		@Override
+		public int describeContents() {
+			// TODO Auto-generated method stub
+			return 0;
+		}
+
+		@Override
+		public void writeToParcel(Parcel dest, int flags) {
+			// TODO Auto-generated method stub
+			dest.writeInt(this.action);
+			dest.writeInt(this.code);
+			dest.writeInt(this.source);
+		}*/
+		
+		public int getAction()
+		{
+			return action;
+		}
+		
+		public int getCode()
+		{
+			return code;
+		}
+		
+		public int getSource()
+		{
+			return source;
+		}
+	}
+	
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteServiceManager.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteServiceManager.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/RemoteServiceManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/RemoteServiceManager.java	2017-09-15 13:57:46.184301000 +0900
@@ -0,0 +1,285 @@
+package android.service.remote;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RemoteServiceManager
+{
+	private final IRemoteService mService;
+
+	public RemoteServiceManager(IRemoteService service)
+	{
+		mService = service;
+	}
+
+	public RemoteServiceManager()
+	{
+		mService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+	}
+
+	public RemoteServiceManager(Context context)
+	{
+		// TODO Auto-generated constructor stub
+		mService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+	}
+
+	public void startServer()
+	{
+		try
+		{
+			mService.startServer();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void stopServer()
+	{
+		try
+		{
+			mService.stopServer();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void setConfiguration()
+	{
+		try
+		{
+			mService.setConfiguration();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void setEnabled(boolean isEnabled)
+	{
+		try
+		{
+			mService.setEnabled(isEnabled);
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void connectToServer(String ip)
+	{
+		try
+		{
+			mService.connectToServer(ip);
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void disconnectToServer()
+	{
+		try
+		{
+			mService.disconnectToServer();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public boolean sendRequest(RemoteRequest request)
+	{
+		Log.d("RemoteRequestManager", "sendRequest!!!!");
+		try
+		{
+			return mService.sendRequest(request);
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+	public void sendMusicData(int sampleSize, byte[] to_send, long presentationTime){
+		try{
+			mService.sendMusicData(sampleSize, to_send, presentationTime);
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+
+	public void sendAllMusic(int sampleSize, byte[] to_send, long presentationTime){
+		try{
+			mService.sendMusicData(sampleSize, to_send, presentationTime);
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+
+	public void sendAllrequest(RemoteRequest request){
+		try{
+			mService.sendAllrequest(request);
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+
+
+	public void testVibrate()
+	{
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.testVibrate();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void testMusic()
+	{
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.testMusic();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void testVideo()
+	{
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.testVideo();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void testTouch()
+	{
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.testTouch();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void testKey()
+	{
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.testKey();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void testSensor()
+	{
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.testSensor();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void testLocation()
+	{
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.testLocation();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void requestMotionEvents(){
+		// TODO Auto-generated method stub
+		try
+		{
+			mService.requestMotionEvents();
+		}
+		catch (RemoteException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+
+	//16.12.07
+	public void refreshDevices(){
+		try{
+			mService.refreshDevices();
+		}catch (RemoteException e){
+			e.printStackTrace();
+		}
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/ResourceAapt.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/ResourceAapt.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/ResourceAapt.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/ResourceAapt.aidl	2017-07-28 05:12:52.445917000 +0900
@@ -0,0 +1,3 @@
+package android.service.remote;
+
+parcelable ResourceAapt;
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/ResourceAapt.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/ResourceAapt.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/ResourceAapt.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/ResourceAapt.java	2017-07-28 05:12:52.445917000 +0900
@@ -0,0 +1,166 @@
+package android.service.remote;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class ResourceAapt implements Serializable, Parcelable
+{
+	private static final long serialVersionUID = 1L;
+	private String type;
+	private String method;
+	private ArrayList<Object> parameters;
+
+	public ResourceAapt()
+    {
+		parameters = new ArrayList<Object>();
+    }
+
+	public ResourceAapt(String type, String method, ArrayList<Object> parameters)
+    {
+		this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+
+	public ResourceAapt(Parcel in)
+	{
+		this.type = in.readString();
+		this.method = in.readString();
+		//this.parameters = in.readArrayList(null);
+		//this.parameters = in.readArrayList(Object.class.getClassLoader());
+		this.parameters = (ArrayList<Object>)in.readSerializable();
+	}
+
+	public static final Creator<ResourceAapt> CREATOR = new Creator<ResourceAapt>()
+	{
+		@Override
+		public ResourceAapt[] newArray(int size)
+		{
+			// TODO Auto-generated method stub
+			return new ResourceAapt[size];
+		}
+
+		@Override
+		public ResourceAapt createFromParcel(Parcel in)
+		{
+			// TODO Auto-generated method stub
+			return new ResourceAapt(in);
+		}
+	};
+
+	@Override
+	public int describeContents()
+	{
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public void writeToParcel(Parcel dest, int flags)
+	{
+		dest.writeString(this.type);
+		dest.writeString(this.method);
+		// dest.writeList(parameters);
+		dest.writeSerializable(this.parameters);
+	}
+
+	public void set(String type, String method, ArrayList<Object> parameters)
+	{
+    	this.type = type;
+    	this.method = method;
+    	this.parameters = parameters;
+    }
+	
+	public String getType()
+	{
+		return type;
+	}
+	
+	public String getMethod()
+	{
+		return method;
+	}
+	
+	public ArrayList<Object> getPara()
+	{
+		return parameters;
+	}
+
+	public String toString()
+	{
+		return "type: " + type + "\nmethod: " + method + "\npara: " + parameters.toString();
+	}
+	
+	public static class RemoteKeyEvent implements Serializable
+	{
+		private static final long serialVersionUID = 1L;
+
+		private int action;
+		private int code;
+		private int source;
+		
+		public RemoteKeyEvent(int action, int code, int source)
+		{
+			this.action = action;
+			this.code = code;
+			this.source = source;
+		}
+		
+		public RemoteKeyEvent(Parcel in) 
+		{
+			this.action = in.readInt();
+			this.code = in.readInt();
+			this.source = in.readInt();
+		}
+		
+		/*public static final Parcelable.Creator<RemoteKeyEvent> CREATOR = new Parcelable.Creator<RemoteKeyEvent>()
+		{
+			@Override
+			public RemoteKeyEvent[] newArray(int size)
+			{
+				// TODO Auto-generated method stub
+				return new RemoteKeyEvent[size];
+			}
+
+			@Override
+			public RemoteKeyEvent createFromParcel(Parcel in)
+			{
+				// TODO Auto-generated method stub
+				return new RemoteKeyEvent(in);
+			}
+		};
+
+		@Override
+		public int describeContents() {
+			// TODO Auto-generated method stub
+			return 0;
+		}
+
+		@Override
+		public void writeToParcel(Parcel dest, int flags) {
+			// TODO Auto-generated method stub
+			dest.writeInt(this.action);
+			dest.writeInt(this.code);
+			dest.writeInt(this.source);
+		}*/
+		
+		public int getAction()
+		{
+			return action;
+		}
+		
+		public int getCode()
+		{
+			return code;
+		}
+		
+		public int getSource()
+		{
+			return source;
+		}
+	}
+	
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/SdPackage.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/SdPackage.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/SdPackage.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/SdPackage.java	2017-01-29 02:51:19.453886000 +0900
@@ -0,0 +1,79 @@
+package android.service.remote;
+
+import java.io.Serializable;
+
+
+
+public class SdPackage implements Serializable{
+
+	private int sampleSize = 0;
+	private byte[] sampleData;
+	private long presentationTime = 0;
+	private String mime = "audio/mpeg";
+	private int bitrate = 0;
+	private int channels = 0;
+	private int sampleRate = 0;
+	private long duration = 0;
+	private byte[] csd0;
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	public SdPackage(int sampleSize, byte[] sampleData, long presentationTime){
+		this.sampleSize = sampleSize;
+		this.sampleData = sampleData;
+		this.presentationTime = presentationTime; 
+	}
+	
+	public SdPackage(String _mime, int _bitrate, int _channels, int _sampleRate, long _duration, byte[] _csd0){
+		this.mime = _mime;
+		this.bitrate = _bitrate;
+		this.channels = _channels;
+		this.sampleRate = _sampleRate;
+		this.duration = _duration;
+		this.csd0 = _csd0;
+	}
+	
+	public String getMime(){
+		return this.mime;
+	}
+	
+	public int getBitrate(){
+		return this.bitrate;
+	}
+	
+	public int getChannels(){
+		return this.channels;
+	}
+	
+	public int getSampleRate(){
+		return this.sampleRate;
+	}
+
+	public int getSampleSize(){
+		return this.sampleSize;
+	}
+	
+	public long getDuration(){
+		return this.duration;
+	}
+	
+	public byte[] get_csd0(){
+		return this.csd0;
+	}
+	
+	public byte[] getSampleData(){
+		return this.sampleData;
+	}
+	
+	public long getPresentationTime(){
+		return this.presentationTime;
+	}
+	
+	@Override
+	public String toString(){
+		 return this.sampleSize+" is sampleSize,  " + this.sampleData + " is sampleData,  " + this.presentationTime + " is prest. time"; 
+	}
+	
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/vData.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/vData.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/remote/vData.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/remote/vData.java	2017-01-29 02:51:19.461886000 +0900
@@ -0,0 +1,112 @@
+package android.service.remote;
+
+import java.io.Serializable;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class vData implements Serializable{
+
+	private String mime = "video/avc";
+	private int width = 0;
+	private int height = 0;
+	private byte[] csd0 = null;
+	private byte[] csd1 = null;
+	
+	public int sampleSize = 0;
+	public byte[] sampleData;
+	public long presentationTime = 0;
+	
+	private static final long serialVersionUID = 1L;
+	
+	/**
+	 * 
+	 */
+	public vData(){
+		
+	}
+	
+	/**
+	 * 
+	 */
+	public vData(int _sampleSize, byte[] _sampleData, long _presentationTime){
+		sampleSize = _sampleSize;
+		sampleData = _sampleData;
+		presentationTime = _presentationTime;
+	}
+	
+	
+	/**
+	 * 
+	 */
+	public void setMediaFormat(String _mime, int _width, int _height, byte[] _csd0, byte[] _csd1){
+		mime = _mime;
+		width = _width;
+		height = _height;
+		csd0 = _csd0;
+		csd1 = _csd1;
+	}
+
+	/**
+	 * 
+	 */
+	public int getSampleSize(){
+		return sampleSize;
+	}
+
+	/**
+	 * 
+	 */
+	public byte[] getSampleData(){
+		return sampleData;
+	}
+
+	/**
+	 * 
+	 */
+	public long getPresentationTime(){
+		return presentationTime;
+	}	
+	/**
+	 * 
+	 */
+	public String getMime(){
+		return mime;
+	}
+	
+	/**
+	 * 
+	 */
+	public int getWidth(){
+		return width;
+	}
+	
+	/**
+	 * 
+	 */
+	public int getHeight(){
+		return height;
+	}
+
+	/**
+	 * 
+	 */
+	public byte[] get_csd0(){
+		return csd0;
+	}
+
+	/**
+	 * 
+	 */
+	public byte[] get_csd1(){
+		return csd1;
+	}
+
+	
+	@Override
+	public String toString() {
+		return sampleSize + " is sampleSize,  " + sampleData
+				+ " is sampleData,  " + presentationTime + " is prest. time";
+	}
+	
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/ISAMDListener.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/ISAMDListener.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/ISAMDListener.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/ISAMDListener.aidl	2017-09-21 13:53:14.619913000 +0900
@@ -0,0 +1,7 @@
+package android.service.samd;
+
+import android.service.samd.SAMDMessage;
+
+oneway interface ISAMDListener {
+    void onSAMDMsg(in SAMDMessage message);
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/ISAMDService.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/ISAMDService.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/ISAMDService.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/ISAMDService.aidl	2017-09-22 00:35:13.873247000 +0900
@@ -0,0 +1,44 @@
+package android.service.samd;
+
+import android.service.remote.RemoteRequest;
+import android.service.samd.ISAMDListener;
+
+import android.os.Bundle;
+
+interface ISAMDService
+{
+	//collaboroid
+    //17.03.02
+    boolean initialARTable(String appName);
+    boolean initialARTableD(int deviceNum, String appName);
+
+    void preSendDex(String currentActivity, String packageName);
+
+    void sendDexActivityD(int deviceNum, String DexFile);
+    void sendDexActivity(String multiDexFile);
+
+	void sendResourcesToLocal(in List<String> resourceFiles);
+	void sendResourcesToRemote(in List<String> resourceFiles, String toSendActivityName);
+	void sendResourcesToRemoteD(int deviceNum, in List<String> resourceFiles, String toSendActivityName);
+
+	void launchActivity(String toSendActivityName);
+	void launchActivityD(int deviceNum, String toSendActivityName);
+	void launchActivityWithRes(String toSendActivityName, in List<String> resourceFiles);
+	void launchActivityWithResD(int deviceNum, String toSendActivityName, in List<String> resourceFiles);
+
+	void sendMessageToRemoteD(int deviceNum, String msg);
+    void sendMessageToRemote(String msg);
+    void sendMessageToLocal(String msg);
+
+    int getRemoteDeviceCount();
+    int getRemoteDeviceNumber();
+    String getCurrentAppName();
+    //samd listener
+    oneway void requestSAMDListener(in ISAMDListener listener);
+    //sendAPK Test
+    void sendAPKFile(String dir);
+    //reviseApp
+    void ConvertDex(String appName);
+    //popup
+    void popUpActivity(String activityName);
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDListener.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDListener.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDListener.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDListener.java	2017-09-21 13:53:14.619913000 +0900
@@ -0,0 +1,8 @@
+package android.service.samd;
+
+/**
+ * Created by sbj on 16. 12. 15.
+ */
+public interface SAMDListener{
+    void onSAMDMsg(SAMDMessage message);
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDManager.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDManager.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDManager.java	2017-09-22 00:33:53.037667000 +0900
@@ -0,0 +1,284 @@
+package android.service.samd;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.service.remote.RemoteServiceManager;
+import android.util.Log;
+import android.service.samd.ISAMDListener;
+import android.service.samd.ISAMDService;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by sbj on 16. 12. 15.
+ */
+public class SAMDManager {
+
+    public SAMDListener listener;
+
+    private final ISAMDService mService;
+    private Context mContext;
+
+    public Handler handler;
+
+    public SAMDManager(ISAMDService service)
+    {
+        mService = service;
+    }
+
+    public SAMDManager()
+    {
+        mService = ISAMDService.Stub.asInterface(ServiceManager.getService(Context.SAMD_SERVICE));
+    }
+
+    public SAMDManager(Context context)
+    {
+        // TODO Auto-generated constructor stub
+        mContext = context;
+        handler = new Handler(mContext.getMainLooper());
+        mService = ISAMDService.Stub.asInterface(ServiceManager.getService(Context.SAMD_SERVICE));
+        //this.listener = listener;
+    }
+
+    public boolean registerSAMDListener(SAMDListener listener){
+        boolean result = false;
+        this.listener = listener;
+        requestSAMDListener(mListener);
+
+        return result;
+    }
+    //ISAMDListener
+    public void requestSAMDListener(ISAMDListener listener){
+        try{
+            mService.requestSAMDListener(listener);
+        }catch (RemoteException e){
+            e.printStackTrace();
+        }
+    }
+    private final ISAMDListener mListener = new ISAMDListener.Stub(){
+        @Override
+        public void onSAMDMsg(SAMDMessage message){
+            //Toast.makeText(getApplicationContext(), "msg : " + msg, Toast.LENGTH_SHORT).show();
+            Log.d("SAMDManager","SAMDManager arrive msg : " + message.getMessage());
+            listener.onSAMDMsg(message);
+        }
+    };
+    //collaboroid
+    public int getRemoteDeviceCount(){
+        try
+        {
+            return mService.getRemoteDeviceCount();
+        }
+        catch (RemoteException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return 0;
+    }
+    //collaboroid
+    public int getRemoteDeviceNumber(){
+        try
+        {
+            return mService.getRemoteDeviceNumber();
+        }
+        catch (RemoteException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return 0;
+    }
+    public String getCurrentAppName()
+    {
+        try
+        {
+            return mService.getCurrentAppName();
+        }
+        catch (RemoteException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return "";
+    }
+    public boolean initialARTableD(int deviceNum, String appName){
+        boolean result = false;
+        try{
+            result = mService.initialARTableD(deviceNum, appName);
+        }catch(RemoteException e){
+            e.printStackTrace();
+        }
+        return result;
+    }
+    public boolean initialARTable(String appName){
+        boolean result = false;
+        try{
+            result = mService.initialARTable(appName);
+        }catch(RemoteException e){
+            e.printStackTrace();
+        }
+        return result;
+    }
+    public void launchActivity(String toSendActivityName){
+        try {
+            mService.launchActivity(toSendActivityName);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void launchActivity(int deviceNum, String toSendActivityName){
+        try {
+            mService.launchActivityD(deviceNum, toSendActivityName);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void launchActivity(String toSendActivityName, Bundle config){
+        int resourseNum = config.getInt("resourceNum");
+        List<String> extraResourcesFile = new ArrayList<>();
+        for(int i=0; i<resourseNum; i++){
+            String resourceName = config.getString("resource"+(i+1));
+            extraResourcesFile.add(i, resourceName);
+        }
+        try {
+            mService.launchActivityWithRes(toSendActivityName, extraResourcesFile);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void launchActivity(int deviceNum, String toSendActivityName, Bundle config){
+        int resourseNum = config.getInt("resourceNum");
+        List<String> extraResourcesFile = new ArrayList<>();
+        for(int i=0; i<resourseNum; i++){
+            String resourceName = config.getString("resource"+(i+1));
+            extraResourcesFile.add(i, resourceName);
+        }
+        try {
+            mService.launchActivityWithResD(deviceNum, toSendActivityName, extraResourcesFile);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void sendActivityDynamic(String toSendActivityName){
+        try {
+            mService.sendDexActivity(toSendActivityName);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void sendActivityDynamic(int deviceNum, String toSendActivityName){
+        try {
+            mService.sendDexActivityD(deviceNum, toSendActivityName);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void sendResourcesToLocal(Bundle resourceFiles){
+        //send only resource
+        int resourseNum = resourceFiles.getInt("resourceNum");
+        List<String> extraResourcesFile = new ArrayList<>();
+        for(int i=0; i<resourseNum; i++){
+            String resourceName = resourceFiles.getString("resource"+(i+1));
+            extraResourcesFile.add(i, resourceName);
+        }
+        try {
+            mService.sendResourcesToLocal(extraResourcesFile);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void sendResourcesToRemote(Bundle resourceFiles, String toSendActivityName){
+        //CUURENT_APP, CURRENT_PACKAGE, CURRENT_ACTIVITY
+        //send resource and aapt tool
+        int resourseNum = resourceFiles.getInt("resourceNum");
+        List<String> extraResourcesFile = new ArrayList<>();
+        for(int i=0; i<resourseNum; i++){
+            String resourceName = resourceFiles.getString("resource"+(i+1));
+            extraResourcesFile.add(i, resourceName);
+        }
+        try {
+            mService.sendResourcesToRemote(extraResourcesFile, toSendActivityName);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void sendResourcesToRemote(int deviceNum, Bundle resourceFiles,String toSendActivityName){
+        //CUURENT_APP, CURRENT_PACKAGE, CURRENT_ACTIVITY
+        //send resource and aapt tool
+        int resourseNum = resourceFiles.getInt("resourceNum");
+        List<String> extraResourcesFile = new ArrayList<>();
+        for(int i=0; i<resourseNum; i++){
+            String resourceName = resourceFiles.getString("resource"+(i+1));
+            extraResourcesFile.add(i, resourceName);
+        }
+        try {
+            mService.sendResourcesToRemoteD(deviceNum, extraResourcesFile, toSendActivityName);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void sendMessageToRemote(int deviceNum, String msg){
+        try {
+            mService.sendMessageToRemoteD(deviceNum, msg);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void sendMessageToRemote(String msg){
+        try {
+            mService.sendMessageToRemote(msg);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public void sendMessageToLocal(String msg){
+        try {
+            mService.sendMessageToLocal(msg);
+        }catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void preSendDex(String currentActivity, String packageName){
+        try{
+            mService.preSendDex(currentActivity, packageName);
+        }catch(RemoteException e){
+            e.printStackTrace();
+        }
+    }
+
+    public void popUpActivity(String activityName){
+        try{
+            mService.popUpActivity(activityName);
+        }catch(RemoteException e){
+            e.printStackTrace();
+        }
+    }
+
+
+    /* revise App */
+    public void ConvertDex(String appName){
+        try{
+            mService.ConvertDex(appName);
+        }catch(RemoteException e){
+            e.printStackTrace();
+        }
+    }
+
+    /* test App */
+    public void sendAPKFile(String dir){
+        try{
+            mService.sendAPKFile(dir);
+        }catch(RemoteException e){
+            e.printStackTrace();
+        }
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDMessage.aidl SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDMessage.aidl
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDMessage.aidl	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDMessage.aidl	2017-09-15 11:32:07.302027000 +0900
@@ -0,0 +1,3 @@
+package android.service.samd;
+
+parcelable SAMDMessage;
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDMessage.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDMessage.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/service/samd/SAMDMessage.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/service/samd/SAMDMessage.java	2017-09-18 11:07:29.491551000 +0900
@@ -0,0 +1,117 @@
+package android.service.samd;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.io.Serializable;
+
+/**
+ * Created by sbj on 17. 6. 26.
+ */
+public class SAMDMessage implements Serializable, Parcelable {
+    int fromDN;
+    int toDN;
+    String fromDip;
+    String toDip;
+    String message;
+
+
+    long stime;
+    long etime;
+
+    public SAMDMessage(){
+
+    }
+    public SAMDMessage(int _fromDN, int _toDN, String _message){
+        this.fromDN = _fromDN;
+        this.toDN = _toDN;
+        this.message = _message;
+        this.stime = 0;
+        this.etime = 0;
+    }
+    public SAMDMessage(int _fromDN, int _toDN, String _fromDip, String _toDip, String _message){
+        this.fromDN = _fromDN;
+        this.toDN = _toDN;
+        this.fromDip = _fromDip;
+        this.toDip = _toDip;
+        this.message = _message;
+        this.stime = 0;
+        this.etime = 0;
+    }
+
+    public int getFromDN(){
+        return this.fromDN;
+    }
+    public int getToDN(){
+        return this.toDN;
+    }
+    public String getFromDip(){
+        return this.fromDip;
+    }
+    public String getToDip(){
+        return this.toDip;
+    }
+    public String getMessage(){
+        return this.message;
+    }
+    public long getStime(){
+        return this.stime;
+    }
+    public long getEtime(){
+        return this.etime;
+    }
+    public void setStime(long s){
+        this.stime = s;
+    }
+
+    public void setEtime(long e){
+        this.etime = e;
+    }
+
+    public SAMDMessage(Parcel in)
+    {
+        this.fromDN = in.readInt();
+        this.toDN = in.readInt();
+        this.fromDip = in.readString();
+        this.toDip = in.readString();
+        this.message = in.readString();
+        this.stime = in.readLong();
+        this.etime = in.readLong();
+    }
+
+    public static final Parcelable.Creator<SAMDMessage> CREATOR = new Parcelable.Creator<SAMDMessage>()
+    {
+        @Override
+        public SAMDMessage[] newArray(int size)
+        {
+            // TODO Auto-generated method stub
+            return new SAMDMessage[size];
+        }
+
+        @Override
+        public SAMDMessage createFromParcel(Parcel in)
+        {
+            // TODO Auto-generated method stub
+            return new SAMDMessage(in);
+        }
+    };
+
+    @Override
+    public int describeContents()
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags)
+    {
+        dest.writeInt(this.fromDN);
+        dest.writeInt(this.toDN);
+        dest.writeString(this.fromDip);
+        dest.writeString(this.toDip);
+        dest.writeString(this.message);
+        dest.writeLong(this.stime);
+        dest.writeLong(this.etime);
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/view/LayoutInflater.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/view/LayoutInflater.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/view/LayoutInflater.java	2017-09-27 02:07:49.043736109 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/view/LayoutInflater.java	2017-02-15 17:11:09.797877000 +0900
@@ -70,7 +70,8 @@
 public abstract class LayoutInflater {
 
     private static final String TAG = LayoutInflater.class.getSimpleName();
-    private static final boolean DEBUG = false;
+    //private static final boolean DEBUG = false;
+    private static final boolean DEBUG = true;
 
     /**
      * This field should be made private, so it is hidden from the SDK.
@@ -108,6 +109,8 @@
     private static final int[] ATTRS_THEME = new int[] {
             com.android.internal.R.attr.theme };
 
+    private boolean isDummy = false;
+    
     /**
      * Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed
      * to be inflated.
@@ -373,6 +376,11 @@
     public View inflate(@LayoutRes int resource, @Nullable ViewGroup root) {
         return inflate(resource, root, root != null);
     }
+    
+    // ADDED FOR ABCMANAGER
+    public View inflate2(String key, @Nullable ViewGroup root) {
+        return inflate2(key, root, root != null);
+    }
 
     /**
      * Inflate a new view hierarchy from the specified xml node. Throws
@@ -420,6 +428,24 @@
 
         final XmlResourceParser parser = res.getLayout(resource);
         try {
+        	isDummy = false;
+            return inflate(parser, root, attachToRoot);
+        } finally {
+            parser.close();
+        }
+    }
+    
+    // ADDED FOR ABCMANAGER
+    public View inflate2(String key, @Nullable ViewGroup root, boolean attachToRoot) {
+        final Resources res = getContext().getResources();
+        /*if (DEBUG) {
+            Log.d(TAG, "INFLATING from resource: \"" + res.getResourceName(resource) + "\" ("
+                    + Integer.toHexString(resource) + ")");
+        }*/
+
+        final XmlResourceParser parser = res.getLayout(key);
+        try {
+        	isDummy = true;
             return inflate(parser, root, attachToRoot);
         } finally {
             parser.close();
@@ -832,10 +858,24 @@
             } else if (TAG_MERGE.equals(name)) {
                 throw new InflateException("<merge /> must be the root element");
             } else {
-                final View view = createViewFromTag(parent, name, context, attrs);
+            	final View view = createViewFromTag(parent, name, context, attrs);
                 final ViewGroup viewGroup = (ViewGroup) parent;
                 final ViewGroup.LayoutParams params = viewGroup.generateLayoutParams(attrs);
                 rInflateChildren(parser, view, attrs, true);
+                
+                if(isDummy)
+                {
+                    //collaboroid
+	                Log.d(TAG, "name: " + name + 
+	                		"\nattrs: " + attrs.toString() +
+	                		"\nid: " + view.getId() +
+	                		"\nhexid: " + Integer.toHexString(view.getId()) +
+	                		"\ntag: " + view.getTag() +
+	                		"\ncontext: " + context.toString() +
+	                		"\nentryName: " + view.getEntryName());
+	                context.getResources().getABC().addResource(view.getId());
+                }
+                
                 viewGroup.addView(view, params);
             }
         }
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/view/View.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/view/View.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/view/View.java	2017-09-27 02:07:49.051736109 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/view/View.java	2017-09-18 16:26:41.681836000 +0900
@@ -33,6 +33,7 @@
 import android.content.Context;
 import android.content.ContextWrapper;
 import android.content.Intent;
+import android.content.res.AssetManager;
 import android.content.res.ColorStateList;
 import android.content.res.Configuration;
 import android.content.res.Resources;
@@ -108,6 +109,7 @@
 import com.google.android.collect.Lists;
 import com.google.android.collect.Maps;
 
+import java.io.InputStream;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.ref.WeakReference;
@@ -3429,6 +3431,9 @@
          */
         public OnClickListener mOnClickListener;
 
+
+
+
         /**
          * Listener used to dispatch long click events.
          * This field should be made private, so it is hidden from the SDK.
@@ -17212,6 +17217,20 @@
         mBackgroundResource = resid;
     }
 
+    //samd
+//    public void setImageSAMD(String resid) {
+//        try{
+//            Log.d("sbjsbj","setImageSAMD : " +resid);
+//            AssetManager am = mContext.getAssets();
+//            InputStream ims = am.open(resid);
+//            Drawable d = Drawable.createFromStream(ims, null);
+//            setBackground(d);
+//        }catch(Exception e){
+//            e.printStackTrace();
+//        }
+//    }
+
+
     /**
      * Set the background to a given Drawable, or remove the background. If the
      * background has padding, this View's padding is set to the background's
@@ -18475,6 +18494,11 @@
         return mID;
     }
 
+    public String getEntryName()
+    {
+    	return mResources.getResourceEntryName(mID);
+    }
+    
     /**
      * Returns this view's tag.
      *
@@ -21341,6 +21365,12 @@
         void onClick(View v);
     }
 
+    //collaboroid
+    public interface SAMDListener{
+
+        void onReceiveMessage();
+    }
+
     /**
      * Interface definition for a callback to be invoked when a view is context clicked.
      */
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/view/Window.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/view/Window.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/view/Window.java	2017-09-27 02:07:49.055736109 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/view/Window.java	2017-01-29 02:51:17.889869000 +0900
@@ -1043,7 +1043,10 @@
      * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
      */
     public abstract void setContentView(@LayoutRes int layoutResID);
-
+    
+    // ADDED FOR ABCMANAGER
+    public abstract void setContentView2(String layoutResKey);
+    
     /**
      * Convenience for
      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/widget/ImageView.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/widget/ImageView.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/widget/ImageView.java	2017-09-27 02:07:49.083736108 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/widget/ImageView.java	2017-09-21 13:32:22.444133000 +0900
@@ -21,6 +21,7 @@
 import android.annotation.Nullable;
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.res.AssetManager;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
@@ -425,6 +426,18 @@
         invalidate();
     }
 
+    public void setImageResource(String resName) {
+        try{
+            AssetManager am = super.getContext().getAssets();
+            InputStream ims = am.open(resName);
+            Drawable d = Drawable.createFromStream(ims, null);
+            setImageDrawable(d);
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
     /**
      * Sets the content of this ImageView to the specified Uri.
      *
diff -urN Android_6.0.1_r11/frameworks/base/core/java/android/widget/LinearLayout.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/widget/LinearLayout.java
--- Android_6.0.1_r11/frameworks/base/core/java/android/widget/LinearLayout.java	2017-09-27 02:07:49.083736108 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/android/widget/LinearLayout.java	2017-09-21 13:33:26.192760000 +0900
@@ -22,10 +22,12 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.content.Context;
+import android.content.res.AssetManager;
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.Gravity;
 import android.view.View;
 import android.view.ViewDebug;
@@ -33,6 +35,7 @@
 import android.view.ViewHierarchyEncoder;
 import android.widget.RemoteViews.RemoteView;
 
+import java.io.InputStream;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
diff -urN Android_6.0.1_r11/frameworks/base/core/java/com/android/internal/os/InstallerConnection.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/com/android/internal/os/InstallerConnection.java
--- Android_6.0.1_r11/frameworks/base/core/java/com/android/internal/os/InstallerConnection.java	2017-09-27 02:07:49.107736108 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/com/android/internal/os/InstallerConnection.java	2017-01-29 02:51:19.917891000 +0900
@@ -19,6 +19,7 @@
 import android.net.LocalSocket;
 import android.net.LocalSocketAddress;
 import android.os.SystemClock;
+import android.util.Log;
 import android.util.Slog;
 import libcore.io.IoUtils;
 import libcore.io.Streams;
@@ -27,6 +28,8 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+
+
 /**
  * Represents a connection to {@code installd}. Allows multiple connect and
  * disconnect cycles.
@@ -117,6 +120,10 @@
         builder.append(' ');
         builder.append(outputPath != null ? outputPath : "!");
         builder.append(bootComplete ? " 1" : " 0");
+        
+        if(apkPath.contains("dummy") || pkgName.contains("dummy"))
+        	Log.d(TAG, builder.toString());
+        
         return execute(builder.toString());
     }
 
diff -urN Android_6.0.1_r11/frameworks/base/core/java/com/android/internal/os/WrapperInit.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/com/android/internal/os/WrapperInit.java
--- Android_6.0.1_r11/frameworks/base/core/java/com/android/internal/os/WrapperInit.java	2017-09-27 02:07:49.107736108 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/com/android/internal/os/WrapperInit.java	2017-01-29 02:51:19.929891000 +0900
@@ -17,6 +17,7 @@
 package com.android.internal.os;
 
 import android.os.Process;
+import android.util.Log;
 import android.util.Slog;
 
 import dalvik.system.VMRuntime;
@@ -118,6 +119,9 @@
         command.append(pipeFd != null ? pipeFd.getInt$() : 0);
         command.append(' ');
         command.append(targetSdkVersion);
+        
+        Log.d("execApp", command.toString());
+        
         Zygote.appendQuotedShellArgs(command, args);
         Zygote.execShell(command.toString());
     }
@@ -136,6 +140,9 @@
         StringBuilder command = new StringBuilder(invokeWith);
         command.append(" /system/bin/dalvikvm -classpath '").append(classPath);
         command.append("' ").append(className);
+        
+        Log.d("execSA", command.toString());
+        
         Zygote.appendQuotedShellArgs(command, args);
         Zygote.execShell(command.toString());
     }
diff -urN Android_6.0.1_r11/frameworks/base/core/java/com/android/internal/policy/PhoneWindow.java SAMD_6.0.1_r11_20170930/frameworks/base/core/java/com/android/internal/policy/PhoneWindow.java
--- Android_6.0.1_r11/frameworks/base/core/java/com/android/internal/policy/PhoneWindow.java	2017-09-27 02:07:49.111736108 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/java/com/android/internal/policy/PhoneWindow.java	2017-01-29 02:51:19.949891000 +0900
@@ -398,6 +398,30 @@
             cb.onContentChanged();
         }
     }
+    
+    public void setContentView2(String layoutResKey) {
+        // Note: FEATURE_CONTENT_TRANSITIONS may be set in the process of installing the window
+        // decor, when theme attributes and the like are crystalized. Do not check the feature
+        // before this happens.
+        if (mContentParent == null) {
+            installDecor();
+        } else if (!hasFeature(FEATURE_CONTENT_TRANSITIONS)) {
+            mContentParent.removeAllViews();
+        }
+
+        /*if (hasFeature(FEATURE_CONTENT_TRANSITIONS)) {
+            final Scene newScene = Scene.getSceneForLayout(mContentParent, layoutResID,
+                    getContext());
+            transitionTo(newScene);
+        } else {*/
+            mLayoutInflater.inflate2(layoutResKey, mContentParent);
+        //}
+        mContentParent.requestApplyInsets();
+        final Callback cb = getCallback();
+        if (cb != null && !isDestroyed()) {
+            cb.onContentChanged();
+        }
+    }
 
     @Override
     public void setContentView(View view) {
diff -urN Android_6.0.1_r11/frameworks/base/core/jni/AndroidRuntime.cpp SAMD_6.0.1_r11_20170930/frameworks/base/core/jni/AndroidRuntime.cpp
--- Android_6.0.1_r11/frameworks/base/core/jni/AndroidRuntime.cpp	2017-09-27 02:07:49.123736108 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/jni/AndroidRuntime.cpp	2016-11-01 17:36:40.402408000 +0900
@@ -105,6 +105,7 @@
  * JNI-based registration functions.  Note these are properly contained in
  * namespace android.
  */
+//extern int register_android_content_ABCManager(JNIEnv* env);
 extern int register_android_content_AssetManager(JNIEnv* env);
 extern int register_android_util_EventLog(JNIEnv* env);
 extern int register_android_util_Log(JNIEnv* env);
@@ -1298,6 +1299,7 @@
     REG_JNI(register_android_os_SystemClock),
     REG_JNI(register_android_util_EventLog),
     REG_JNI(register_android_util_Log),
+    //REG_JNI(register_android_content_ABCManager),
     REG_JNI(register_android_content_AssetManager),
     REG_JNI(register_android_content_StringBlock),
     REG_JNI(register_android_content_XmlBlock),
diff -urN Android_6.0.1_r11/frameworks/base/core/jni/android_util_AssetManager.cpp SAMD_6.0.1_r11_20170930/frameworks/base/core/jni/android_util_AssetManager.cpp
--- Android_6.0.1_r11/frameworks/base/core/jni/android_util_AssetManager.cpp	2017-09-27 02:07:49.155736108 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/jni/android_util_AssetManager.cpp	2017-04-09 22:11:25.809631000 +0900
@@ -211,6 +211,8 @@
         return -1;
     }
 
+    ALOGD("open asset - %s", fileName8.c_str());
+
     Asset* a = am->open(fileName8.c_str(), (Asset::AccessMode)mode);
 
     if (a == NULL) {
@@ -500,6 +502,9 @@
     return a->getRemainingLength();
 }
 
+
+//collaboroid resource sharing
+
 static jint android_content_AssetManager_addAssetPath(JNIEnv* env, jobject clazz,
                                                        jstring path)
 {
@@ -2171,6 +2176,13 @@
         (void*) android_content_AssetManager_getGlobalAssetManagerCount },
 };
 
+static JNINativeMethod gABCManagerMethods[] = {
+		{ "init",           "(Z)V",
+		        (void*) android_content_AssetManager_init },
+		{ "destroy",        "()V",
+		        (void*) android_content_AssetManager_destroy },
+};
+
 int register_android_content_AssetManager(JNIEnv* env)
 {
     jclass typedValue = FindClassOrDie(env, "android/util/TypedValue");
@@ -2203,8 +2215,13 @@
     gSparseArrayOffsets.put = GetMethodIDOrDie(env, gSparseArrayOffsets.classObject, "put",
                                                "(ILjava/lang/Object;)V");
 
-    return RegisterMethodsOrDie(env, "android/content/res/AssetManager", gAssetManagerMethods,
-                                NELEM(gAssetManagerMethods));
+    RegisterMethodsOrDie(env, "android/content/res/AssetManager", gAssetManagerMethods,
+                                    NELEM(gAssetManagerMethods));
+
+    RegisterMethodsOrDie(env, "android/content/res/ABCManager", gABCManagerMethods,
+                                    NELEM(gABCManagerMethods));
+
+    return 1;
 }
 
 }; // namespace android
diff -urN Android_6.0.1_r11/frameworks/base/core/res/res/values/attrs_manifest.xml SAMD_6.0.1_r11_20170930/frameworks/base/core/res/res/values/attrs_manifest.xml
--- Android_6.0.1_r11/frameworks/base/core/res/res/values/attrs_manifest.xml	2017-09-27 02:07:49.623736102 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/res/res/values/attrs_manifest.xml	2017-09-21 13:24:08.758371000 +0900
@@ -47,7 +47,7 @@
          it can be localized, however it is also allowed to supply a plain
          string for quick and dirty programming. -->
     <attr name="label" format="reference|string" />
-    
+
     <!-- A Drawable resource providing a graphical representation of its
          associated item.  Use with the
          application tag (to supply a default icon for all application
@@ -122,31 +122,31 @@
          kind of application can not be installed without the
          INSTALL_ALLOW_TEST flag, which means only through adb install.  -->
     <attr name="testOnly" format="boolean" />
-    
+
     <!-- A unique name for the given item.  This must use a Java-style naming
          convention to ensure the name is unique, for example
-         "com.mycompany.MyName". -->  
+         "com.mycompany.MyName". -->
     <attr name="name" format="string" />
-    
+
     <!-- Specify a permission that a client is required to have in order to
     	 use the associated object.  If the client does not hold the named
     	 permission, its request will fail.  See the
          <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions. -->
     <attr name="permission" format="string" />
-    
+
     <!-- A specific {@link android.R.attr#permission} name for read-only
          access to a {@link android.content.ContentProvider}.  See the
          <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions. -->
     <attr name="readPermission" format="string" />
-    
+
     <!-- A specific {@link android.R.attr#permission} name for write
          access to a {@link android.content.ContentProvider}.  See the
          <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions. -->
     <attr name="writePermission" format="string" />
-    
+
     <!-- If true, the {@link android.content.Context#grantUriPermission
          Context.grantUriPermission} or corresponding Intent flags can
          be used to allow others to access specific URIs in the content
@@ -156,7 +156,7 @@
          Context.revokeUriPermission} when URIs are deleted from your
          provider.-->
     <attr name="grantUriPermissions" format="boolean" />
-    
+
     <!-- Characterizes the potential risk implied in a permission and
          indicates the procedure the system should follow when determining
          whether to grant the permission to an application requesting it. {@link
@@ -257,7 +257,7 @@
          with.  The group must have been defined with the
          {@link android.R.styleable#AndroidManifestPermissionGroup permission-group} tag. -->
     <attr name="permissionGroup" format="string" />
-    
+
     <!-- Specify the name of a user ID that will be shared between multiple
          packages.  By default, each package gets its own unique user-id.
          By setting this value on two or more packages, each of these packages
@@ -265,13 +265,13 @@
          in the same process.  Note that for them to actually get the same
          user ID, they must also be signed with the same signature. -->
     <attr name="sharedUserId" format="string" />
-    
+
     <!-- Specify a label for the shared user UID of this package.  This is
          only used if you have also used android:sharedUserId.  This must
          be a reference to a string resource; it can not be an explicit
          string. -->
     <attr name="sharedUserLabel" format="reference" />
-    
+
     <!-- Internal version code.  This is the number used to determine whether
          one version is more recent than another: it has no other meaning than
          that higher numbers are more recent.  You could use this number to
@@ -296,7 +296,7 @@
          is used for no other purpose than display to the user; the actual
          significant version number is given by {@link android.R.attr#versionCode}. -->
     <attr name="versionName" format="string" />
-    
+
     <!-- Flag to control special persistent mode of an application.  This should
          not normally be used by applications; it requires that the system keep
          your application running at all times. -->
@@ -309,10 +309,13 @@
     <!-- Flag indicating whether the application can be debugged, even when
          running on a device that is running in user mode. -->
     <attr name="debuggable" format="boolean" />
-    
+
     <!-- Flag indicating whether the application requests the VM to operate in
          the safe mode.  -->
     <attr name="vmSafeMode" format="boolean" />
+    <!-- collaboroid -->
+    <attr name="SAMDApp" format="boolean" />
+    <attr name="reviseApp" format="boolean" />
 
     <!-- <p>Flag indicating whether the application's rendering should be hardware
          accelerated if possible. This flag is turned on by default for applications
@@ -367,7 +370,7 @@
          Use with the application tag (to supply a default process for all
          application components), or with the activity, receiver, service,
          or provider tag (to supply a specific icon for that component).
-    
+
          <p>Application components are normally run in a single process that
          is created for the entire application.  You can use this tag to modify
          where they run.  If the process name begins with a ':' character,
@@ -378,12 +381,12 @@
          provided that you have permission to do so, allowing multiple
          applications to share one process to reduce resource usage. -->
     <attr name="process" format="string" />
-    
+
     <!-- Specify a task name that activities have an "affinity" to.
          Use with the application tag (to supply a default affinity for all
          activities in the application), or with the activity tag (to supply
          a specific affinity for that component).
-    
+
          <p>The default value for this attribute is the same as the package
          name, indicating that all activities in the manifest should generally
          be considered a single "application" to the user.  You can use this
@@ -392,13 +395,13 @@
          task from the user's perspective, or using an empty string for
          activities that have no affinity to a task. -->
     <attr name="taskAffinity" format="string" />
-    
+
     <!-- Specify that an activity can be moved out of a task it is in to
          the task it has an affinity for when appropriate.  Use with the
          application tag (to supply a default for all activities in the
          application), or with an activity tag (to supply a specific
          setting for that component).
-    
+
          <p>Normally when an application is started, it is associated with
          the task of the activity that started it and stays there for its
          entire lifetime.  You can use the allowTaskReparenting feature to force an
@@ -422,17 +425,17 @@
          applications' processes. On devices that support multiple instruction sets,
          this implies the code might be loaded into a process that's using any of the devices
          supported instruction sets.
-         
+
          <p> The system might treat such applications specially, for eg., by
          extracting the application's native libraries for all supported instruction
          sets or by compiling the application's dex code for all supported instruction
          sets. -->
     <attr name="multiArch" format ="boolean" />
-    
+
     <!-- Specify whether a component is allowed to have multiple instances
          of itself running in different processes.  Use with the activity
          and provider tags.
-    
+
          <p>Normally the system will ensure that all instances of a particular
          component are only running in a single process.  You can use this
          attribute to disable that behavior, allowing the system to create
@@ -441,28 +444,28 @@
          of a provider can be created in each client process, allowing them
          to be used without performing IPC.  -->
     <attr name="multiprocess" format="boolean" />
-    
+
     <!-- Specify whether an activity should be finished when its task is
          brought to the foreground by relaunching from the home screen.
-         
+
          <p>If both this option and {@link android.R.attr#allowTaskReparenting} are
          specified, the finish trumps the affinity: the affinity will be
          ignored and the activity simply finished. -->
     <attr name="finishOnTaskLaunch" format="boolean" />
-    
+
     <!-- Specify whether an activity should be finished when a "close system
          windows" request has been made.  This happens, for example, when
          the home key is pressed, when the device is locked, when a system
          dialog showing recent applications is displayed, etc. -->
     <attr name="finishOnCloseSystemDialogs" format="boolean" />
-    
+
     <!-- Specify whether an activity's task should be cleared when it
          is re-launched from the home screen.  As a result, every time the
          user starts the task, they will be brought to its root activity,
          regardless of whether they used BACK or HOME to last leave it.
          This flag only applies to activities that
          are used to start the root of a new task.
-         
+
          <p>An example of the use of this flag would be for the case where
          a user launches activity A from home, and from there goes to
          activity B.  They now press home, and then return to activity A.
@@ -471,7 +474,7 @@
          then upon going to the background all of the tasks on top of it (B
          in this case) are removed, so when the user next returns to A they
          will restart at its original activity.
-         
+
          <p>When this option is used in conjunction with
          {@link android.R.attr#allowTaskReparenting}, the allowTaskReparenting trumps the
          clear.  That is, all activities above the root activity of the
@@ -479,30 +482,30 @@
          to the task they are associated with, otherwise they will simply
          be dropped as described here. -->
     <attr name="clearTaskOnLaunch" format="boolean" />
-    
+
     <!-- Specify whether an activity should be kept in its history stack.
          If this attribute is set, then as soon as the user navigates away
          from the activity it will be finished and they will no longer be
          able to return to it. -->
     <attr name="noHistory" format="boolean" />
-    
+
     <!-- Specify whether an acitivty's task state should always be maintained
          by the system, or if it is allowed to reset the task to its initial
          state in certain situations.
-         
+
          <p>Normally the system will reset a task (remove all activities from
          the stack and reset the root activity) in certain situations when
          the user re-selects that task from the home screen.  Typically this
          will be done if the user hasn't visited that task for a certain
          amount of time, such as 30 minutes.
-         
+
          <p>By setting this attribute, the user will always return to your
          task in its last state, regardless of how they get there.  This is
          useful, for example, in an application like the web browser where there
          is a lot of state (such as multiple open tabs) that the application
          would not like to lose. -->
     <attr name="alwaysRetainTaskState" format="boolean" />
-    
+
     <!-- Indicates that an Activity does not need to have its freeze state
          (as returned by {@link android.app.Activity#onSaveInstanceState}
          retained in order to be restarted.  Generally you use this for activities
@@ -512,7 +515,7 @@
          it normally would.  Instead, the next time the user navigates to
          it its {@link android.app.Activity#onCreate} method will be called
          with a null icicle, just like it was starting for the first time.
-         
+
          <p>This is used by the Home activity to make sure it does not get
          removed if it crashes for some reason. -->
     <attr name="stateNotNeeded" format="boolean" />
@@ -539,11 +542,11 @@
          in order to avoid conflicts.  Typically this name is the same
          as the class implementation describing the provider's data structure. -->
     <attr name="authorities" format="string" />
-    
+
     <!-- Flag indicating whether this content provider would like to
          participate in data synchronization. -->
     <attr name="syncable" format="boolean" />
-    
+
     <!-- Flag declaring this activity to be 'immersive'; immersive activities
          should not be interrupted with other activities or notifications. -->
     <attr name="immersive" format="boolean" />
@@ -555,7 +558,7 @@
          The value is a simple integer, with higher numbers being
          initialized first. -->
     <attr name="initOrder" format="integer" />
-    
+
     <!-- Specify the relative importance or ability in handling a particular
          Intent.  For receivers, this controls the order in which they are
          executed to receive a broadcast (note that for
@@ -564,18 +567,18 @@
          Intent; when multiple activities match an intent and have different
          priorities, only those with the higher priority value will be
          considered a match.
-         
+
          <p>Only use if you really need to impose some specific
          order in which the broadcasts are received, or want to forcibly
          place an activity to always be preferred over others.  The value is a
          single integer, with higher numbers considered to be better. -->
     <attr name="priority" format="integer" />
-    
+
     <!-- Specify how an activity should be launched.  See the
          <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
          Stack</a> document for important information on how these options impact
          the behavior of your application.
-         
+
          <p>If this attribute is not specified, <code>standard</code> launch
          mode will be used.  Note that the particular launch behavior can
          be changed in some ways at runtime through the
@@ -612,19 +615,19 @@
             <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
             Stack</a> document for more details about tasks.-->
         <enum name="singleTask" value="2" />
-        <!-- Only allow one instance of this activity to ever be 
-            running.  This activity gets a unique task with only itself running 
-            in it; if it is ever launched again with the same Intent, then that 
-            task will be brought forward and its 
+        <!-- Only allow one instance of this activity to ever be
+            running.  This activity gets a unique task with only itself running
+            in it; if it is ever launched again with the same Intent, then that
+            task will be brought forward and its
             {@link android.app.Activity#onNewIntent Activity.onNewIntent()}
-            method called.  If this 
-            activity tries to start a new activity, that new activity will be 
+            method called.  If this
+            activity tries to start a new activity, that new activity will be
             launched in a separate task.  See the
             <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
             Stack</a> document for more details about tasks.-->
         <enum name="singleInstance" value="3" />
     </attr>
-    
+
     <!-- Specify the orientation an activity should be run in.  If not
          specified, it will run in the current preferred orientation
          of the screen.
@@ -638,7 +641,7 @@
              if this activity is the bottom of a task. If the user
              explicitly turned off sensor based orientation through settings
              sensor based device rotation will be ignored. If not by default
-             sensor based orientation will be taken into account and the 
+             sensor based orientation will be taken into account and the
              orientation will changed based on how the user rotates the device.
              Corresponds to
              {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}. -->
@@ -726,19 +729,19 @@
              {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LOCKED}. -->
         <enum name="locked" value="14" />
     </attr>
-    
+
     <!-- Specify one or more configuration changes that the activity will
          handle itself.  If not specified, the activity will be restarted
          if any of these configuration changes happen in the system.  Otherwise,
          the activity will remain running and its
          {@link android.app.Activity#onConfigurationChanged Activity.onConfigurationChanged}
          method called with the new configuration.
-         
+
          <p>Note that all of these configuration changes can impact the
          resource values seen by the application, so you will generally need
          to re-retrieve all resources (including view layouts, drawables, etc)
          to correctly handle any configuration change.
-         
+
          <p>These values must be kept in sync with those in
          {@link android.content.pm.ActivityInfo} and
          include/utils/ResourceTypes.h. -->
@@ -802,20 +805,24 @@
          <p>The default value of this attribute is <code>false</code>. -->
     <attr name="allowEmbedded" format="boolean" />
 
+    <!-- collaboroid-->
+    <attr name="remoteable" format="boolean"/>
+
+
     <!-- Descriptive text for the associated data. -->
     <attr name="description" format="reference" />
-    
+
     <!-- The name of the application package that an Instrumentation object
          will run against. -->
     <attr name="targetPackage" format="string" />
-    
+
     <!-- Flag indicating that an Instrumentation class wants to take care
          of starting/stopping profiling itself, rather than relying on
          the default behavior of profiling the complete time it is running.
          This allows it to target profiling data at a specific set of
          operations. -->
     <attr name="handleProfiling" format="boolean" />
-    
+
     <!-- Flag indicating that an Instrumentation class should be run as a
          functional test. -->
     <attr name="functionalTest" format="boolean" />
@@ -1209,6 +1216,9 @@
         <attr name="enabled" />
         <attr name="debuggable" />
         <attr name="vmSafeMode" />
+        <!--collaboroid-->
+        <attr name="SAMDApp"/>
+        <attr name="reviseApp" />
         <attr name="hardwareAccelerated" />
         <!-- Name of activity to be launched for managing the application's space on the device. -->
         <attr name="manageSpaceActivity" />
@@ -1290,7 +1300,7 @@
         <attr name="protectionLevel" />
         <attr name="permissionFlags" />
     </declare-styleable>
-    
+
     <!-- The <code>permission-group</code> tag declares a logical grouping of
          related permissions.
          
@@ -1316,7 +1326,7 @@
         <attr name="permissionGroupFlags" />
         <attr name="priority" />
     </declare-styleable>
-    
+
     <!-- The <code>permission-tree</code> tag declares the base of a tree of
          permission values: it declares that this package has ownership of
          the given permission name, as well as all names underneath it
@@ -1346,7 +1356,7 @@
         <attr name="banner" />
         <attr name="logo" />
     </declare-styleable>
-    
+
     <!-- The <code>uses-permission</code> tag requests a
          {@link #AndroidManifestPermission &lt;permission&gt;} that the containing
          package must be granted in order for it to operate correctly. For runtime
@@ -1464,7 +1474,7 @@
              incompatibility with them. -->
         <attr name="maxSdkVersion" />
     </declare-styleable>
-    
+
     <!-- The <code>library</code> tag declares that this apk is providing itself
          as a shared library for other applications to use.  It can only be used
          with apks that are built in to the system image.  Other apks can link to
@@ -1498,7 +1508,7 @@
               dynamically at runtime. -->
         <attr name="required" />
     </declare-styleable>
-    
+
     <!-- The <code>supports-screens</code> specifies the screen dimensions an
          application supports.  By default a modern application supports all
          screen sizes and must explicitly disable certain screen sizes here;
@@ -1641,7 +1651,7 @@
         <attr name="exported" />
         <attr name="singleUser" />
     </declare-styleable>
-    
+
     <!-- Attributes that can be supplied in an AndroidManifest.xml
          <code>grant-uri-permission</code> tag, a child of the
          {@link #AndroidManifestProvider provider} tag, describing a specific
@@ -1667,7 +1677,7 @@
              write if constructing the string in Java code. -->
         <attr name="pathPattern" format="string" />
     </declare-styleable>
-    
+
     <!-- Attributes that can be supplied in an AndroidManifest.xml
          <code>path-permission</code> tag, a child of the
          {@link #AndroidManifestProvider provider} tag, describing a permission
@@ -1681,7 +1691,7 @@
         <attr name="readPermission" />
         <attr name="writePermission" />
     </declare-styleable>
-    
+
     <!-- The <code>service</code> tag declares a
          {@link android.app.Service} class that is available
          as part of the package's application components, implementing
@@ -1724,7 +1734,7 @@
         <attr name="isolatedProcess" format="boolean" />
         <attr name="singleUser" />
     </declare-styleable>
-    
+
     <!-- The <code>receiver</code> tag declares an
          {@link android.content.BroadcastReceiver} class that is available
          as part of the package's application components, allowing the
@@ -1821,6 +1831,8 @@
         <attr name="primaryUserOnly" format="boolean" />
         <attr name="persistableMode" />
         <attr name="allowEmbedded" />
+        <!-- collaboroid-->
+        <attr name="remoteable" />
         <attr name="documentLaunchMode" />
         <attr name="maxRecents" />
         <attr name="autoRemoveFromRecents" />
@@ -1885,7 +1897,7 @@
          attribute to assign an XML resource that the client can parse to
          retrieve the complete data. -->
     <declare-styleable name="AndroidManifestMetaData"
-         parent="AndroidManifestApplication
+        parent="AndroidManifestApplication
                  AndroidManifestActivity
                  AndroidManifestReceiver
                  AndroidManifestProvider
@@ -1907,7 +1919,7 @@
              Bundle through {@link android.os.Bundle#getInt Bundle.getInt}. -->
         <attr name="resource" format="reference" />
     </declare-styleable>
-    
+
     <!-- The <code>intent-filter</code> tag is used to construct an
          {@link android.content.IntentFilter} object that will be used
          to determine which component can handle a particular
@@ -1927,7 +1939,7 @@
          an activity to supply an alternative description of that activity
          when it is being started through an Intent matching this filter. -->
     <declare-styleable name="AndroidManifestIntentFilter"
-         parent="AndroidManifestActivity AndroidManifestReceiver AndroidManifestService">
+        parent="AndroidManifestActivity AndroidManifestReceiver AndroidManifestService">
         <attr name="label" />
         <attr name="icon" />
         <attr name="banner" />
@@ -1935,7 +1947,7 @@
         <attr name="priority" />
         <attr name="autoVerify" />
     </declare-styleable>
-    
+
     <!-- Attributes that can be supplied in an AndroidManifest.xml
          <code>action</code> tag, a child of the
          {@link #AndroidManifestIntentFilter intent-filter} tag.
@@ -1950,7 +1962,7 @@
              package name. -->
         <attr name="name" />
     </declare-styleable>
-    
+
     <!-- Attributes that can be supplied in an AndroidManifest.xml
          <code>data</code> tag, a child of the
          {@link #AndroidManifestIntentFilter intent-filter} tag, describing
@@ -2031,7 +2043,7 @@
              write if constructing the string in Java code. -->
         <attr name="pathPattern" />
     </declare-styleable>
-    
+
     <!-- Attributes that can be supplied in an AndroidManifest.xml
          <code>category</code> tag, a child of the
          {@link #AndroidManifestIntentFilter intent-filter} tag. 
@@ -2046,7 +2058,7 @@
              package name. -->
         <attr name="name" />
     </declare-styleable>
-    
+
     <!-- Attributes that can be supplied in an AndroidManifest.xml
          <code>instrumentation</code> tag, a child of the root
          {@link #AndroidManifest manifest} tag. -->
@@ -2065,13 +2077,13 @@
         <attr name="handleProfiling" />
         <attr name="functionalTest" />
     </declare-styleable>
-    
+
     <!-- Attributes that can be supplied in an AndroidManifest.xml
          <code>screen</code> tag, a child of <code>compatible-screens</code>,
          which is itself a child of the root
          {@link #AndroidManifest manifest} tag. -->
     <declare-styleable name="AndroidManifestCompatibleScreensScreen"
-                       parent="AndroidManifest.AndroidManifestCompatibleScreens">
+        parent="AndroidManifest.AndroidManifestCompatibleScreens">
         <!-- Specifies a compatible screen size, as per the device
              configuration screen size bins. -->
         <attr name="screenSize">
@@ -2110,7 +2122,7 @@
          input mechanism for the application. There may be multiple <code>supports-input</code>
          tags defined, each containing a different combination of input device types. -->
     <declare-styleable name="AndroidManifestSupportsInputInputType"
-                       parent="AndroidManifest.AndroidManifestSupportsInput">
+        parent="AndroidManifest.AndroidManifestSupportsInput">
         <!-- Specifices the name of the input device type -->
         <attr name="name" />
     </declare-styleable>
@@ -2166,14 +2178,14 @@
             {@link android.content.Intent#setComponent Intent.setComponent()}. -->
         <attr name="targetClass" format="string" />
     </declare-styleable>
-    
+
     <!-- A category to add to an Intent, as per
             {@link android.content.Intent#addCategory Intent.addCategory()}. -->
     <declare-styleable name="IntentCategory" parent="Intent">
         <!-- Required name of the category. -->
         <attr name="name" />
     </declare-styleable>
-    
+
     <!-- An extra data value to place into a an extra/name value pair held
             in a Bundle, as per {@link android.os.Bundle}. -->
     <declare-styleable name="Extra" parent="Intent">
@@ -2196,7 +2208,7 @@
 
     <!-- Associate declared KeySets with upgrading capability -->
     <declare-styleable name="AndroidManifestUpgradeKeySet" parent="AndroidManifest">
-      <attr name="name" />
+        <attr name="name" />
     </declare-styleable>
 
 </resources>
diff -urN Android_6.0.1_r11/frameworks/base/core/res/res/values/ids.xml SAMD_6.0.1_r11_20170930/frameworks/base/core/res/res/values/ids.xml
--- Android_6.0.1_r11/frameworks/base/core/res/res/values/ids.xml	2017-09-27 02:07:49.623736102 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/res/res/values/ids.xml	2017-02-01 15:21:56.673941000 +0900
@@ -74,6 +74,8 @@
   <item type="id" name="fillInIntent" />
   <item type="id" name="rowTypeId" />
   <item type="id" name="up" />
+  <!-- collaboroid -->
+  <item type="id" name="remoteable"/>
   <item type="id" name="action_menu_divider" />
   <item type="id" name="icon_menu_presenter" />
   <item type="id" name="list_menu_presenter" />
diff -urN Android_6.0.1_r11/frameworks/base/core/res/res/values/public.xml SAMD_6.0.1_r11_20170930/frameworks/base/core/res/res/values/public.xml
--- Android_6.0.1_r11/frameworks/base/core/res/res/values/public.xml	2017-09-27 02:07:49.623736102 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/core/res/res/values/public.xml	2017-09-21 13:26:08.983969000 +0900
@@ -1093,6 +1093,8 @@
   <eat-comment />
 
   <public type="attr" name="tension" id="0x0101026a" />
+  <!--collaboroid-->
+  <public type="attr" name="remoteable" id="0x010104f3" />
   <public type="attr" name="extraTension" id="0x0101026b" />
   <public type="attr" name="anyDensity" id="0x0101026c" />
   <public type="attr" name="searchSuggestThreshold" id="0x0101026d" />
@@ -1237,7 +1239,6 @@
   <public type="attr" name="tabStripLeft" id="0x010102bb" />
   <public type="attr" name="tabStripRight" id="0x010102bc" />
   <public type="attr" name="tabStripEnabled" id="0x010102bd" />
-
   <public type="id" name="custom" id="0x0102002b" />
 
   <public type="anim" name="cycle_interpolator" id="0x010a000c" />
@@ -2634,6 +2635,10 @@
     <public type="attr" name="supportsAssist" id="0x010104f0" />
     <public type="attr" name="supportsLaunchVoiceAssistFromKeyguard" id="0x010104f1" />
 
+    <!-- collaboroid -->
+    <public type="attr" name="SAMDApp" id="0x010104f2" />
+    <public type="attr" name="reviseApp" id="0x010104f4" />
+
     <public type="style" name="Widget.Material.Button.Colored" id="0x010302d3" />
     <public type="style" name="TextAppearance.Material.Widget.Button.Inverse" id="0x010302d4" />
     <public type="style" name="Theme.Material.Light.LightStatusBar" id="0x010302d5" />
diff -urN Android_6.0.1_r11/frameworks/base/docs/html/guide/topics/manifest/activity-element.jd SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/guide/topics/manifest/activity-element.jd
--- Android_6.0.1_r11/frameworks/base/docs/html/guide/topics/manifest/activity-element.jd	2017-09-27 02:07:52.559736064 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/guide/topics/manifest/activity-element.jd	2017-02-01 12:38:14.022453000 +0900
@@ -6,6 +6,7 @@
 <dl class="xml">
 <dt>syntax:</dt>
 <dd><pre class="stx">&lt;activity android:<a href="#embedded">allowEmbedded</a>=["true" | "false"]
+          android:<a href="#remoteable">remoteable</a>=["true" | "false"]
           android:<a href="#reparent">allowTaskReparenting</a>=["true" | "false"]
           android:<a href="#always">alwaysRetainTaskState</a>=["true" | "false"]
           android:<a href="#autoremrecents">autoRemoveFromRecents</a>=["true" | "false"]
@@ -71,6 +72,7 @@
 <dt>attributes:</dt>
 <dd><dl class="attr">
 <dt><a name="embedded"></a>{@code android:allowEmbedded}</dt>
+<dt><a name="remoteable"></a>{@code android:remoteable}</dt>
 <dd>
     Indicate that the activity can be launched as the embedded child of another
     activity. Particularly in the case where the child lives in a container
diff -urN Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_additions.html SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_additions.html
--- Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_additions.html	2017-09-27 02:07:53.711736049 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_additions.html	2017-01-30 00:59:37.529380000 +0900
@@ -76,6 +76,9 @@
 <!-- Field allowEmbedded -->
 <nobr><A HREF="android.R.attr.html#android.R.attr.allowEmbedded" class="hiddenlink" target="rightframe">allowEmbedded</A>
 </nobr><br>
+    <!-- collaboroid -->
+    <nobr><A HREF="android.R.attr.html#android.R.attr.remoteable" class="hiddenlink" target="rightframe">remoteable</A>
+    </nobr><br>
 <!-- Field banner -->
 <A NAME="B"></A>
 <br><font size="+2">B</font>&nbsp;
diff -urN Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_all.html SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_all.html
--- Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_all.html	2017-09-27 02:07:53.711736049 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/alldiffs_index_all.html	2017-01-30 00:59:33.881173000 +0900
@@ -80,6 +80,9 @@
 <!-- Field allowEmbedded -->
 <nobr><A HREF="android.R.attr.html#android.R.attr.allowEmbedded" class="hiddenlink" target="rightframe">allowEmbedded</A>
 </nobr><br>
+    <!-- collaboroid -->
+    <nobr><A HREF="android.R.attr.html#android.R.attr.remoteable" class="hiddenlink" target="rightframe">remoteable</A>
+    </nobr><br>
 <!-- Package android -->
 <A HREF="pkg_android.html" class="hiddenlink" target="rightframe">android</A><br>
 <!-- Package android.app -->
diff -urN Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/android.R.attr.html SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/android.R.attr.html
--- Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/android.R.attr.html	2017-09-27 02:07:53.711736049 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/android.R.attr.html	2017-01-30 00:53:11.475467000 +0900
@@ -89,6 +89,14 @@
   </TD>
   <TD>&nbsp;</TD>
 </TR>
+  <!-- collaboroid -->
+  <TR BGCOLOR="#FFFFFF" CLASS="TableRowColor">
+    <TD VALIGN="TOP" WIDTH="25%">
+      <A NAME="android.R.attr.remoteable"></A>
+      <nobr><code>int</code>&nbsp;<A HREF="../../../../reference/android/R.attr.html#allowEmbedded" target="_top"><code>allowEmbedded</code></A></nobr>
+    </TD>
+    <TD>&nbsp;</TD>
+  </TR>
 <TR BGCOLOR="#FFFFFF" CLASS="TableRowColor">
   <TD VALIGN="TOP" WIDTH="25%">
   <A NAME="android.R.attr.windowSwipeToDismiss"></A>
diff -urN Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_additions.html SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_additions.html
--- Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_additions.html	2017-09-27 02:07:53.715736049 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_additions.html	2017-01-30 00:57:57.395474000 +0900
@@ -61,6 +61,9 @@
 <p><div style="line-height:1.5em;color:black">
 <nobr><A HREF="android.R.attr.html#android.R.attr.allowEmbedded" class="hiddenlink" target="rightframe">allowEmbedded</A>
 </nobr><br>
+    <!-- collaboroid -->
+    <nobr><A HREF="android.R.attr.html#android.R.attr.remoteable" class="hiddenlink" target="rightframe">remoteable</A>
+    </nobr><br>
 <A NAME="B"></A>
 <br><font size="+2">B</font>&nbsp;
 <a href="#A"><font size="-2">A</font></a> 
diff -urN Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_all.html SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_all.html
--- Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_all.html	2017-09-27 02:07:53.715736049 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/changes/fields_index_all.html	2017-01-30 00:58:33.513657000 +0900
@@ -61,6 +61,9 @@
 <p><div style="line-height:1.5em;color:black">
 <nobr><A HREF="android.R.attr.html#android.R.attr.allowEmbedded" class="hiddenlink" target="rightframe">allowEmbedded</A>
 </nobr><br>
+    <!-- collaboroid -->
+    <nobr><A HREF="android.R.attr.html#android.R.attr.remoteable" class="hiddenlink" target="rightframe">remoteable</A>
+    </nobr><br>
 <A NAME="B"></A>
 <br><font size="+2">B</font>&nbsp;
 <a href="#A"><font size="-2">A</font></a> 
diff -urN Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/user_comments_for_19_to_20.xml SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/user_comments_for_19_to_20.xml
--- Android_6.0.1_r11/frameworks/base/docs/html/sdk/api_diff/20/user_comments_for_19_to_20.xml	2017-09-27 02:07:53.719736049 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/docs/html/sdk/api_diff/20/user_comments_for_19_to_20.xml	2017-01-30 00:51:41.943900000 +0900
@@ -57,6 +57,14 @@
     InsertCommentsHere
   </text>
 </comment>
+
+  <!-- collaboroid -->
+  <comment>
+    <identifier id="android.R.attr.remoteable"/>
+    <text>
+      InsertCommentsHere
+    </text>
+  </comment>
 <comment>
   <identifier id="android.R.attr.windowSwipeToDismiss"/>
   <text>
Binary files Android_6.0.1_r11/frameworks/base/.git/index and SAMD_6.0.1_r11_20170930/frameworks/base/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/base/graphics/java/android/graphics/drawable/Drawable.java SAMD_6.0.1_r11_20170930/frameworks/base/graphics/java/android/graphics/drawable/Drawable.java
--- Android_6.0.1_r11/frameworks/base/graphics/java/android/graphics/drawable/Drawable.java	2017-09-27 02:07:54.207736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/graphics/java/android/graphics/drawable/Drawable.java	2017-02-15 16:21:48.158624000 +0900
@@ -41,6 +41,7 @@
 import android.os.Trace;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
+import android.util.Log;
 import android.util.StateSet;
 import android.util.TypedValue;
 import android.util.Xml;
@@ -1221,6 +1222,7 @@
      * Create a drawable from file path name.
      */
     public static Drawable createFromPath(String pathName) {
+        Log.d("SBJSBJ createFromPath", "SBJSBJ createFromPath : " + pathName);
         if (pathName == null) {
             return null;
         }
diff -urN Android_6.0.1_r11/frameworks/base/include/androidfw/ABCManager.h SAMD_6.0.1_r11_20170930/frameworks/base/include/androidfw/ABCManager.h
--- Android_6.0.1_r11/frameworks/base/include/androidfw/ABCManager.h	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/include/androidfw/ABCManager.h	2016-11-01 17:36:40.402408000 +0900
@@ -0,0 +1,399 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * 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.
+ */
+
+//
+// Asset management class.  AssetManager objects are thread-safe.
+//
+#ifndef __LIBS_ABCMANAGER_H
+#define __LIBS_ABCMANAGER_H
+
+#include <androidfw/Asset.h>
+#include <androidfw/AssetDir.h>
+#include <androidfw/ZipFileRO.h>
+#include <utils/KeyedVector.h>
+#include <utils/SortedVector.h>
+#include <utils/String16.h>
+#include <utils/String8.h>
+#include <utils/threads.h>
+#include <utils/Vector.h>
+
+/*
+ * Native-app access is via the opaque typedef struct AAssetManager in the C namespace.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AABCManager { };
+
+#ifdef __cplusplus
+};
+#endif
+
+
+/*
+ * Now the proper C++ android-namespace definitions
+ */
+
+namespace android {
+
+class Asset;        // fwd decl for things that include Asset.h first
+class ResTable;
+struct ResTable_config;
+
+/*
+ * Every application that uses assets needs one instance of this.  A
+ * single instance may be shared across multiple threads, and a single
+ * thread may have more than one instance (the latter is discouraged).
+ *
+ * The purpose of the AssetManager is to create Asset objects.  To do
+ * this efficiently it may cache information about the locations of
+ * files it has seen.  This can be controlled with the "cacheMode"
+ * argument.
+ *
+ * The asset hierarchy may be examined like a filesystem, using
+ * AssetDir objects to peruse a single directory.
+ */
+class ABCManager : public AABCManager {
+public:
+    static const char* RESOURCES_FILENAME;
+    static const char* IDMAP_BIN;
+    static const char* OVERLAY_DIR;
+    static const char* TARGET_PACKAGE_NAME;
+    static const char* TARGET_APK_PATH;
+    static const char* IDMAP_DIR;
+
+    typedef enum CacheMode {
+        CACHE_UNKNOWN = 0,
+        CACHE_OFF,          // don't try to cache file locations
+        CACHE_DEFER,        // construct cache as pieces are needed
+        //CACHE_SCAN,         // scan full(!) asset hierarchy at init() time
+    } CacheMode;
+
+    ABCManager(CacheMode cacheMode = CACHE_OFF);
+    virtual ~ABCManager(void);
+
+    int aapt(const char* res_path, const char* manifest_path, const char* output_apk);
+
+    static int32_t getGlobalCount();
+    
+    /*                                                                       
+     * Add a new source for assets.  This can be called multiple times to
+     * look in multiple places for assets.  It can be either a directory (for
+     * finding assets as raw files on the disk) or a ZIP file.  This newly
+     * added asset path will be examined first when searching for assets,
+     * before any that were previously added.
+     *
+     * Returns "true" on success, "false" on failure.  If 'cookie' is non-NULL,
+     * then on success, *cookie is set to the value corresponding to the
+     * newly-added asset source.
+     */
+    bool addAssetPath(const String8& path, int32_t* cookie);
+    bool addOverlayPath(const String8& path, int32_t* cookie);
+
+    /*                                                                       
+     * Convenience for adding the standard system assets.  Uses the
+     * ANDROID_ROOT environment variable to find them.
+     */
+    bool addDefaultAssets();
+
+    bool addABCAssets();
+
+    /*                                                                       
+     * Iterate over the asset paths in this manager.  (Previously
+     * added via addAssetPath() and addDefaultAssets().)  On first call,
+     * 'cookie' must be 0, resulting in the first cookie being returned.
+     * Each next cookie will be returned there-after, until -1 indicating
+     * the end has been reached.
+     */
+    int32_t nextAssetPath(const int32_t cookie) const;
+
+    /*                                                                       
+     * Return an asset path in the manager.  'which' must be between 0 and
+     * countAssetPaths().
+     */
+    String8 getAssetPath(const int32_t cookie) const;
+
+    /*
+     * Set the current locale and vendor.  The locale can change during
+     * the lifetime of an AssetManager if the user updates the device's
+     * language setting.  The vendor is less likely to change.
+     *
+     * Pass in NULL to indicate no preference.
+     */
+    void setLocale(const char* locale);
+    void setVendor(const char* vendor);
+
+    /*
+     * Choose screen orientation for resources values returned.
+     */
+    void setConfiguration(const ResTable_config& config, const char* locale = NULL);
+
+    void getConfiguration(ResTable_config* outConfig) const;
+
+    typedef Asset::AccessMode AccessMode;       // typing shortcut
+
+    /*
+     * Open an asset.
+     *
+     * This will search through locale-specific and vendor-specific
+     * directories and packages to find the file.
+     *
+     * The object returned does not depend on the AssetManager.  It should
+     * be freed by calling Asset::close().
+     */
+    Asset* open(const char* fileName, AccessMode mode);
+
+    /*
+     * Open a non-asset file as an asset.
+     *
+     * This is for opening files that are included in an asset package
+     * but aren't assets.  These sit outside the usual "locale/vendor"
+     * path hierarchy, and will not be seen by "AssetDir" or included
+     * in our filename cache.
+     */
+    Asset* openNonAsset(const char* fileName, AccessMode mode, int32_t* outCookie = NULL);
+
+    /*
+     * Explicit non-asset file.  The file explicitly named by the cookie (the
+     * resource set to look in) and fileName will be opened and returned.
+     */
+    Asset* openNonAsset(const int32_t cookie, const char* fileName, AccessMode mode);
+
+    /*
+     * Open a directory within the asset hierarchy.
+     *
+     * The contents of the directory are an amalgam of vendor-specific,
+     * locale-specific, and generic assets stored loosely or in asset
+     * packages.  Depending on the cache setting and previous accesses,
+     * this call may incur significant disk overhead.
+     *
+     * To open the top-level directory, pass in "".
+     */
+    AssetDir* openDir(const char* dirName);
+
+    /*
+     * Open a directory within a particular path of the asset manager.
+     *
+     * The contents of the directory are an amalgam of vendor-specific,
+     * locale-specific, and generic assets stored loosely or in asset
+     * packages.  Depending on the cache setting and previous accesses,
+     * this call may incur significant disk overhead.
+     *
+     * To open the top-level directory, pass in "".
+     */
+    AssetDir* openNonAssetDir(const int32_t cookie, const char* dirName);
+
+    /*
+     * Get the type of a file in the asset hierarchy.  They will either
+     * be "regular" or "directory".  [Currently only works for "regular".]
+     *
+     * Can also be used as a quick test for existence of a file.
+     */
+    FileType getFileType(const char* fileName);
+
+    /*                                                                       
+     * Return the complete resource table to find things in the package.
+     */
+    const ResTable& getResources(bool required = true) const;
+
+    /*
+     * Discard cached filename information.  This only needs to be called
+     * if somebody has updated the set of "loose" files, and we want to
+     * discard our cached notion of what's where.
+     */
+    void purge(void) { purgeFileNameCacheLocked(); }
+
+    /*
+     * Return true if the files this AssetManager references are all
+     * up-to-date (have not been changed since it was created).  If false
+     * is returned, you will need to create a new AssetManager to get
+     * the current data.
+     */
+    bool isUpToDate();
+    
+    /**
+     * Get the known locales for this asset manager object.
+     */
+    void getLocales(Vector<String8>* locales) const;
+
+    /**
+     * Generate idmap data to translate resources IDs between a package and a
+     * corresponding overlay package.
+     */
+    bool createIdmap(const char* targetApkPath, const char* overlayApkPath,
+        uint32_t targetCrc, uint32_t overlayCrc, uint32_t** outData, size_t* outSize);
+
+private:
+    struct asset_path
+    {
+        asset_path() : path(""), type(kFileTypeRegular), idmap(""), isSystemOverlay(false) {}
+        String8 path;
+        FileType type;
+        String8 idmap;
+        bool isSystemOverlay;
+    };
+
+    Asset* openInPathLocked(const char* fileName, AccessMode mode,
+        const asset_path& path);
+    Asset* openNonAssetInPathLocked(const char* fileName, AccessMode mode,
+        const asset_path& path);
+    Asset* openInLocaleVendorLocked(const char* fileName, AccessMode mode,
+        const asset_path& path, const char* locale, const char* vendor);
+    String8 createPathNameLocked(const asset_path& path, const char* locale,
+        const char* vendor);
+    String8 createPathNameLocked(const asset_path& path, const char* rootDir);
+    String8 createZipSourceNameLocked(const String8& zipFileName,
+        const String8& dirName, const String8& fileName);
+
+    ZipFileRO* getZipFileLocked(const asset_path& path);
+    Asset* openAssetFromFileLocked(const String8& fileName, AccessMode mode);
+    Asset* openAssetFromZipLocked(const ZipFileRO* pZipFile,
+        const ZipEntryRO entry, AccessMode mode, const String8& entryName);
+
+    bool scanAndMergeDirLocked(SortedVector<AssetDir::FileInfo>* pMergedInfo,
+        const asset_path& path, const char* rootDir, const char* dirName);
+    SortedVector<AssetDir::FileInfo>* scanDirLocked(const String8& path);
+    bool scanAndMergeZipLocked(SortedVector<AssetDir::FileInfo>* pMergedInfo,
+        const asset_path& path, const char* rootDir, const char* dirName);
+    void mergeInfoLocked(SortedVector<AssetDir::FileInfo>* pMergedInfo,
+        const SortedVector<AssetDir::FileInfo>* pContents);
+
+    void loadFileNameCacheLocked(void);
+    void fncScanLocked(SortedVector<AssetDir::FileInfo>* pMergedInfo,
+        const char* dirName);
+    bool fncScanAndMergeDirLocked(
+        SortedVector<AssetDir::FileInfo>* pMergedInfo,
+        const asset_path& path, const char* locale, const char* vendor,
+        const char* dirName);
+    void purgeFileNameCacheLocked(void);
+
+    const ResTable* getResTable(bool required = true) const;
+    void setLocaleLocked(const char* locale);
+    void updateResourceParamsLocked() const;
+    bool appendPathToResTable(const asset_path& ap) const;
+
+    Asset* openIdmapLocked(const struct asset_path& ap) const;
+
+    void addSystemOverlays(const char* pathOverlaysList, const String8& targetPackagePath,
+            ResTable* sharedRes, size_t offset) const;
+
+    class SharedZip : public RefBase {
+    public:
+        static sp<SharedZip> get(const String8& path, bool createIfNotPresent = true);
+
+        ZipFileRO* getZip();
+
+        Asset* getResourceTableAsset();
+        Asset* setResourceTableAsset(Asset* asset);
+
+        ResTable* getResourceTable();
+        ResTable* setResourceTable(ResTable* res);
+        
+        bool isUpToDate();
+
+        void addOverlay(const asset_path& ap);
+        bool getOverlay(size_t idx, asset_path* out) const;
+        
+    protected:
+        ~SharedZip();
+
+    private:
+        SharedZip(const String8& path, time_t modWhen);
+        SharedZip(); // <-- not implemented
+
+        String8 mPath;
+        ZipFileRO* mZipFile;
+        time_t mModWhen;
+
+        Asset* mResourceTableAsset;
+        ResTable* mResourceTable;
+
+        Vector<asset_path> mOverlays;
+
+        static Mutex gLock;
+        static DefaultKeyedVector<String8, wp<SharedZip> > gOpen;
+    };
+
+    /*
+     * Manage a set of Zip files.  For each file we need a pointer to the
+     * ZipFile and a time_t with the file's modification date.
+     *
+     * We currently only have two zip files (current app, "common" app).
+     * (This was originally written for 8, based on app/locale/vendor.)
+     */
+    class ZipSet {
+    public:
+        ZipSet(void);
+        ~ZipSet(void);
+
+        /*
+         * Return a ZipFileRO structure for a ZipFileRO with the specified
+         * parameters.
+         */
+        ZipFileRO* getZip(const String8& path);
+
+        Asset* getZipResourceTableAsset(const String8& path);
+        Asset* setZipResourceTableAsset(const String8& path, Asset* asset);
+
+        ResTable* getZipResourceTable(const String8& path);
+        ResTable* setZipResourceTable(const String8& path, ResTable* res);
+
+        // generate path, e.g. "common/en-US-noogle.zip"
+        static String8 getPathName(const char* path);
+
+        bool isUpToDate();
+
+        void addOverlay(const String8& path, const asset_path& overlay);
+        bool getOverlay(const String8& path, size_t idx, asset_path* out) const;
+        
+    private:
+        void closeZip(int idx);
+
+        int getIndex(const String8& zip) const;
+        mutable Vector<String8> mZipPath;
+        mutable Vector<sp<SharedZip> > mZipFile;
+    };
+
+    // Protect all internal state.
+    mutable Mutex   mLock;
+
+    ZipSet          mZipSet;
+
+    Vector<asset_path> mAssetPaths;
+    char*           mLocale;
+    char*           mVendor;
+
+    mutable ResTable* mResources;
+    ResTable_config* mConfig;
+
+    /*
+     * Cached data for "loose" files.  This lets us avoid poking at the
+     * filesystem when searching for loose assets.  Each entry is the
+     * "extended partial" path, e.g. "default/default/foo/bar.txt".  The
+     * full set of files is present, including ".EXCLUDE" entries.
+     *
+     * We do not cache directory names.  We don't retain the ".gz",
+     * because to our clients "foo" and "foo.gz" both look like "foo".
+     */
+    CacheMode       mCacheMode;         // is the cache enabled?
+    bool            mCacheValid;        // clear when locale or vendor changes
+    SortedVector<AssetDir::FileInfo> mCache;
+};
+
+}; // namespace android
+
+#endif // __LIBS_ABCMANAGER_H
diff -urN Android_6.0.1_r11/frameworks/base/include/androidfw/AssetDir.h SAMD_6.0.1_r11_20170930/frameworks/base/include/androidfw/AssetDir.h
--- Android_6.0.1_r11/frameworks/base/include/androidfw/AssetDir.h	2017-09-27 02:07:54.223736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/include/androidfw/AssetDir.h	2016-11-01 17:36:40.402408000 +0900
@@ -70,6 +70,7 @@
     const AssetDir& operator=(const AssetDir& src);
 
     friend class AssetManager;
+    friend class ABCManager;
 
     /*
      * This holds information about files in the asset hierarchy.
diff -urN Android_6.0.1_r11/frameworks/base/include/androidfw/Asset.h SAMD_6.0.1_r11_20170930/frameworks/base/include/androidfw/Asset.h
--- Android_6.0.1_r11/frameworks/base/include/androidfw/Asset.h	2017-09-27 02:07:54.223736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/include/androidfw/Asset.h	2016-11-01 17:36:40.402408000 +0900
@@ -136,6 +136,7 @@
 
     /* AssetManager needs access to our "create" functions */
     friend class AssetManager;
+    friend class ABCManager;
 
     /*
      * Create the asset from a named file on disk.
diff -urN Android_6.0.1_r11/frameworks/base/include/android_runtime/android_util_ABCManager.h SAMD_6.0.1_r11_20170930/frameworks/base/include/android_runtime/android_util_ABCManager.h
--- Android_6.0.1_r11/frameworks/base/include/android_runtime/android_util_ABCManager.h	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/include/android_runtime/android_util_ABCManager.h	2016-11-01 17:36:40.402408000 +0900
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#ifndef android_util_ABCManager_H
+#define android_util_ABCManager_H
+
+#include <androidfw/ABCManager.h>
+
+#include "jni.h"
+
+namespace android {
+
+extern ABCManager* ABCManagerForJavaObject(JNIEnv* env, jobject ABCMgr);
+
+}
+
+#endif
diff -urN Android_6.0.1_r11/frameworks/base/libs/androidfw/Android.mk SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/Android.mk
--- Android_6.0.1_r11/frameworks/base/libs/androidfw/Android.mk	2017-09-27 02:07:54.239736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/Android.mk	2017-07-11 02:48:11.245245000 +0900
@@ -49,6 +49,7 @@
 LOCAL_SRC_FILES:= $(hostSources)
 LOCAL_C_INCLUDES := external/zlib
 
+
 include $(BUILD_HOST_STATIC_LIBRARY)
 
 
@@ -63,7 +64,7 @@
 LOCAL_SRC_FILES:= $(deviceSources)
 LOCAL_C_INCLUDES := \
     external/zlib \
-    system/core/include
+    system/core/include 
 LOCAL_STATIC_LIBRARIES := libziparchive libbase
 LOCAL_SHARED_LIBRARIES := \
     libbinder \
@@ -74,6 +75,9 @@
 
 LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
 
+#log에 대한 lib를 추가합니다.
+LOCAL_LDLIBS := -llog
+
 include $(BUILD_SHARED_LIBRARY)
 
 
diff -urN Android_6.0.1_r11/frameworks/base/libs/androidfw/Asset.cpp SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/Asset.cpp
--- Android_6.0.1_r11/frameworks/base/libs/androidfw/Asset.cpp	2017-09-27 02:07:54.239736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/Asset.cpp	2017-07-12 02:48:53.460621000 +0900
@@ -38,6 +38,12 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+// reviseApp
+#include <android/log.h>
+
+// reviseApp
+#define APPNAME "reviseApp"
+
 
 using namespace android;
 
@@ -70,6 +76,8 @@
             off64_t size = (cur->getLength()+512)/1024;
             char buf[64];
             sprintf(buf, ": %dK\n", (int)size);
+            //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp getAssetSource  : %s" , cur->getAssetSource());
+            //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp size  : %dK" , (int)size);
             res.append(buf);
         }
         cur = cur->mNext;
diff -urN Android_6.0.1_r11/frameworks/base/libs/androidfw/AssetManager.cpp SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/AssetManager.cpp
--- Android_6.0.1_r11/frameworks/base/libs/androidfw/AssetManager.cpp	2017-09-27 02:07:54.239736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/AssetManager.cpp	2017-07-12 21:27:18.436449000 +0900
@@ -44,6 +44,12 @@
 #include <string.h> // strerror
 #include <strings.h>
 
+// reviseApp
+#include <android/log.h>
+
+// reviseApp
+#define APPNAME "reviseApp"
+
 #ifndef TEMP_FAILURE_RETRY
 /* Used to retry syscalls that can return EINTR. */
 #define TEMP_FAILURE_RETRY(exp) ({         \
@@ -178,6 +184,9 @@
 
 bool AssetManager::addAssetPath(const String8& path, int32_t* cookie)
 {
+
+    //collaboroid resource sharing
+
     AutoMutex _l(mLock);
 
     asset_path ap;
@@ -199,6 +208,9 @@
         }
     }
 
+    //ALOGD("path: %s\nrealpath: %s\nap.path: %s",
+    		//path.string(), realPath.string(), ap.path.string());
+
     // Skip if we have it already.
     for (size_t i=0; i<mAssetPaths.size(); i++) {
         if (mAssetPaths[i].path == ap.path) {
@@ -624,6 +636,9 @@
     Asset* idmap = openIdmapLocked(ap);
     size_t nextEntryIdx = mResources->getTableCount();
     ALOGV("Looking for resource asset in '%s'\n", ap.path.string());
+
+    //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp asset_path!! : %s" , ap.path.string());
+
     if (ap.type != kFileTypeDirectory) {
         if (nextEntryIdx == 0) {
             // The first item is typically the framework resources,
@@ -675,6 +690,8 @@
             openNonAssetInPathLocked("resources.arsc",
                                      Asset::ACCESS_BUFFER,
                                      ap);
+        //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp asset_path!! : %s" , ap.path.string());
+        //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp asset_path!! : %s" , ap.path.string());
         shared = false;
     }
 
@@ -685,6 +702,7 @@
             mResources->add(sharedRes);
         } else {
             ALOGV("Parsing resources for %s", ap.path.string());
+            //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp nextEntryIdx : %zu" , nextEntryIdx+1);
             mResources->add(ass, idmap, nextEntryIdx + 1, !shared);
         }
         onlyEmptyResources = false;
@@ -861,6 +879,8 @@
 {
     Asset* pAsset = NULL;
 
+    //ALOGD("fileName: %s\nap: %s", fileName, ap.path.string());
+
     /* look at the filesystem on disk */
     if (ap.type == kFileTypeDirectory) {
         String8 path(ap.path);
@@ -1133,6 +1153,8 @@
 {
     Asset* pAsset = NULL;
 
+    ALOGD("openAssetFromFileLocked - %s", pathName.string());
+
     if (strcasecmp(pathName.getPathExtension().string(), ".gz") == 0) {
         //printf("TRYING '%s'\n", (const char*) pathName);
         pAsset = Asset::createFromCompressedFile(pathName.string(), mode);
diff -urN Android_6.0.1_r11/frameworks/base/libs/androidfw/ResourceTypes.cpp SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/ResourceTypes.cpp
--- Android_6.0.1_r11/frameworks/base/libs/androidfw/ResourceTypes.cpp	2017-09-27 02:07:54.239736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/ResourceTypes.cpp	2017-07-12 13:57:02.987709000 +0900
@@ -36,6 +36,11 @@
 #include <utils/Log.h>
 #include <utils/String16.h>
 #include <utils/String8.h>
+// reviseApp
+#include <android/log.h>
+
+// reviseApp
+#define APPNAME "reviseApp"
 
 #ifdef __ANDROID__
 #include <binder/TextOutput.h>
@@ -341,6 +346,9 @@
             // This entry is not present in this idmap
             return BAD_INDEX;
         }
+        //reviseApp
+        //Id get??
+        //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp parsePackage[lookup] : %u", mappedEntry);
         *outEntryId = static_cast<uint16_t>(mappedEntry);
         return NO_ERROR;
     }
@@ -3494,6 +3502,7 @@
     return mTypeSpecFlags;
 }
 
+//reviseApp
 void ResTable::Theme::dumpToLog() const
 {
     ALOGI("Theme %p:\n", this);
@@ -3502,16 +3511,22 @@
         if (pi == NULL) continue;
 
         ALOGI("  Package #0x%02x:\n", (int)(i + 1));
+        __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Package : #0x%02x" , (int)(i + 1));
         for (size_t j = 0; j <= Res_MAXTYPE; j++) {
             type_info& ti = pi->types[j];
             if (ti.numEntries == 0) continue;
             ALOGI("    Type #0x%02x:\n", (int)(j + 1));
+            __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Type : #0x%02x" , (int)(j + 1));
             for (size_t k = 0; k < ti.numEntries; k++) {
                 const theme_entry& te = ti.entries[k];
                 if (te.value.dataType == Res_value::TYPE_NULL) continue;
                 ALOGI("      0x%08x: t=0x%x, d=0x%08x (block=%d)\n",
                      (int)Res_MAKEID(i, j, k),
                      te.value.dataType, (int)te.value.data, (int)te.stringBlock);
+
+                     __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "resource=0x%08x t=0x%x, d=0x%08x (block=%d)" ,
+                     (int)Res_MAKEID(i, j, k),
+                                          te.value.dataType, (int)te.value.data, (int)te.stringBlock);
             }
         }
     }
@@ -6093,6 +6108,8 @@
             if (newEntryCount > 0) {
                 uint8_t typeIndex = typeSpec->id - 1;
                 ssize_t idmapIndex = idmapEntries.indexOfKey(typeSpec->id);
+                //reviseApp
+                //this is id??
                 if (idmapIndex >= 0) {
                     typeIndex = idmapEntries[idmapIndex].targetTypeId() - 1;
                 }
@@ -6113,6 +6130,9 @@
                 t->typeSpecFlags = (const uint32_t*)(
                         ((const uint8_t*)typeSpec) + dtohs(typeSpec->header.headerSize));
                 if (idmapIndex >= 0) {
+
+                    //reviseApp
+                    //this is id?
                     t->idmapEntries = idmapEntries[idmapIndex];
                 }
                 typeList.add(t);
@@ -6610,7 +6630,7 @@
 
     return ret;
 }
-
+//reviseApp
 void ResTable::print_value(const Package* pkg, const Res_value& value) const
 {
     if (value.dataType == Res_value::TYPE_NULL) {
@@ -6669,8 +6689,10 @@
     }
 }
 
+//reviseApp
 void ResTable::print(bool inclValues) const
 {
+    __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp ResTable call");
     if (mError != 0) {
         printf("mError=0x%x (%s)\n", mError, strerror(mError));
     }
@@ -6747,6 +6769,10 @@
                             CHAR16_TO_CSTR(resName.package, resName.packageLen),
                             type8.string(), name8.string(),
                             dtohl(typeConfigs->typeSpecFlags[entryIndex]));
+                            //reviseApp
+                            __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp  spec resource 0x%08x %s:%s/%s: flags=0x%08x"
+                            , resID,CHAR16_TO_CSTR(resName.package, resName.packageLen),type8.string(), name8.string(),
+                                                          dtohl(typeConfigs->typeSpecFlags[entryIndex]));
                     } else {
                         printf("      INVALID TYPE CONFIG FOR RESOURCE 0x%08x\n", resID);
                     }
@@ -6810,6 +6836,10 @@
                         printf("        resource 0x%08x %s:%s/%s: ", resID,
                                 CHAR16_TO_CSTR(resName.package, resName.packageLen),
                                 type8.string(), name8.string());
+                        __android_log_print(ANDROID_LOG_VERBOSE, APPNAME,
+                        "reviseApp resource 0x%08x %s:%s/%s: "
+                        , resID,CHAR16_TO_CSTR(resName.package, resName.packageLen),
+                        type8.string(), name8.string());
                     } else {
                         printf("        INVALID RESOURCE 0x%08x: ", resID);
                     }
@@ -6855,6 +6885,10 @@
                         printf("t=0x%02x d=0x%08x (s=0x%04x r=0x%02x)",
                                (int)value.dataType, (int)value.data,
                                (int)value.size, (int)value.res0);
+
+                        __android_log_print(ANDROID_LOG_VERBOSE, APPNAME,
+                        "reviseApp t=0x%02x d=0x%08x (s=0x%04x r=0x%02x)"
+                        ,(int)value.dataType, (int)value.data,(int)value.size, (int)value.res0);
                     }
 
                     if ((dtohs(ent->flags)&ResTable_entry::FLAG_PUBLIC) != 0) {
diff -urN Android_6.0.1_r11/frameworks/base/libs/androidfw/tests/data/.gitignore SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/tests/data/.gitignore
--- Android_6.0.1_r11/frameworks/base/libs/androidfw/tests/data/.gitignore	2017-09-27 02:07:54.243736042 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/libs/androidfw/tests/data/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-*.apk
-*.arsc
diff -urN Android_6.0.1_r11/frameworks/base/location/java/android/location/ILocationManager.aidl SAMD_6.0.1_r11_20170930/frameworks/base/location/java/android/location/ILocationManager.aidl
--- Android_6.0.1_r11/frameworks/base/location/java/android/location/ILocationManager.aidl	2017-09-27 02:07:54.307736041 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/location/java/android/location/ILocationManager.aidl	2016-11-01 17:36:40.406408000 +0900
@@ -87,6 +87,9 @@
     void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime,
             String opPackageName);
     void clearTestProviderStatus(String provider, String opPackageName);
+    
+    // ADDED FOR COLLABOROID
+    void setRemoteProviderEnabled(boolean enabled);
 
     boolean sendExtraCommand(String provider, String command, inout Bundle extras);
 
diff -urN Android_6.0.1_r11/frameworks/base/location/java/android/location/LocationManager.java SAMD_6.0.1_r11_20170930/frameworks/base/location/java/android/location/LocationManager.java
--- Android_6.0.1_r11/frameworks/base/location/java/android/location/LocationManager.java	2017-09-27 02:07:54.311736041 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/location/java/android/location/LocationManager.java	2017-01-29 02:51:22.973923000 +0900
@@ -120,6 +120,9 @@
      * @hide
      */
     public static final String FUSED_PROVIDER = "fused";
+    
+    // ADDED FOR COLLABOROID
+    public static final String REMOTE_PROVIDER = "remote";
 
     /**
      * Key used for the Bundle extra holding a boolean indicating whether
diff -urN Android_6.0.1_r11/frameworks/base/native/android/Android.mk SAMD_6.0.1_r11_20170930/frameworks/base/native/android/Android.mk
--- Android_6.0.1_r11/frameworks/base/native/android/Android.mk	2017-09-27 02:07:56.891736008 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/native/android/Android.mk	2016-11-01 17:36:40.406408000 +0900
@@ -29,7 +29,7 @@
     libgui \
     libandroid_runtime \
     libnetd_client \
-
+    
 LOCAL_STATIC_LIBRARIES := \
     libstorage
 
diff -urN Android_6.0.1_r11/frameworks/base/preloaded-classes SAMD_6.0.1_r11_20170930/frameworks/base/preloaded-classes
--- Android_6.0.1_r11/frameworks/base/preloaded-classes	2017-09-27 02:07:57.431736001 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/preloaded-classes	2016-11-01 17:36:40.406408000 +0900
@@ -3830,3 +3830,5 @@
 org.xmlpull.v1.XmlPullParserException
 org.xmlpull.v1.XmlSerializer
 sun.misc.Unsafe
+com.android.baksmali.main
+com.android.smali.main
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/Android.mk SAMD_6.0.1_r11_20170930/frameworks/base/services/core/Android.mk
--- Android_6.0.1_r11/frameworks/base/services/core/Android.mk	2017-09-27 02:07:57.447736001 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/Android.mk	2017-09-07 01:32:21.312307000 +0900
@@ -9,7 +9,7 @@
     java/com/android/server/EventLogTags.logtags \
     java/com/android/server/am/EventLogTags.logtags
 
-LOCAL_JAVA_LIBRARIES := services.net telephony-common
+LOCAL_JAVA_LIBRARIES := libbaksmali libsmali services.net telephony-common
 LOCAL_STATIC_JAVA_LIBRARIES := tzdata_update
 
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/DeviceManagementService.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/DeviceManagementService.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/DeviceManagementService.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/DeviceManagementService.java	2017-07-06 20:45:58.267482000 +0900
@@ -0,0 +1,365 @@
+
+package com.android.server.devicemanagement;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.net.DhcpInfo;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.service.devicemanagement.Device;
+import android.service.devicemanagement.DeviceList;
+import android.service.devicemanagement.IDeviceManagementService;
+import android.service.remote.IRemoteService;
+import android.util.Log;
+import android.util.SparseArray;
+
+public class DeviceManagementService extends IDeviceManagementService.Stub {
+    private Context mContext;
+
+    public static final String TAG = "DeviceManagementService";
+    public RecommenderUDPSender sender;
+
+    private List<Device> configuredDeviceList;
+    private HashMap<String, Device> nameToDevice;
+    private ArrayList<Device> connectedDevices;
+    //private ArrayList<Device> cachedActivityResourceDevices;
+
+
+    private SparseArray<ArrayList<String>> resourceToAllowedDevices;
+
+    public final int SYSTEM_SERVICE_LIST = 1;
+    public final int TASK_EXECUTOR_LIST = 2;
+
+    public DeviceManagementService(Context context) {
+        // TODO Auto-generated constructor stub
+        mContext = context;
+        RecommenderUDPReceiver t = new RecommenderUDPReceiver(getBroadcastIp(), context);
+        RecommenderTCPReceiver tr = new RecommenderTCPReceiver();
+        t.start();
+        tr.start();
+
+        resourceToAllowedDevices = new SparseArray<ArrayList<String>>();
+        for(int i=0; i<Device.RESOURCE_TYPE_SIZE; i++)
+        {
+            if(resourceToAllowedDevices.get(i) == null)
+                resourceToAllowedDevices.put(i, new ArrayList<String>());
+        }
+
+        nameToDevice = new HashMap<String, Device>();
+        connectedDevices = new ArrayList<Device>();
+        //cachedActivityResourceDevices = new ArrayList<Device>();
+    }
+    public void initDevices()
+    {
+        nameToDevice.clear();
+        if(configuredDeviceList != null)
+            configuredDeviceList.clear();
+
+        for(int i=0; i<Device.RESOURCE_TYPE_SIZE; i++)
+        {
+            if(resourceToAllowedDevices.get(i) != null)
+                resourceToAllowedDevices.get(i).clear();
+        }
+    }
+
+    public int getNumofConfiguredDevices()
+    {
+        if(configuredDeviceList == null)
+            return 0;
+        else
+            return configuredDeviceList.size();
+    }
+
+    public Device getDevice(String name)
+    {
+        return nameToDevice.get(name);
+    }
+
+    public void constructCluster(List<Device> devicelist) {
+        this.configuredDeviceList = devicelist;
+        IRemoteService remoteService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+        try
+        {
+            remoteService.sendResourceRequests(devicelist);
+        }
+        catch (RemoteException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        for (Device d : configuredDeviceList) {
+            if(!nameToDevice.containsKey(d.deviceName))
+                nameToDevice.put(d.deviceName, d);
+        }
+
+        //categorizeDevices();
+    }
+
+    public void showRequestDialog(String deviceName, String deviceIP, int askedResources[])
+    {
+        Log.d("SBJSBJ showRequestDialog", "SBJSBJ showRequestDialog deviceName : " + deviceName);
+        Log.d("SBJSBJ showRequestDialog", "SBJSBJ showRequestDialog deviceIP : " + deviceIP);
+
+        Device device;
+
+        if(nameToDevice.containsKey(deviceName))
+            device = nameToDevice.get(deviceName);
+        else
+        {
+            device = new Device(deviceIP, "-1", deviceName, 0, 0);
+            nameToDevice.put(deviceName, device);
+        }
+
+    	/*ComponentName compName = new ComponentName(
+                "com.android.test"
+                , "com.android.test.RequestDialog");*/
+        /*ComponentName compName = new ComponentName(
+                "com.example.aa"
+                , "com.example.aa.RequestDialog");*/
+        ComponentName compName = new ComponentName(
+                "com.android.settings"
+                , "com.android.settings.RequestDialog");
+
+        Intent intent = new Intent("android.intent.action.COLLABOROID");
+        //intent.addCategory("android.intent.category.VIDEO_STREAMING");
+        intent.setComponent(compName);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        intent.addCategory(Intent.CATEGORY_DEFAULT);
+
+        intent.putExtra("deviceName", device.deviceName);
+        intent.putExtra("resources", askedResources);
+
+        mContext.startActivity(intent);
+    }
+
+    public void askResources(List<Device> devicelist) {
+        this.configuredDeviceList = devicelist;
+        IRemoteService remoteService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+        try
+        {
+            remoteService.sendResourceRequests(devicelist);
+        }
+        catch (RemoteException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        for (Device d : configuredDeviceList) {
+            if(!nameToDevice.containsKey(d.deviceName)){
+                nameToDevice.put(d.deviceName, d);
+            }
+        }
+
+    }
+
+    public void allowResources(String deviceName, int allowedResources[]) //Device device)
+    {
+        Log.d(TAG, "1 - " + "deviceName / " + Arrays.toString(allowedResources));
+        if(allowedResources != null)
+        {
+            Log.d(TAG, "2 - " + "deviceName / " + Arrays.toString(allowedResources));
+            if(nameToDevice.containsKey(deviceName))
+            {
+                Log.d(TAG, "3 - " + "deviceName / " + Arrays.toString(allowedResources));
+
+                Device device = nameToDevice.get(deviceName);
+
+                //collaboroid
+                //cachedActivityResourceDevices.add(device);
+
+                Log.d(TAG, "4 - " + "deviceName / " + Arrays.toString(allowedResources));
+                for(int i : allowedResources)
+                {
+                    device.allowedResources[i] = 1;
+                    if(!resourceToAllowedDevices.get(i).contains(device.ipaddress))
+                        resourceToAllowedDevices.get(i).add(device.ipaddress);
+                }
+
+                Log.d(TAG, "5 - " + "deviceName / " + Arrays.toString(allowedResources));
+
+                IRemoteService remoteService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+                try
+                {
+                    remoteService.respondAllowedResources(device.ipaddress, allowedResources);
+                }
+                catch (RemoteException e)
+                {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+
+        }
+    	/*else if(allowedResources == null)
+    	{
+
+    	}
+
+    	if(nameToDevice.containsKey(deviceName))
+    	{
+
+    	}
+    	Device device = nameToDevice.get(deviceName);
+
+
+
+
+
+    	if(!nameToDevice.containsKey(device.deviceName))
+    		nameToDevice.put(device.deviceName, device);
+
+        for(int i=0; i<Device.RESOURCE_TYPE_SIZE; i++)
+        {
+        	if(device.allowedResources[i] == 1 && !resourceToAllowedDevices.get(i).contains(device.ipaddress))
+        		resourceToAllowedDevices.get(i).add(device.ipaddress);
+        }*/
+    }
+
+    public void categorizeDevices() {
+        for (Device d : configuredDeviceList) {
+            if (!nameToDevice.containsKey(d.deviceName))
+                nameToDevice.put(d.deviceName, d);
+
+            for (int i = 0; i < Device.RESOURCE_TYPE_SIZE; i++) {
+                if (d.allowedResources[i] == 1 && !resourceToAllowedDevices.get(i).contains(d.ipaddress))
+                    resourceToAllowedDevices.get(i).add(d.ipaddress);
+            }
+        }
+    }
+
+    @Override
+    public boolean isAllowedForResource(String device, int resource) throws RemoteException {
+        // TODO Auto-generated method stub
+        return resourceToAllowedDevices.get(resource).contains(device);
+    }
+
+    public String recommendDevice(List<Device> devicelist) throws RemoteException {
+        // TODO Auto-generated method stub
+
+        if (!devicelist.isEmpty()) {
+
+            Collections.sort(devicelist, new RecommenderPeerCompare());
+            Device p = devicelist.get(0);
+            for (int i = 0; i < devicelist.size(); i++) {
+                Device d = devicelist.get(i);
+                Log.i("RecommService", "address: " + d.ipaddress + "  SystemServer: "
+                        + d.isSystemServiceOn
+                        + "  TaskServer: " + d.isTaskExecutorOn);
+            }
+            return p.ipaddress;
+        }
+        return null;
+    }
+
+    public List<Device> getDeviceList(int kind) throws RemoteException {
+        // TODO Auto-generated method stub
+        findDevice();
+        /*
+         * Set<String> keys = DeviceList.getDevices().keySet(); List<Device> ps
+         * = new ArrayList<Device>(); for (String key : keys) {
+         * ps.add(DeviceList.getDevices().get(key)); }
+         */
+        return getServerList(kind);
+    }
+
+    public String[] getSystemServiceOnServerList() throws RemoteException {
+        return (String[]) getServerList(SYSTEM_SERVICE_LIST).toArray();
+    }
+
+    public String[] getTaskExecutorOnServerList() throws RemoteException {
+        return (String[]) getServerList(TASK_EXECUTOR_LIST).toArray();
+    }
+
+    public ArrayList<Device> getServerList(int kind) throws RemoteException {
+        ArrayList<Device> deviceList = new ArrayList<Device>();
+        Collection<Device> cp = DeviceList.getDevices().values();
+        for (Device p : cp) {
+            if (kind == SYSTEM_SERVICE_LIST) {
+                if (p.isSystemServiceOn > 0) {
+                    deviceList.add(p);
+                }
+            } else if (kind == TASK_EXECUTOR_LIST) {
+                if (p.isTaskExecutorOn > 0) {
+                    deviceList.add(p);
+                }
+            }
+        }
+        return deviceList;
+    }
+
+    /*
+     * public ArrayList<String> getServerList(int KIND) throws RemoteException{
+     * ArrayList<String> serverlist = new ArrayList<String>();
+     * Collection<Device> cp = DeviceList.getDevices().values(); for(Device p :
+     * cp){ if(KIND == SYSTEM_SERVICE_LIST){ if(p.isSystemServiceOn > 0){
+     * serverlist.add(p.ipaddress); } } else if(KIND == TASK_EXECUTOR_LIST){
+     * if(p.isTaskExecutorOn > 0){ serverlist.add(p.ipaddress); } } } return
+     * serverlist; }
+     */
+
+    private void findDevice() {
+        // TODO Auto-generated method stub
+        InetAddress broadcast = getBroadcastIp();
+        Log.i("RecommService", "broadcast: " + broadcast.toString());
+        sender = new RecommenderUDPSender(broadcast);
+        sender.start();
+    }
+
+    public InetAddress getBroadcastIp() {
+        try {
+            WifiManager mWifi = (WifiManager) mContext
+                    .getSystemService(Context.WIFI_SERVICE);
+            WifiInfo info = mWifi.getConnectionInfo();
+
+            DhcpInfo dhcp = mWifi.getDhcpInfo();
+
+            int broadcast = (dhcp.ipAddress & dhcp.netmask) | ~dhcp.netmask;
+
+            byte[] quads = new byte[4];
+            for (int k = 0; k < 4; k++)
+                quads[k] = (byte) ((broadcast >> k * 8) & 0xFF);
+
+            // Log.d("UDP", "main ipadd1 = : " + dhcp.ipAddress);
+            // Log.d("UDP", "main ipadd2 = : " + dhcp.netmask);
+            Log.d("UDP", "broadcast ip = : " + InetAddress.getByAddress(quads));
+            return InetAddress.getByAddress(quads);
+        } catch (Exception e) {
+
+        }
+        return null;
+    }
+
+    //collaboroid
+    //String getHaveDexFiles();
+    //void addHaveDexFiles(String dexFiles);
+    public String getHaveDexFiles(int deviceNum){
+        Log.d("SBJSBJ", "SBJSBJ getHaveDexFiles [DeviceManagementService]");
+        //Device d = cachedActivityResourceDevices.get(deviceNum);
+        //Log.d("SBJSBJ", "SBJSBJ getHaveDexFiles [DeviceManagementService] HaveDexFiles : " + d.HaveDexFiles);
+        return "";
+    }
+
+    public void addHaveDexFiles(int deviceNum, String dexFiles){
+        Log.d("SBJSBJ", "SBJSBJ addHaveDexFiles [DeviceManagementService]");
+        //Log.d("SBJSBJ", "SBJSBJ addHaveDexFiles [DeviceManagementService] size : " + cachedActivityDevices.size());
+        //cachedActivityResourceDevices.get(deviceNum).HaveDexFiles += "@" + dexFiles;
+    }
+
+    //samd
+    //initialize
+
+
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderPeerCompare.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderPeerCompare.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderPeerCompare.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderPeerCompare.java	2017-01-29 02:51:16.473854000 +0900
@@ -0,0 +1,16 @@
+package com.android.server.devicemanagement;
+
+import java.util.Comparator;
+
+import android.service.devicemanagement.Device;
+
+public class RecommenderPeerCompare implements Comparator<Device> {
+
+	@Override
+	public int compare(Device device1, Device device2) {
+		// TODO Auto-generated method stub
+		return device2.idleCpu.compareTo(device1.idleCpu);
+	}
+
+
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderTCPReceiver.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderTCPReceiver.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderTCPReceiver.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderTCPReceiver.java	2017-01-29 02:51:16.477854000 +0900
@@ -0,0 +1,39 @@
+package com.android.server.devicemanagement;
+
+import android.util.Log;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class RecommenderTCPReceiver extends Thread {
+	public static final int PORT = 9050;
+
+	public void run() {
+		ServerSocket sc;
+		try {
+			sc = new ServerSocket(PORT + 1);
+			Log.i("TCP Receiver", "waiting for a client to join: ");
+			try {
+				while (true) {
+					Socket returnSocket = sc.accept();
+					Log.i("TCP Receiver", "return from "
+                            + returnSocket.getInetAddress().getHostAddress());
+//					System.out.println("return from " + returnSocket.getInetAddress().getAddress());
+					ReturnThread rt = new ReturnThread(returnSocket);
+					rt.start();
+				}
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			} finally {
+				sc.close();
+			}
+
+		} catch (IOException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPReceiver.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPReceiver.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPReceiver.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPReceiver.java	2017-01-29 02:51:16.477854000 +0900
@@ -0,0 +1,203 @@
+package com.android.server.devicemanagement;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+import android.app.Application;
+import android.content.Context;
+import android.os.Build;
+import android.provider.Settings.Secure;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+
+public class RecommenderUDPReceiver extends Thread {
+	public static final int PORT = 9050;
+	public InetAddress broadcastip;
+	Context mContext;
+	
+	public RecommenderUDPReceiver(InetAddress broadcastip, Context context) {
+		this.broadcastip = broadcastip;
+		this.mContext = context;
+	}
+
+	public static String getIpaddress() {
+		// TODO Auto-generated method stub
+		try {
+			for (Enumeration<NetworkInterface> en = NetworkInterface
+					.getNetworkInterfaces(); en.hasMoreElements();) {
+				NetworkInterface intf = (NetworkInterface) en.nextElement();
+				for (Enumeration<InetAddress> enumIpaddr = intf
+						.getInetAddresses(); enumIpaddr.hasMoreElements();) {
+					InetAddress inetAddress = (InetAddress) enumIpaddr
+							.nextElement();
+					if (!inetAddress.isLoopbackAddress()
+							&& inetAddress instanceof Inet4Address) {
+						return inetAddress.getHostAddress();
+					}
+				}
+			}
+		} catch (SocketException e) {
+		}
+		return null;
+	}
+	public String getWifiMacAddress(){
+		Process p;
+		try {
+			p = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address");
+			BufferedReader br = new BufferedReader(new InputStreamReader(
+					p.getInputStream()));
+			String line = null;
+			line = br.readLine();
+			if(!line.isEmpty()){
+				return line;
+			}
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+
+	}
+	public double cpuUsage() {
+		try {
+			Process p = Runtime.getRuntime().exec("cat /proc/stat");
+			BufferedReader br = new BufferedReader(new InputStreamReader(
+					p.getInputStream()));
+			String line = null;
+
+			while ((line = br.readLine()) != null) {
+				if (line.contains("cpu ")) {
+					System.out.println(line);
+					String[] temp = line.split(" ");
+					double total_cpu = 0;
+					for (int i = 2; i < 6; i++)
+						total_cpu = Double.parseDouble(temp[i]) + total_cpu;
+
+					double idle = Double.parseDouble(temp[5]);
+					double result = (idle / total_cpu) * 100;
+
+					return Math.round(result);
+				}
+			}
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return -1;
+	}
+	
+    public String getDeviceName() {
+        /*String manufacturer = Build.MANUFACTURER;
+        String model = Build.MODEL;
+        if (model.startsWith(manufacturer)) {
+            return capitalize(model);
+        } else {
+            return capitalize(manufacturer) + " " + model;
+        }*/
+//        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+//        return telephonyManager.getDeviceId().substring(11);
+        
+        //final String deviceId = ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
+        
+    	
+    	return capitalize(Build.SERIAL);
+    	
+    	/*
+        String deviceId = Secure.getString(mContext.getContentResolver(),
+                Secure.ANDROID_ID); 
+        
+        Log.d("UDP", deviceId);
+        
+        if (deviceId != null) {
+            return capitalize(deviceId);
+        } else {
+            return capitalize(Build.SERIAL);
+        }*/
+    }
+
+    private String capitalize(String s) {
+        if (s == null || s.length() == 0) {
+            return "";
+        }
+        char first = s.charAt(0);
+        if (Character.isUpperCase(first)) {
+            return s;
+        } else {
+            return Character.toUpperCase(first) + s.substring(1);
+        }
+    }
+	
+	
+	@Override
+	public void run() {
+		// TODO Auto-generated method stub
+		DatagramSocket socket = null;
+		try {
+			socket = new DatagramSocket(PORT);
+			socket.setBroadcast(true);
+			// socket.setSoTimeout(5000);
+			byte[] buf = new byte[4096];
+
+			while (true) {
+				try {
+					DatagramPacket receivepacket = new DatagramPacket(buf,
+							buf.length);
+
+					Log.i("UDP Receiver", "WAITING UDP BROADCAST");
+					socket.receive(receivepacket);
+
+					InetAddress returnAddress = receivepacket.getAddress();
+					String message = new String(receivepacket.getData()).trim();
+
+					Log.i("UDP Receiver", "Got udp broadcast from "
+							+ returnAddress.getHostAddress() + ", msg : " + message);
+
+					String ipaddress = getIpaddress();
+					double idlecpu = cpuUsage();
+					String macAddr = getWifiMacAddress();
+//					android.provider.Settings.Global.putInt(, name, value)
+//					int isCollaboroidOn = android.provider.Settings.Global.getInt(mContext.getContentResolver(), android.provider.Settings.Global.COLLABOROID_ON, 0);
+					int isCollaboroidOn = 1;
+					int taskExecutorOn = 0;
+					
+					String result = macAddr + "_" + ipaddress + "_" + idlecpu + "_" + getDeviceName() + "_" + String.valueOf(isCollaboroidOn) + "_" + String.valueOf(taskExecutorOn);
+
+					Log.i(DeviceManagementService.TAG, "msg: " + result);
+
+					// buf = result.getBytes();
+
+					Socket returnInfo = new Socket(returnAddress,
+							PORT + 1);
+					OutputStream out = returnInfo.getOutputStream();
+					DataOutputStream dos = new DataOutputStream(out);
+
+					dos.writeUTF(result);
+					Log.i("UDP Receiver", "return to " + returnAddress
+							+ "  msg " + result);
+					returnInfo.close();
+					dos.close();
+
+				} catch (Exception e) {
+					Log.e(DeviceManagementService.TAG, "UDP receiver error: ");
+					e.getStackTrace();
+				}
+			}
+
+		} catch (Exception e) {
+
+		} finally {
+			socket.close();
+		}
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPSender.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPSender.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPSender.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/RecommenderUDPSender.java	2017-01-29 02:51:16.473854000 +0900
@@ -0,0 +1,80 @@
+package com.android.server.devicemanagement;
+
+import android.util.Log;
+
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+
+public class RecommenderUDPSender extends Thread {
+	public static final int PORT = 9050;
+	public InetAddress broadcastIp;
+
+	public RecommenderUDPSender(InetAddress broadcastIp) {
+		this.broadcastIp = broadcastIp;
+	}
+
+	@Override
+	public void run() {
+		// TODO Auto-generated method stub
+		String return_msg = null;
+		try {
+
+			DatagramSocket send_socket = new DatagramSocket();
+//			DatagramSocket receive_socket = new DatagramSocket(PORT+1);
+			send_socket.setBroadcast(true);
+
+			byte[] buf = new byte[4096];
+			buf = ("ip/cpu").getBytes(); 
+
+			DatagramPacket sendpacket = new DatagramPacket(buf, buf.length,
+					this.broadcastIp, PORT);
+
+			send_socket.send(sendpacket);
+			Log.i("UDPSender", "Send:"+ new String(buf).trim());
+			
+//			
+//			
+//			ServerSocket sc = new ServerSocket(PORT+1);
+//			Socket returnSocket = sc.accept();
+//			System.out.println("return from" + returnSocket.getInetAddress().getAddress());
+//			ReturnThread rt = new ReturnThread(returnSocket);
+//			rt.start();
+			
+//			
+//			InputStream in = returnSocket.getInputStream();
+//			DataInputStream dis = new DataInputStream(in);
+////			
+//			
+//			DatagramPacket receviePacket = new DatagramPacket(buf, buf.length);
+//			receive_socket.receive(receviePacket);
+	
+//			return_msg = new String(receviePacket.getData())+"";
+//			
+//			Log.i(RecommenderService.TAG, "udp return msg: " + return_msg);
+//
+//			String[] temp2 = return_msg.split("_");
+//			String ipaddress = temp2[0];
+//			String idlecpu = temp2[1];
+//			
+//			Log.i(RecommenderService.TAG, "return ip:" + ipaddress + "return cpu usage:" + idlecpu);
+//
+//			Peer p = new Peer(ipaddress, idlecpu);
+//			
+//			Log.i(RecommenderService.TAG, "peer:" + p.toString());
+//			
+//			
+//			PeerList.getPeers().add(p);
+
+			send_socket.close();
+			
+//			receive_socket.close();
+//			sc.close();
+//			dis.close();
+//			returnSocket.close();
+
+		} catch (Exception e) {
+			Log.e("UDP", "S: Error", e);
+		}
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/ReturnThread.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/ReturnThread.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/devicemanagement/ReturnThread.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/devicemanagement/ReturnThread.java	2017-01-29 02:51:16.473854000 +0900
@@ -0,0 +1,57 @@
+
+package com.android.server.devicemanagement;
+
+import android.service.devicemanagement.Device;
+import android.service.devicemanagement.DeviceList;
+import android.util.Log;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+
+public class ReturnThread extends Thread {
+    public static final int PORT = 9050;
+
+    private Socket socket;
+
+    public ReturnThread(Socket socket) {
+        this.socket = socket;
+    }
+
+    public void run() {
+        try {
+            InputStream in = socket.getInputStream();
+            DataInputStream dis = new DataInputStream(in);
+            String return_msg = dis.readUTF();
+
+            String[] temp2 = return_msg.split("_");
+            String macAddr = temp2[0];
+            String ipaddress = temp2[1];
+            String idlecpu = temp2[2];
+            String deviceName = temp2[3];
+            int isCollaboroidOn = Integer.parseInt(temp2[4]);
+            int isTaskExecutor = Integer.parseInt(temp2[5]);
+
+            Log.i("ReturnThread", "device: " + macAddr + "  return ip: " + ipaddress
+                    + "  return cpu usage: " + idlecpu);
+            
+            Device p = new Device(ipaddress, idlecpu, deviceName, isCollaboroidOn, isTaskExecutor);
+            Log.i("ReturnThread", "device name: " + macAddr + " / peer: " + p.toString());
+            
+            if (ipaddress.equals(RecommenderUDPReceiver.getIpaddress())){
+                Log.i("ReturnThread", "Return from own device: " + ipaddress + ", " + InetAddress.getLocalHost().getHostAddress());
+            }
+            else{
+                DeviceList.getDevices().put(macAddr, p);
+                Log.i("ReturnThread", "Added to Peer list " + ipaddress + ", " + RecommenderUDPReceiver.getIpaddress());
+            }
+            
+            socket.close();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/DistributedComputingService.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/DistributedComputingService.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/DistributedComputingService.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/DistributedComputingService.java	2017-01-29 02:51:16.789858000 +0900
@@ -0,0 +1,93 @@
+package com.android.server.distribute;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.service.distribute.IDistributedComputingService;
+import android.util.Log;
+
+public class DistributedComputingService extends IDistributedComputingService.Stub
+{
+	private static final String TAG = "DistributedComputing";
+	// private static final int SERVERPORT = 55555;
+
+	Context mContext;
+
+	private JobManager mJobManager;
+	
+	// For Server
+	private TaskExecutor mTaskExecutor = null;
+	private Thread taskExecutorThread = null;
+
+	public DistributedComputingService(Context context)
+	{
+		mContext = context;
+	}
+
+
+	@Override
+	public void startJobManager(String ip)
+	{
+		if(mJobManager == null)
+		{
+			ArrayList<String> ip_list = new ArrayList<String>();
+			ip_list.add(ip);
+			mJobManager = new JobManager(ip_list);
+		}
+		else
+			Log.d(TAG, "HAHA?");
+	}
+	
+	@Override
+	public void stopJobManager()
+	{
+		
+	}
+	
+	@Override
+	public void startTaskExecutor()
+	{
+		if(taskExecutorThread == null)
+		{
+			mTaskExecutor = new TaskExecutor();
+			taskExecutorThread = new Thread(mTaskExecutor);
+			
+			taskExecutorThread.start();
+		}
+	}
+	
+	@Override
+	public void stopTaskExecutor()
+	{
+		if(taskExecutorThread != null)
+		{
+			mTaskExecutor.terminate();
+			taskExecutorThread.interrupt();
+		}
+	}
+
+	@Override
+	public int sum(int start, int end)
+	{
+		// TODO Auto-generated method stub
+		ArrayList<Object> paras = new ArrayList<Object>();
+		paras.add(start);
+		paras.add(end);
+		
+		//mJobManager.submitTask(new TaskRequest("com.android.server.distribute.Sum", paras));
+		mJobManager.submitTask(new TaskRequest("SUM", paras));
+		
+		Log.d(TAG, "result: " + mJobManager.executeJob()[0]);
+		
+		return 432;
+	}
+
+
+
+	@Override
+	public void testOperation()
+	{
+		// TODO Auto-generated method stub
+		sum(10, 50);
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/JobManager.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/JobManager.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/JobManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/JobManager.java	2017-01-29 02:51:16.793858000 +0900
@@ -0,0 +1,291 @@
+package com.android.server.distribute;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import android.util.Log;
+
+public class JobManager 
+{
+	private static final String TAG = "JobManager";
+	private static final int DISTRIBUTED_COMPUTING_PORT = 55556;
+	
+	int node_num = 0, task_num = 0, total_task_num = 0;
+	
+	ArrayList<String> nodes;
+	//private final IRecommender mService;
+	
+	// for node performance
+	long node_info[][];
+	int node_perf_ratio[];
+	
+	long total_runtime = 0;
+	boolean isrunning = false;
+
+	int task_length, taskinfo_length;
+
+	AtomicInteger current_task = new AtomicInteger(0);
+	
+	ArrayList<TaskRequest> tasks;
+	
+	public JobManager(ArrayList<String> ip_list)
+	{
+		//mService = IRecommender.Stub.asInterface(ServiceManager.getService("recommender"));
+		
+		//nodes = mService.getPeerList();
+		nodes = ip_list;
+		node_num = nodes.size();
+		
+		node_info = new long[node_num][2]; // [][0]=task_count, [][1]=runtime
+		node_perf_ratio = new int[node_num];
+		
+		tasks = new ArrayList<TaskRequest>();
+		
+		Log.d(TAG, nodes.toString());
+		Log.d(TAG, "node_num: " + node_num);
+	}
+	
+	public void submitTask(TaskRequest task)
+	{
+		tasks.add(task);
+		task_num++;
+		Log.d(TAG, tasks.toString());
+	}
+	
+	/*public <T> Task submitTask(T t)
+	{
+		Task task = (Task)t;
+		
+		return task;
+	}*/
+	
+	public Object[] executeJob()
+	{
+		Thread node_thread[] = new Thread[node_num];
+		final long[][] job_info = new long[node_num][2];
+		
+		long begin, terminate;
+		
+		final Object[] results = new Object[task_num];
+		
+		// calculate node performance
+		if(node_perf_ratio[0] == 0)
+			executeTestcode();
+		else
+			for(int i=1; i<node_num; i++)
+				node_perf_ratio[i] = (int) Math.round((double)((float)node_info[i][1]/(float)node_info[i][0]) / ((float)node_info[0][1]/(float)node_info[0][0]));
+		
+		begin = System.currentTimeMillis();
+		try
+		{
+			// create thread for each node
+			for(int i = 0; i < node_num; i++)
+			{
+				final int num = i;
+				node_thread[i] = new Thread(new Runnable()
+				{
+					public void run()
+					{
+						long start=0, end=0;
+						job_info[num][0] = 0;
+						job_info[num][1] = 0;
+						
+						if(nodes.get(num).equals("localhost"))
+						{
+							int running_task = 0;// current_task.getAndIncrement();
+							
+							while((running_task=current_task.getAndIncrement()) < task_num)
+							{
+								if((task_num-running_task) < node_perf_ratio[num])
+								{
+									Log.d(TAG, "remain task: " + (task_num-running_task));
+									task_num++;
+									tasks.add(tasks.get(running_task));				
+									break;
+								}
+							
+								start = System.currentTimeMillis();
+	
+								//tasks.get(running_task).setValue(tasks.get(running_task).getTask().execute());
+						
+								end = System.currentTimeMillis();		
+								
+								job_info[num][0]++;
+								job_info[num][1]+=(end-start);
+							}
+						}
+						else
+						{
+							try
+							{
+								Socket node = new Socket(nodes.get(num), DISTRIBUTED_COMPUTING_PORT);
+
+								ObjectOutputStream oos = new ObjectOutputStream(node.getOutputStream());
+								ObjectInputStream ois = new ObjectInputStream(node.getInputStream());
+
+								int running_task=0;
+								
+								while((running_task=current_task.getAndIncrement()) < task_num)
+								{
+									Log.d(TAG, "running_task: " + running_task);
+									Log.d(TAG, "task_num: " + task_num);
+									
+									if((task_num-running_task) < node_perf_ratio[num])
+									{
+										Log.d(TAG, "remain task: " + (task_num-running_task));
+										task_num++;
+										tasks.add(tasks.get(running_task));				
+										break;
+									}
+									
+									start = System.currentTimeMillis();
+	
+									oos.writeObject(tasks.get(running_task));
+									//oos.flush();
+
+									//tasks.get(running_task).setValue(ois.readObject());
+									//reois.readObject()
+									
+									//results.set(running_task, ois.readObject());
+									results[running_task] = ois.readObject();
+									
+									end = System.currentTimeMillis();
+									
+									job_info[num][0]++;
+									job_info[num][1]+=(end-start);
+								}
+								oos.writeObject(new TaskRequest("BYE", null));
+								node.close();
+							}
+							catch (Exception e)
+							{
+								// TODO Auto-generated catch block
+								Log.e(TAG, "ExecuteJob exception:");
+								e.printStackTrace();
+							}
+						}
+					}
+				});
+				node_thread[i].start();
+			}
+			for(int i = 0; i < node_num; i++)
+				node_thread[i].join();
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		
+		terminate = System.currentTimeMillis();
+		tasks.clear();
+		current_task.set(0);
+		collect_info(job_info);
+		total_runtime += (terminate - begin);
+		isrunning = false;
+		total_task_num += task_num;
+		task_num = 0;
+		
+		return results;
+	}
+	
+	public void executeTestcode()
+	{
+		final ArrayList<String> temp_list = new ArrayList<String>();
+		final ArrayList<Long> testcode_runtime = new ArrayList<Long>();
+		
+		final ArrayList<Object> paras = new ArrayList<Object>();
+		paras.add(10);
+		paras.add(100000);
+		
+		Thread node_thread[] = new Thread[node_num];
+		
+		try
+		{
+			// create thread for each node
+			for(int i=0; i<node_num; i++)
+			{
+				final int num = i;
+				node_thread[i] = new Thread(new Runnable()
+				{
+					public void run()
+					{
+						try
+						{
+							long start, end;
+							Socket node = new Socket(nodes.get(num), DISTRIBUTED_COMPUTING_PORT);
+
+							ObjectOutputStream oos = new ObjectOutputStream(node.getOutputStream());
+							ObjectInputStream ois = new ObjectInputStream(node.getInputStream());
+
+							start = System.currentTimeMillis();
+
+							oos.writeObject(new TaskRequest("SUM", paras));
+							ois.readObject();
+							
+							end = System.currentTimeMillis();
+
+							temp_list.add(nodes.get(num));
+							testcode_runtime.add(end-start);
+							
+							oos.writeObject(new TaskRequest("BYE", null));
+							node.close();
+						}
+						catch (Exception e)
+						{
+							// TODO Auto-generated catch block
+							Log.e(TAG, "TestCode exception:");
+							e.printStackTrace();
+						}											
+					}
+				});
+				node_thread[i].start();
+			}		
+			for(int i=0; i<node_num; i++)
+				node_thread[i].join();		
+			Log.d(TAG, "all finish!" + node_num);
+		}
+		catch(Exception e)
+		{
+			e.printStackTrace();
+		}
+		
+		nodes = temp_list;
+		
+		for(int i=0; i<node_num; i++)
+    		node_perf_ratio[i] = (int) Math.round((double)testcode_runtime.get(i) / testcode_runtime.get(0));
+	}
+	
+	public void collect_info(long[][] job_info)
+	{
+		for(int i = 0; i < node_num; i++)
+		{
+			node_info[i][0] += job_info[i][0];
+			node_info[i][1] += job_info[i][1];
+		}
+	}
+
+	public void print_info()
+	{
+		System.out
+				.println(" task count | % of all tasks | task time sum | time per task | job server");
+
+		for(int i = 0; i < node_num; i++)
+			System.out.printf(
+					"%11d |        %7.2f |     %9.3f |  %12.6f | %s\n",
+					node_info[i][0],
+					(((float) node_info[i][0] / (float) total_task_num)) * 100,
+					(float) node_info[i][1] / 1000,
+					((float) node_info[i][1] / (float) node_info[i][0]) / 1000,
+					nodes.get(i));
+
+		System.out.println("\ntotal runtime is " + total_runtime / 1000 + "."
+				+ total_runtime % 1000 + "sec");
+
+		System.out.println("task_length : " + task_length + "\ntaskinfo_length : "
+				+ taskinfo_length);
+
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/NodeManager.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/NodeManager.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/NodeManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/NodeManager.java	2017-01-29 02:51:16.793858000 +0900
@@ -0,0 +1,24 @@
+package com.android.server.distribute;
+
+import android.os.ServiceManager;
+import android.service.devicemanagement.IDeviceManagementService;
+
+
+public class NodeManager 
+{
+	private final IDeviceManagementService mService;
+	
+	public NodeManager()
+	{
+		mService = IDeviceManagementService.Stub.asInterface(ServiceManager.getService("devicemanager"));
+	}
+	
+	/*public ArrayList<String> getNodes()
+	{
+		List<Peer> peers = mService.getPeerList();
+		
+		ArrayList<String> nodes = new ArrayList<String>();
+		
+		nodes.addAll(peers.)
+	}*/
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/Sum.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/Sum.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/Sum.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/Sum.java	2017-01-29 02:51:16.789858000 +0900
@@ -0,0 +1,28 @@
+package com.android.server.distribute;
+
+public class Sum implements Task<Integer>
+{
+	private final int min, max;
+	
+	public Sum(int min, int max)
+	{
+		this.min = min;
+		this.max = max;
+	}
+
+	public Integer execute()
+	{
+		return sum(min, max);
+	}
+	
+	public static int sum(int min, int max)
+	{
+		int i=0;
+		int result = 0;
+		
+		for(i=min; i<max; i++)
+			result += i;
+		
+		return result;
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/TaskExecutor.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/TaskExecutor.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/TaskExecutor.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/TaskExecutor.java	2017-01-29 02:51:16.793858000 +0900
@@ -0,0 +1,137 @@
+package com.android.server.distribute;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import android.util.Log;
+
+public class TaskExecutor extends Thread
+{
+	private static final String TAG = "TaskExecutor";
+	private static final int DISTRIBUTED_COMPUTING_PORT = 55556;
+	
+	long execution_time = 0;
+	
+	ServerSocket serverSocket;
+	Socket socket;
+	
+	ObjectOutputStream outToClient;
+	ObjectInputStream inFromClient;
+	
+	TaskRequest task;
+	Object result;
+	
+	private static boolean isConnected = false;
+	
+	public void terminate()
+	{
+		try
+		{
+			outToClient.close();
+			inFromClient.close();
+			socket.close();
+		}
+		catch(IOException e)
+		{
+			e.printStackTrace();
+		}
+	}
+	
+	//Socket client;
+	@Override
+	public void run()
+	{
+		try
+		{
+			socket = null;
+			serverSocket = new ServerSocket(DISTRIBUTED_COMPUTING_PORT);
+			
+			
+			
+			long start, end;
+			
+			while (!Thread.currentThread().isInterrupted())
+			{
+				Log.d(TAG, "TaskExecutor successfully started!");
+				socket = serverSocket.accept();
+				isConnected = true;
+				Log.d(TAG, socket.getInetAddress() + "connected.");
+				
+				outToClient = new ObjectOutputStream(socket.getOutputStream());
+				inFromClient = new ObjectInputStream(socket.getInputStream());
+				
+				while(isConnected)
+				{
+					task = (TaskRequest)inFromClient.readObject();
+					Log.d(TAG, "Request!!!!");
+					
+					start = System.currentTimeMillis();
+					
+					result = handleTask(task);
+					Log.d(TAG, "result: " + result);
+					
+					end = System.currentTimeMillis();
+					
+					if(result != null)
+						outToClient.writeObject(result);
+					//outToClient.reset();
+					
+					execution_time += (end-start);
+					
+					//outToClient.writeObject(handleTask((TaskRequest)inFromClient.readObject()));
+					
+					/*
+					Class<?> cls = Class.forName(task.name);
+					Object obj = cls.newInstance();
+					
+					Method method = cls.getDeclaredMethod("execute", Integer.class);
+					method.invoke(obj, 4);*/
+				}
+				
+				outToClient.close();
+				inFromClient.close();
+				socket.close();
+				
+				outToClient = null;
+				inFromClient = null;
+				socket = null;
+				task = null;
+				result = null;
+				execution_time = 0;
+				//Toast.makeText(mContext, "Client Connected: " + socket.getInetAddress().getHostAddress(), Toast.LENGTH_SHORT).show();
+				
+			}
+			//socket.close();
+			
+		} 
+		catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} 
+		catch (ClassNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	private Object handleTask(TaskRequest task)
+	{
+		Object result = null;
+		
+		if(task.name.equals("SUM"))
+		{
+			Log.d(TAG, "SUM!!!");
+			result = new Sum((Integer)task.parameters.get(0), (Integer)task.parameters.get(1)).execute();
+		}
+		else if(task.name.equals("BYE"))
+		{
+			Log.d(TAG, "BYE!!!");
+			isConnected = false;
+		}
+		
+		return result;
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/Task.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/Task.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/Task.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/Task.java	2017-01-29 02:51:16.789858000 +0900
@@ -0,0 +1,6 @@
+package com.android.server.distribute;
+
+public interface Task<T> 
+{
+	T execute();
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/TaskRequest.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/TaskRequest.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/distribute/TaskRequest.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/distribute/TaskRequest.java	2017-01-29 02:51:16.789858000 +0900
@@ -0,0 +1,17 @@
+package com.android.server.distribute;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class TaskRequest implements Serializable
+{
+	private static final long serialVersionUID = 1L;
+	public String name;
+	public ArrayList<Object> parameters;
+	
+	public TaskRequest(String name, ArrayList<Object> parameters)
+	{
+		this.name = name;
+		this.parameters = parameters;
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/location/RemoteLocationProvider.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/location/RemoteLocationProvider.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/location/RemoteLocationProvider.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/location/RemoteLocationProvider.java	2017-01-29 02:51:16.753857000 +0900
@@ -0,0 +1,153 @@
+package com.android.server.location;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+import com.android.internal.location.ProviderProperties;
+import com.android.internal.location.ProviderRequest;
+
+import android.content.Context;
+import android.location.Criteria;
+import android.location.LocationManager;
+import android.location.LocationProvider;
+import android.os.Bundle;
+import android.os.ServiceManager;
+import android.os.WorkSource;
+import android.service.remote.IRemoteService;
+
+public class RemoteLocationProvider implements LocationProviderInterface 
+{
+	//private final String mName;
+    private final ProviderProperties mProperties = new ProviderProperties(
+            false, false, false, false, false, false, false,
+            Criteria.POWER_LOW, Criteria.ACCURACY_COARSE);
+    
+    //private final ILocationManager mLocationManager;
+
+    //private final Location mLocation;
+    private final Bundle mExtras = new Bundle();
+
+    private int mStatus;
+    private long mStatusUpdateTime;
+    private boolean mHasLocation;
+    private boolean mHasStatus;
+    private boolean mEnabled;
+    
+    private IRemoteService mRemoteService;
+
+    private static final String TAG = "RemoteLocationProvider";
+
+    public RemoteLocationProvider()
+    {
+    	mRemoteService = IRemoteService.Stub.asInterface(ServiceManager
+				.getService(Context.REMOTE_SERVICE));
+    }
+    
+    /*public RemoteLocationProvider(String name, ILocationManager locationManager,
+            ProviderProperties properties) {
+        if (properties == null) throw new NullPointerException("properties is null");
+
+        mName = name;
+        mLocationManager = locationManager;
+        mProperties = properties;
+        mLocation = new Location(name);
+    }*/
+
+    @Override
+    public String getName() {
+        return LocationManager.REMOTE_PROVIDER;
+    }
+
+    @Override
+    public ProviderProperties getProperties() {
+        return mProperties;
+    }
+
+    @Override
+    public void disable() {
+        mEnabled = false;
+    }
+
+    @Override
+    public void enable() {
+    	//if(mRemoteService)
+        mEnabled = true;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return mEnabled;
+    }
+
+    @Override
+    public int getStatus(Bundle extras) {
+        if (mHasStatus) {
+            extras.clear();
+            extras.putAll(mExtras);
+            return mStatus;
+        } else {
+            return LocationProvider.AVAILABLE;
+        }
+    }
+
+    @Override
+    public long getStatusUpdateTime() {
+        //return mStatusUpdateTime;
+    	return -1;
+    }
+
+    /*public void setLocation(Location l) {
+        mLocation.set(l);
+        mHasLocation = true;
+        if (mEnabled) {
+            try {
+                mLocationManager.reportLocation(mLocation, false);
+            } catch (RemoteException e) {
+                Log.e(TAG, "RemoteException calling reportLocation");
+            }
+        }
+    }*/
+
+    /*public void clearLocation() {
+        mHasLocation = false;
+    }
+
+    public void setStatus(int status, Bundle extras, long updateTime) {
+        mStatus = status;
+        mStatusUpdateTime = updateTime;
+        mExtras.clear();
+        if (extras != null) {
+            mExtras.putAll(extras);
+        }
+        mHasStatus = true;
+    }
+
+    public void clearStatus() {
+        mHasStatus = false;
+        mStatusUpdateTime = 0;
+    }*/
+
+    @Override
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        dump(pw, "");
+    }
+
+    public void dump(PrintWriter pw, String prefix) {
+        /*pw.println(prefix + mName);
+        pw.println(prefix + "mHasLocation=" + mHasLocation);
+        pw.println(prefix + "mLocation:");
+        mLocation.dump(new PrintWriterPrinter(pw), prefix + "  ");
+        pw.println(prefix + "mHasStatus=" + mHasStatus);
+        pw.println(prefix + "mStatus=" + mStatus);
+        pw.println(prefix + "mStatusUpdateTime=" + mStatusUpdateTime);
+        pw.println(prefix + "mExtras=" + mExtras);*/
+    }
+
+    @Override
+    public void setRequest(ProviderRequest request, WorkSource source) { }
+
+    @Override
+    public boolean sendExtraCommand(String command, Bundle extras) {
+        return false;
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/LocationManagerService.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/LocationManagerService.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/LocationManagerService.java	2017-09-27 02:07:57.459736001 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/LocationManagerService.java	2017-01-29 02:51:16.441854000 +0900
@@ -39,6 +39,7 @@
 import com.android.server.location.LocationRequestStatistics.PackageStatistics;
 import com.android.server.location.MockProvider;
 import com.android.server.location.PassiveProvider;
+import com.android.server.location.RemoteLocationProvider;
 
 import android.app.AppOpsManager;
 import android.app.PendingIntent;
@@ -2602,6 +2603,33 @@
             mockProvider.clearStatus();
         }
     }
+    
+    @Override
+	public void setRemoteProviderEnabled(boolean enabled)
+			throws RemoteException
+	{
+    	synchronized (mLock) 
+    	{
+    		Log.d(TAG, "Enabled: " + enabled);
+    		
+    		long identity = Binder.clearCallingIdentity();
+            if (enabled) {
+            	RemoteLocationProvider provider = new RemoteLocationProvider();
+                addProviderLocked(provider);
+                provider.enable();
+                mEnabledProviders.add(provider.getName());
+                mDisabledProviders.remove(provider.getName());
+            } else {
+            	LocationProviderInterface provider = mProvidersByName.get(LocationManager.REMOTE_PROVIDER);
+            	removeProviderLocked(provider);
+                provider.disable();
+                mEnabledProviders.remove(provider.getName());
+                mDisabledProviders.add(provider.getName());
+            }
+            updateProvidersLocked();
+            Binder.restoreCallingIdentity(identity);
+        }
+	}
 
     private void log(String log) {
         if (Log.isLoggable(TAG, Log.VERBOSE)) {
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/pm/Installer.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/pm/Installer.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/pm/Installer.java	2017-09-27 02:07:57.519736000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/pm/Installer.java	2017-08-05 14:50:48.811606000 +0900
@@ -120,7 +120,63 @@
         builder.append(uid);
         return mInstaller.execute(builder.toString());
     }
+    
+    // ADDED FOR COLLABOROID
+    public int aapt_package(String resPath, String manifestPath, String outputApk)
+    {
+    	StringBuilder builder = new StringBuilder("aaptpackage");
+    	builder.append(' ');
+        builder.append(resPath);
+        builder.append(' ');
+        builder.append(manifestPath);
+        builder.append(' ');
+        builder.append(outputApk);
+        
+        return mInstaller.execute(builder.toString());
+    }
+    // ADDED FOR SAMD
+    public int aapt_package_with_assets(String resPath, String assetsPath, String manifestPath, String outputApk)
+    {
+        StringBuilder builder = new StringBuilder("aaptpackagewithassets");
+        builder.append(' ');
+        builder.append(resPath);
+        builder.append(' ');
+        builder.append(assetsPath);
+        builder.append(' ');
+        builder.append(manifestPath);
+        builder.append(' ');
+        builder.append(outputApk);
 
+        return mInstaller.execute(builder.toString());
+    }
+    
+    public int aapt_add(int type, String apkPath, String filePath)
+    {
+    	StringBuilder builder = new StringBuilder("aaptadd");
+    	builder.append(' ');
+        builder.append(type);
+    	builder.append(' ');
+        builder.append(apkPath);
+        builder.append(' ');
+        builder.append(filePath);
+        
+        return mInstaller.execute(builder.toString());
+    }
+    
+    public int makeodex(String dexPath, String outPath, String pkgName)
+    {
+    	StringBuilder builder = new StringBuilder("makeodex");
+        builder.append(' ');
+        builder.append(dexPath);
+        builder.append(' ');
+        builder.append(outPath);
+        builder.append(' ');
+        builder.append(pkgName);
+        
+        return mInstaller.execute(builder.toString());
+    }
+    // ADDED FOR COLLABOROID
+    
     public int movedex(String srcPath, String dstPath, String instructionSet) {
         if (!isValidInstructionSet(instructionSet)) {
             Slog.e(TAG, "Invalid instruction set: " + instructionSet);
@@ -136,6 +192,21 @@
         builder.append(instructionSet);
         return mInstaller.execute(builder.toString());
     }
+    
+    // ADDED FOR COLLABOROID
+    public int movefile(String srcPath, String dstPath) {
+        /*if (!isValidInstructionSet(instructionSet)) {
+            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
+            return -1;
+        }*/
+
+        StringBuilder builder = new StringBuilder("movefile");
+        builder.append(' ');
+        builder.append(srcPath);
+        builder.append(' ');
+        builder.append(dstPath);
+        return mInstaller.execute(builder.toString());
+    }
 
     public int rmdex(String codePath, String instructionSet) {
         if (!isValidInstructionSet(instructionSet)) {
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerSession.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerSession.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerSession.java	2017-09-27 02:07:57.519736000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerSession.java	2017-07-13 15:02:57.242645000 +0900
@@ -60,6 +60,7 @@
 import android.system.StructStat;
 import android.util.ArraySet;
 import android.util.ExceptionUtils;
+import android.util.Log;
 import android.util.MathUtils;
 import android.util.Slog;
 
@@ -462,6 +463,7 @@
     }
 
     private void commitLocked() throws PackageManagerException {
+        Log.d("experiment install time", "commitLocked call");
         if (mDestroyed) {
             throw new PackageManagerException(INSTALL_FAILED_INTERNAL_ERROR, "Session destroyed");
         }
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java	2017-09-27 02:07:57.527736000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java	2017-09-12 13:14:50.537101000 +0900
@@ -226,6 +226,7 @@
 import com.android.server.pm.PermissionsState.PermissionState;
 import com.android.server.pm.Settings.DatabaseVersion;
 import com.android.server.pm.Settings.VersionInfo;
+import com.android.server.remote.Receiver;
 import com.android.server.storage.DeviceStorageMonitorInternal;
 
 import org.xmlpull.v1.XmlPullParser;
@@ -415,7 +416,9 @@
     final ServiceThread mHandlerThread;
 
     final PackageHandler mHandler;
-
+    //SAMD
+    public static Message SAMDMessage;
+    public static File SAMDFile;
     /**
      * Messages for {@link #mHandler} that need to wait for system ready before
      * being dispatched.
@@ -1191,8 +1194,10 @@
                             if (params.startCopy()) {
                                 // We are done...  look for more work or to
                                 // go idle.
-                                if (DEBUG_SD_INSTALL) Log.i(TAG,
-                                        "Checking for more work or unbind...");
+                                if (DEBUG_SD_INSTALL) {
+                                    Log.i(TAG,
+                                            "Checking for more work or unbind...");
+                                }
                                 // Delete pending install
                                 if (mPendingInstalls.size() > 0) {
                                     mPendingInstalls.remove(0);
@@ -1300,6 +1305,7 @@
                                 i++;
                             }
                         }
+
                         size = i;
                         mPendingBroadcasts.clear();
                     }
@@ -1332,6 +1338,7 @@
                 } break;
                 case POST_INSTALL: {
                     if (DEBUG_INSTALL) Log.v(TAG, "Handling post-install for " + msg.arg1);
+
                     PostInstallData data = mRunningInstalls.get(msg.arg1);
                     mRunningInstalls.delete(msg.arg1);
                     boolean deleteOld = false;
@@ -1341,6 +1348,8 @@
                         PackageInstalledInfo res = data.res;
 
                         if (res.returnCode == PackageManager.INSTALL_SUCCEEDED) {
+
+
                             final String packageName = res.pkg.applicationInfo.packageName;
                             res.removedInfo.sendBroadcast(false, true, false);
                             Bundle extras = new Bundle(1);
@@ -1436,9 +1445,7 @@
                             EventLog.writeEvent(EventLogTags.UNKNOWN_SOURCES_ENABLED,
                                 getUnknownSourcesSettings());
                         }
-                        // Force a gc to clear up things
-                        Runtime.getRuntime().gc();
-                        // We delete after a gc for applications  on sdcard.
+
                         if (deleteOld) {
                             synchronized (mInstallLock) {
                                 res.removedInfo.args.doPostDeleteLI(true);
@@ -1739,6 +1746,7 @@
                 break;
             }
             case PackageManager.INSTALL_SUCCEEDED: {
+                //Log.d("experiment install time","[PackageManagerService] PackageManager.INSTALL_SUCCEEDED");
                 extras = new Bundle();
                 extras.putBoolean(Intent.EXTRA_REPLACING,
                         res.removedInfo != null && res.removedInfo.removedPackage != null);
@@ -2000,6 +2008,9 @@
             // code, so don't dexopt it to avoid the resulting log spew.
             alreadyDexOpted.add(frameworkDir.getPath() + "/framework-res.apk");
 
+            //collaboroid resource sharing
+
+
             // Gross hack for now: we know this file is only part of
             // the boot class path for art, so don't dexopt it to
             // avoid the resulting log spew.
@@ -2075,6 +2086,7 @@
 
             // Collected privileged system packages.
             final File privilegedAppDir = new File(Environment.getRootDirectory(), "priv-app");
+            Log.d("experiment install time","[PakcageManagerService] start scanDirLI");
             scanDirLI(privilegedAppDir, PackageParser.PARSE_IS_SYSTEM
                     | PackageParser.PARSE_IS_SYSTEM_DIR
                     | PackageParser.PARSE_IS_PRIVILEGED, scanFlags, 0);
@@ -3008,6 +3020,7 @@
         synchronized (mPackages) {
             PackageParser.Activity a = mActivities.mActivities.get(component);
 
+
             if (DEBUG_PACKAGE_INFO) Log.v(TAG, "getActivityInfo " + component + ": " + a);
             if (a != null && mSettings.isEnabledLPr(a.info, flags, userId)) {
                 PackageSetting ps = mSettings.mPackages.get(component.getPackageName());
@@ -4149,6 +4162,63 @@
         }
         return 0;
     }
+    
+    // ADDED FOR COLLABOROID
+    @Override
+    public int makeodex(String dexPath, String outPath, String pkgName)
+    {
+    	int result = 0;
+    	synchronized (mPackages)
+    	{
+    		result = mInstaller.makeodex(dexPath, outPath, pkgName);
+    	}
+    	return result;
+    }
+    
+    @Override
+    public int aaptPackage(String resPath, String manifestPath, String outputApk)
+    {
+    	int result = 0;
+    	synchronized (mPackages)
+    	{
+    		result = mInstaller.aapt_package(resPath, manifestPath, outputApk);
+    	}
+    	return result;
+    }
+
+    // ADDED FOR SAMD
+    @Override
+    public int aaptPackageWithAssets(String resPath, String assetsPath, String manifestPath, String outputApk)
+    {
+        int result = 0;
+        synchronized (mPackages)
+        {
+            result = mInstaller.aapt_package_with_assets(resPath, assetsPath, manifestPath, outputApk);
+        }
+        return result;
+    }
+    
+    @Override
+    public int aaptAdd(int type, String apkPath, String filePath)
+    {
+    	int result = 0;
+    	synchronized (mPackages)
+    	{
+    		result = mInstaller.aapt_add(type, apkPath, filePath);
+    	}
+    	return result;
+    }
+    
+    @Override
+    public int movefile(String srcPath, String dstPath)
+    {
+    	int result = 0;
+    	synchronized (mPackages)
+    	{
+    		result = mInstaller.movefile(srcPath, dstPath);
+    	}
+    	return result;
+    }
 
     @Override
     public boolean isUidPrivileged(int uid) {
@@ -5622,6 +5692,19 @@
     }
 
     private void scanDirLI(File dir, int parseFlags, int scanFlags, long currentTime) {
+        if(dir.getAbsolutePath().contains("TexasHoldem")){
+            Log.d("experiment install time","[PackageManagerService] scanDirLI TexasHoldem call");
+        }
+        if(dir.getAbsolutePath().contains("TestApp")){
+            Log.d("experiment install time","[PackageManagerService] scanDirLI TestApp call");
+        }
+        if(dir.getAbsolutePath().contains("CodeIntensive")){
+            Log.d("experiment install time","[PackageManagerService] scanDirLI CodeIntensive call");
+        }
+        if(dir.getAbsolutePath().contains("ResourseIntensive")){
+            Log.d("experiment install time","[PackageManagerService] scanDirLI ResourseIntensive call");
+        }
+
         final File[] files = dir.listFiles();
         if (ArrayUtils.isEmpty(files)) {
             Log.d(TAG, "No files in app dir " + dir);
@@ -5717,6 +5800,19 @@
             Slog.w(TAG, "PackageSetting for " + ps.name
                     + " is missing signatures.  Collecting certs again to recover them.");
         } else {
+            if(srcFile.getAbsolutePath().contains("TexasHoldem")){
+                Log.d("experiment install time", "TexasHoldem install success");
+            }
+            if(srcFile.getAbsolutePath().contains("CodeIntensive")){
+                Log.d("experiment install time", "CodeIntensive install success");
+            }
+            if(srcFile.getAbsolutePath().contains("TestApp")){
+                Log.d("experiment install time", "TestApp install success");
+            }
+            if(srcFile.getAbsolutePath().contains("ResourseIntensive")){
+                Log.d("experiment install time", "ResourseIntensive install success");
+            }
+
             Log.i(TAG, srcFile.toString() + " changed; collecting certs");
         }
 
@@ -5734,7 +5830,10 @@
      */
     private PackageParser.Package scanPackageLI(File scanFile, int parseFlags, int scanFlags,
             long currentTime, UserHandle user) throws PackageManagerException {
+
+        Log.d("experiment install time","[PackageManagerServise] scanPackageLI call");
         if (DEBUG_INSTALL) Slog.d(TAG, "Parsing: " + scanFile);
+
         parseFlags |= mDefParseFlags;
         PackageParser pp = new PackageParser();
         pp.setSeparateProcesses(mSeparateProcesses);
@@ -5748,6 +5847,10 @@
         final PackageParser.Package pkg;
         try {
             pkg = pp.parsePackage(scanFile, parseFlags);
+            
+            if(pkg.packageName.contains("Dummy"))
+        		Log.d(TAG, "DUMMY!! - volume: " + pkg.volumeUuid + "pn: " +pkg.packageName);
+            
         } catch (PackageParserException e) {
             throw PackageManagerException.from(e);
         }
@@ -6304,6 +6407,10 @@
     }
 
     private int createDataDirsLI(String volumeUuid, String packageName, int uid, String seinfo) {
+    	
+    	if(packageName.contains("Dummy"))
+    		Log.d(TAG, "DUMMY!! - volume: " + volumeUuid + "pn: " +packageName + "uid: " + uid + "seinfo: " + seinfo);
+    	
         int[] users = sUserManager.getUserIds();
         int res = mInstaller.install(volumeUuid, packageName, uid, uid, seinfo);
         if (res < 0) {
@@ -6546,6 +6653,9 @@
                 Log.d(TAG, "Scanning package " + pkg.packageName);
         }
 
+        if(pkg.packageName.contains("Dummy"))
+    		Log.d(TAG, "DUMMY!! - volume: " + pkg.volumeUuid + "pn: " +pkg.packageName);
+        
         if (mPackages.containsKey(pkg.packageName)
                 || mSharedLibraries.containsKey(pkg.packageName)) {
             throw new PackageManagerException(INSTALL_FAILED_DUPLICATE_PACKAGE,
@@ -9571,12 +9681,14 @@
         final Message msg = mHandler.obtainMessage(INIT_COPY);
         msg.obj = new InstallParams(origin, null, observer, installFlags, installerPackageName,
                 null, verificationParams, user, packageAbiOverride, null);
+
         mHandler.sendMessage(msg);
     }
 
     void installStage(String packageName, File stagedDir, String stagedCid,
             IPackageInstallObserver2 observer, PackageInstaller.SessionParams params,
             String installerPackageName, int installerUid, UserHandle user) {
+        //Log.d("experiment install time", "installStage call");
         final VerificationParams verifParams = new VerificationParams(null, params.originatingUri,
                 params.referrerUri, installerUid, null);
         verifParams.setInstallerUid(installerUid);
@@ -12214,6 +12326,8 @@
             res.uid = newPackage.applicationInfo.uid;
             res.pkg = newPackage;
             mSettings.setInstallStatus(pkgName, PackageSettingBase.PKG_INSTALL_COMPLETE);
+            Log.d("experiment install time",
+                    "[PackageManagerService] updateSettingsLI PKG_INSTALL_COMPLETE");
             mSettings.setInstallerPackageName(pkgName, installerPackageName);
             res.returnCode = PackageManager.INSTALL_SUCCEEDED;
             //to update install status
@@ -12222,6 +12336,7 @@
     }
 
     private void installPackageLI(InstallArgs args, PackageInstalledInfo res) {
+        //Log.d("experiment install time","[PackageManagerService] installPackageLI call");
         final int installFlags = args.installFlags;
         final String installerPackageName = args.installerPackageName;
         final String volumeUuid = args.volumeUuid;
@@ -15779,6 +15894,7 @@
     }
 
     private void loadPrivatePackagesInner(VolumeInfo vol) {
+        Log.d("experiment install time", "[PackageManagerService] loadPrivatePackagesInner call");
         final ArrayList<ApplicationInfo> loaded = new ArrayList<>();
         final int parseFlags = mDefParseFlags | PackageParser.PARSE_EXTERNAL_STORAGE;
 
@@ -15795,6 +15911,7 @@
                 try {
                     pkg = scanPackageLI(ps.codePath, parseFlags, SCAN_INITIAL, 0L, null);
                     loaded.add(pkg.applicationInfo);
+                    Log.d("experiment install time", "[PackageManagerService] loadPrivatePackagesInner add");
                 } catch (PackageManagerException e) {
                     Slog.w(TAG, "Failed to scan " + ps.codePath + ": " + e.getMessage());
                 }
@@ -16207,6 +16324,7 @@
         final OriginInfo origin = OriginInfo.fromExistingFile(codeFile);
         msg.obj = new InstallParams(origin, move, installObserver, installFlags,
                 installerPackageName, volumeUuid, null, user, packageAbiOverride, null);
+
         mHandler.sendMessage(msg);
     }
 
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/CodeResourceReceiver.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/CodeResourceReceiver.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/CodeResourceReceiver.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/CodeResourceReceiver.java	2017-09-15 12:01:31.827634000 +0900
@@ -0,0 +1,444 @@
+
+package com.android.server.remote;
+
+import android.app.ActivityThread;
+import android.content.Context;
+import android.content.pm.IPackageManager;
+import android.os.AsyncTask;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.service.remote.AppendingObjectOutputStream;
+import android.service.remote.DexCode;
+import android.service.remote.IRemoteService;
+import android.service.remote.ResourceAapt;
+import android.service.samd.ISAMDService;
+import android.util.Log;
+
+import com.android.server.samd.SAMDService;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.util.ArrayList;
+
+
+public class CodeResourceReceiver implements Runnable {
+    private static final String TAG = "Data Receiver";
+
+    private Socket clientSocket;
+    private ObjectOutputStream outToClient;
+    private AppendingObjectOutputStream oos;
+    private ObjectInputStream inFromClient;
+    private int hashValue;
+    private int sourceDevice;
+
+    // private ObjectOutputStream
+    private final Context mContext;
+    private final String mPackageName;
+
+    private final IRemoteService mRemoteService;
+
+    public CodeResourceReceiver(Context context, Socket clientSocket, int _sourceDevice) {
+        mContext = context;
+        mPackageName = ActivityThread.currentPackageName();
+
+
+        this.clientSocket = clientSocket;
+        Log.d(TAG, "request from(for data): "
+                + this.clientSocket.getInetAddress().getHostAddress());
+        hashValue = clientSocket.getInetAddress().getHostAddress().hashCode();
+        this.sourceDevice = _sourceDevice;
+
+        mRemoteService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+        try {
+
+            outToClient = new ObjectOutputStream(this.clientSocket.getOutputStream());
+            oos = new AppendingObjectOutputStream(this.clientSocket.getOutputStream());
+            inFromClient = new ObjectInputStream(new BufferedInputStream(
+                    this.clientSocket.getInputStream()));
+//            inFromClient = new ObjectInputStream(
+//                    this.clientSocket.getInputStream());
+
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void run() {
+        try {
+            while (!Thread.currentThread().isInterrupted()) {
+                Object input = inFromClient.readObject();
+                if (input instanceof String) {
+                    Log.d(TAG, "String: " + input.toString());
+                    if (input.toString().equals("DataHello")) {
+                        Log.d("sbjsbjsbjsbjsbj", "sbjsbjsbjsbjsbj codeResourceReceiver");
+
+                        RemoteService.deviceToOutputforData.
+                                put(this.clientSocket.getInetAddress().getHostAddress(), oos);
+                        RemoteService.deviceToInputforData.put(this.clientSocket.getInetAddress().getHostAddress(),
+                                inFromClient);
+
+                        Log.d(TAG, "just got Hellooo from client (for data)"
+                                + RemoteService.mSensorHandles.toString());
+                        Log.d(TAG, "SBJJJJJJJJJJJJJJJJJ");
+                        oos.writeObject("DataGooooood");
+                        oos.flush();
+                        Log.d(TAG, "SBJJJJJJJJJJJJJJJJJ");
+                    }
+                } else if (input instanceof ResourceAapt) {
+                    ResourceAapt resourceAapt = (ResourceAapt) input;
+                    SAMDService.remote_device_number = (int) resourceAapt.getPara().get(0);
+                    ArrayList<String> addResourcesPerActivity = new ArrayList<String>();
+                    Log.d("uuuuuuu_SAMDVSAPK", "multiDexTransfer getMultiDex receive : " + (String) resourceAapt.getPara().get(1));
+                    //File dexFiles = new File("/data/collaboroid/agent/dex/" + (String) request.getPara().get(j) + "_classes.dex");
+                    //DEX
+                    String dexFileName = (String) resourceAapt.getPara().get(1);
+                    Log.d("samd experiment","receive Dex & Resources : " + dexFileName);
+                    //PRE RESOURCES
+                    int preResourcesNum = (int) resourceAapt.getPara().get(3);
+                    //REAL RESOURCES
+                    int resourcesNum = (int) resourceAapt.getPara().get(4+preResourcesNum);
+
+                    File dexFiles = new File("/collaboroid/agent/dex/" + dexFileName + "_classes.dex");
+                    try {
+                        FileOutputStream fileOutputStream = new FileOutputStream(dexFiles);
+                        fileOutputStream.write((byte[]) resourceAapt.getPara().get(2));
+                        fileOutputStream.flush();
+                        fileOutputStream.close();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                    for (int i = 0, j = 4; i < preResourcesNum; i++, j ++) {
+                        //SBJ_A/res/drawable/a.png?
+                        String resDirectory = (String) resourceAapt.getPara().get(j);
+                        //add resources
+                        File src = new File("collaboroid/agent/activity_res/"+resDirectory);
+                        String dstResDirectory = resDirectory.replace(resDirectory.split("\\/")[0],dexFileName);
+                        File dst = new File("collaboroid/agent/activity_res/"+dstResDirectory);
+                        copy(src, dst);
+                        addResourcesPerActivity.add(resDirectory);
+                    }
+                    for (int i = 0, j = 4+preResourcesNum+1; i < resourcesNum; i++, j += 2) {
+                        Log.d("uuuuuuu_SAMDVSAPK", "getResourcesLR receive : " + (String) resourceAapt.getPara().get(j));
+                        String activityResDirectory = (String) resourceAapt.getPara().get(j);
+                        //add resources
+                        addResourcesPerActivity.add(activityResDirectory);
+                        //create directory
+                        createDirAndFile(activityResDirectory,(byte[]) resourceAapt.getPara().get(j + 1));
+                    }
+                    AndroidManifestDummy(dexFileName);
+
+                    File f = new File("collaboroid/agent/activity_res/"+dexFileName+"/assets");
+                    if(f.exists()){
+                        Log.d("samd experiment","aapt package start["+dexFileName+"]");
+                        IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+                        try {
+                            pm.aaptPackageWithAssets("/collaboroid/agent/activity_res/"+dexFileName+"/res",
+                                    "collaboroid/agent/activity_res/"+dexFileName+"/assets",
+                                    "/collaboroid/agent/activity_res/"+dexFileName+"/AndroidManifest.xml",
+                                    "/collaboroid/agent/activity_res/"+dexFileName+"/abc.apk");
+                        } catch (RemoteException e) {
+                            e.printStackTrace();
+                        }
+                        Log.d("samd experiment","aapt package end["+dexFileName+"]");
+
+                    }else{
+                        Log.d("samd experiment","aapt package start["+dexFileName+"]");
+                        IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+                        try {
+                            pm.aaptPackage("/collaboroid/agent/activity_res/"+dexFileName+"/res",
+                                    "/collaboroid/agent/activity_res/"+dexFileName+"/AndroidManifest.xml",
+                                    "/collaboroid/agent/activity_res/"+dexFileName+"/abc.apk");
+                        } catch (RemoteException e) {
+                            e.printStackTrace();
+                        }
+                        Log.d("samd experiment","aapt package end["+dexFileName+"]");
+                    }
+                    try{
+                        ISAMDService ss = ISAMDService.Stub.asInterface(ServiceManager.getService(Context.SAMD_SERVICE));
+                        ss.popUpActivity(dexFileName);
+                    }catch(RemoteException e){
+                        e.printStackTrace();
+                    }
+                } else if (input instanceof DexCode) {
+                    DexCode dexcode = (DexCode) input;
+
+                    SAMDService.remote_device_number = (int) dexcode.getPara().get(0);
+                    ArrayList<String> addResourcesPerActivity = new ArrayList<String>();
+                    Log.d("uuuuuuu_SAMDVSAPK", "multiDexTransfer getMultiDex receive : " + (String) dexcode.getPara().get(1));
+                    //File dexFiles = new File("/data/collaboroid/agent/dex/" + (String) request.getPara().get(j) + "_classes.dex");
+                    //DEX
+                    String dexFileName = (String) dexcode.getPara().get(1);
+                    Log.d("samd experiment","receive Dex & Resources : " + dexFileName);
+                    //PRE RESOURCES
+                    int preResourcesNum = (int) dexcode.getPara().get(3);
+                    //REAL RESOURCES
+                    int resourcesNum = (int) dexcode.getPara().get(4+preResourcesNum);
+
+                    File dexFiles = new File("/collaboroid/agent/dex/" + dexFileName + "_classes.dex");
+                    try {
+                        FileOutputStream fileOutputStream = new FileOutputStream(dexFiles);
+                        fileOutputStream.write((byte[]) dexcode.getPara().get(2));
+                        fileOutputStream.flush();
+                        fileOutputStream.close();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+
+
+                    for (int i = 0, j = 4; i < preResourcesNum; i++, j ++) {
+                        //SBJ_A/res/drawable/a.png?
+                        String resDirectory = (String) dexcode.getPara().get(j);
+                        //add resources
+                        File src = new File("collaboroid/agent/activity_res/"+resDirectory);
+                        String dstResDirectory = resDirectory.replace(resDirectory.split("\\/")[0],dexFileName);
+                        Log.d("uuuuuuu_SAMDVSAPK","pre dstResDirectory : " + dstResDirectory);
+                        File dst = new File("collaboroid/agent/activity_res/"+dstResDirectory);
+                        copy(src, dst);
+                        addResourcesPerActivity.add(resDirectory);
+                    }
+
+                    for (int i = 0, j = 4+preResourcesNum+1; i < resourcesNum; i++, j += 2) {
+                        Log.d("uuuuuuu_SAMDVSAPK", "getResourcesLR receive : " + (String) dexcode.getPara().get(j));
+                        String activityResDirectory = (String) dexcode.getPara().get(j);
+                        //add resources
+                        addResourcesPerActivity.add(activityResDirectory);
+                        //create directory
+                        createDirAndFile(activityResDirectory,(byte[]) dexcode.getPara().get(j + 1));
+                    }
+
+
+                    AndroidManifestDummy(dexFileName);
+                    aaptForDexAsync afd = new aaptForDexAsync();
+                    afd.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, dexFileName);
+                    SAMDService.resourcesPerActivity.put(dexFileName, addResourcesPerActivity);
+
+
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void terminate() {
+        try{
+            clientSocket.close();
+            inFromClient.close();
+            outToClient.close();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    class aaptForDexAsync extends AsyncTask<String,Void, String> {
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+        }
+
+        @Override
+        protected String doInBackground(String... strings) {
+            //collaboroid
+            String dexFile = strings[0];
+
+            Log.d("aaptTask","aapt task void : " + dexFile);
+            String dexName = dexFile;
+            File f = new File("collaboroid/agent/activity_res/"+dexName+"/assets");
+            if(f.exists()){
+                Log.d("samd experiment","aapt package start["+dexName+"]");
+                IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+                try {
+                    pm.aaptPackageWithAssets("/collaboroid/agent/activity_res/"+dexName+"/res",
+                            "collaboroid/agent/activity_res/"+dexName+"/assets",
+                            "/collaboroid/agent/activity_res/"+dexName+"/AndroidManifest.xml",
+                            "/collaboroid/agent/activity_res/"+dexName+"/abc.apk");
+                } catch (RemoteException e) {
+                    e.printStackTrace();
+                }
+                Log.d("samd experiment","aapt package end["+dexName+"]");
+
+            }else{
+                Log.d("samd experiment","aapt package start["+dexName+"]");
+                IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+                try {
+                    pm.aaptPackage("/collaboroid/agent/activity_res/"+dexName+"/res",
+                            "/collaboroid/agent/activity_res/"+dexName+"/AndroidManifest.xml",
+                            "/collaboroid/agent/activity_res/"+dexName+"/abc.apk");
+                } catch (RemoteException e) {
+                    e.printStackTrace();
+                }
+                Log.d("samd experiment","aapt package end["+dexName+"]");
+            }
+
+
+            if(SAMDService.callResourceStack.contains(dexName)){
+                try{
+                    Log.d("uuuuuuu_SAMDVSAPK", "SAMDService.callResourceStack : "+ dexName+" is in stack... so call ["+dexName+"]");
+                    ISAMDService ss = ISAMDService.Stub.asInterface(ServiceManager.getService(Context.SAMD_SERVICE));
+                    ss.popUpActivity(dexName);
+                }catch(RemoteException e){
+                    e.printStackTrace();
+                }
+            }
+            return null;
+        }
+        @Override
+        protected void onPostExecute(String string) {
+            super.onPostExecute(string);
+        }
+        // AsyncTask.cancel(boolean) 메소드가 true 인자로
+        // 실행되면 호출되는 콜백.
+        // background 작업이 취소될때 꼭 해야될 작업은  여기에 구현.
+        @Override
+        protected void onCancelled() {
+            // TODO Auto-generated method stub
+            super.onCancelled();
+        }
+    }
+
+
+    public void copy(File src, File dst) throws IOException{
+        String dir = dst.getAbsolutePath();
+        Log.d("uuuuuuu_DexCode","dir check : " +dir);
+        String pathSplit[] = dir.split("/");
+        String baseDir = "/";
+        for (int z = 1; z < pathSplit.length; z++) {
+            if(pathSplit[z].contains(".png") || pathSplit[z].contains(".xml")
+                    || pathSplit[z].contains(".jpg") || pathSplit[z].contains(".jpeg")){
+                baseDir += pathSplit[z];
+            }else{
+                baseDir += pathSplit[z] +"/";
+                File directory = new File(baseDir);
+                if (!directory.exists()) {
+                    directory.mkdir();
+                }
+            }
+            Log.d("uuuuuuu_DexCode", "copy baseDir : : " + baseDir);
+        }
+        InputStream in = new FileInputStream(src);
+        try{
+            OutputStream out = new FileOutputStream(dst);
+            try{
+                byte[] buf = new byte[4096];
+                int len;
+                while( (len=in.read(buf)) > 0){
+                    out.write(buf, 0, len);
+                }
+            }finally {
+                out.close();
+
+            }
+        }finally {
+            in.close();
+        }
+    }
+
+    public void createDirAndFile(String dir, byte[] dexByte){
+        String pathSplit[] = dir.split("/");
+        String baseDir = "/collaboroid/agent/activity_res/";
+        for (int z = 0; z < pathSplit.length; z++) {
+            if(pathSplit[z].contains(".png") || pathSplit[z].contains(".xml")
+                    || pathSplit[z].contains(".jpg") || pathSplit[z].contains(".jpeg")){
+                baseDir += pathSplit[z];
+                File activityResFile = new File("/collaboroid/agent/activity_res/" + dir);
+                try {
+                    //activity res
+                    FileOutputStream fileOutputStream = new FileOutputStream(activityResFile);
+                    fileOutputStream.write(dexByte);
+                    fileOutputStream.flush();
+                    fileOutputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }else{
+                baseDir += pathSplit[z] +"/";
+                File directory = new File(baseDir);
+                if (!directory.exists()) {
+                    directory.mkdir();
+                }
+            }
+            Log.d("uuuuuuu_DexCode", "baseDir : : " + baseDir);
+        }
+    }
+    public void copyDirectoryOneLocationToAnotherLocation(File sourceLocation, File targetLocation)
+            throws IOException{
+        if(sourceLocation.isDirectory()){
+            if(!targetLocation.exists()){
+                targetLocation.mkdir();
+            }
+
+            String[] children = sourceLocation.list();
+            for(int i=0; i<sourceLocation.listFiles().length; i++){
+                copyDirectoryOneLocationToAnotherLocation(new File(sourceLocation, children[i]),
+                        new File(targetLocation, children[i]));
+            }
+        }else{
+            InputStream in = new FileInputStream(sourceLocation);
+            OutputStream out = new FileOutputStream(targetLocation);
+
+            byte[] buf = new byte[4096];
+            int len;
+            while((len=in.read(buf))>0){
+                out.write(buf,0,len);
+            }
+            in.close();
+            out.close();
+        }
+    }
+
+    public void AndroidManifestDummy(String dexName) {
+        String[] DummyxmlLine =
+                {"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
+                        "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"",
+                        "package=\"com.collaboroid.dummy1\">",
+                        "android:versionCode=\"1\"",
+                        "android:versionName=\"1.0\"",
+                        "<uses-permission android:name=\"android.permission.INTERNET\"/>",
+                        "<uses-permission android:name=\"android.permission.KILL_BACKGROUND_PROCESSES\"/>",
+                        "<application",
+                        "android:icon=\"@drawable/ic_launcher\"",
+                        "android:label=\"@string/Main_title\">",
+                        "<activity android:name=\".MainActivity\"",
+                        "android:label=\"@string/Main_title\"",
+                        "android:launchMode=\"singleTask\"",
+                        "android:clearTaskOnLaunch=\"true\">",
+                        "<intent-filter>",
+                        "<action android:name=\"android.intent.action.MAIN\" />",
+                        "<category android:name=\"android.intent.category.LAUNCHER\" />",
+                        "</intent-filter>",
+                        "</activity>",
+                        "</application>",
+                        "</manifest>"};
+        String dummy1FileName = "/collaboroid/agent/activity_res/"+dexName+"/AndroidManifest.xml";
+        BufferedWriter bw = null;
+        try {
+            bw = new BufferedWriter(new FileWriter(dummy1FileName));
+            for(int i=0; i<DummyxmlLine.length; i++){
+                bw.write(DummyxmlLine[i]);
+                bw.newLine();
+
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally{
+            try {
+                if (bw != null)
+                    bw.close();
+            } catch (IOException e) {
+
+            }
+        }
+    }
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/DataListener.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/DataListener.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/DataListener.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/DataListener.java	2017-09-02 18:25:35.304029000 +0900
@@ -0,0 +1,112 @@
+package com.android.server.remote;
+
+import android.content.Context;
+import android.os.AsyncTask;
+import android.util.Log;
+import android.util.SparseIntArray;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.ArrayList;
+
+public class DataListener extends Thread
+{
+	private static final String TAG = "Data RemoteRequestServer";
+	private static final int DATASERVERPORT = 33333;
+
+	private ServerSocket serverSocket;
+
+
+	private Thread crreceiverThread;
+	private CodeResourceReceiver codeResourceReceiver;
+
+	private final Context mContext;
+
+	public static SparseIntArray mNodes = new SparseIntArray();
+	private int currentNode = 0;
+
+	private static ArrayList<String> clientIPs = new ArrayList<String>();
+	private ArrayList<Thread> receiverThreads;
+
+	public DataListener(Context context)
+	{
+		mContext = context;
+		receiverThreads = new ArrayList<Thread>();
+	}
+	
+	public void terminate()
+	{
+		try
+		{
+			if(receiverThreads.size() > 0)
+			{
+				for(Thread t : receiverThreads)
+					t.interrupt();
+			}
+			serverSocket.close();
+			codeResourceReceiver.terminate();
+			
+		}
+		catch (IOException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public static ArrayList<String> getClientIPs(){
+	    return clientIPs;
+	}
+	
+	@Override
+	public void run()
+	{
+		Socket socket = null;
+		
+		try
+		{
+			serverSocket = new ServerSocket(DATASERVERPORT);
+			
+			while (!Thread.currentThread().isInterrupted())
+			{
+				Log.d(TAG, "Data RemoteRequestServer successfully started!");
+				socket = serverSocket.accept();
+				//17.01.31
+
+				socket.setTcpNoDelay(true);
+				socket.setKeepAlive(true);
+				socket.setSoTimeout(0);
+				//socket.setReceiveBufferSize(128*1024*1024);
+
+				String currentClientIP = socket.getInetAddress().getHostAddress();
+				
+				Log.i(TAG, "Client Connected: " + currentClientIP);
+				
+				clientIPs.add(currentClientIP);
+
+				Log.d(TAG, mNodes.toString());
+
+				RemoteService.deviceToSNforData.put(currentClientIP, ++currentNode);
+				
+
+				/*
+				codeResourceReceiver = new CodeResourceReceiver(mContext, socket, currentNode);
+				codeResourceReceiver.execute();
+				*/
+
+				codeResourceReceiver = new CodeResourceReceiver(mContext, socket, currentNode);
+				crreceiverThread = new Thread(codeResourceReceiver);
+				receiverThreads.add(crreceiverThread);
+				crreceiverThread.start();
+
+			}
+			//socket.close();
+			
+		}
+		catch (IOException e)
+		{
+			e.printStackTrace();
+		}
+	}	
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Listener.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Listener.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Listener.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Listener.java	2017-09-02 18:25:35.300028000 +0900
@@ -0,0 +1,105 @@
+package com.android.server.remote;
+
+import android.content.Context;
+import android.util.Log;
+import android.util.SparseIntArray;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.ArrayList;
+
+public class Listener extends Thread
+{
+	private static final String TAG = "RemoteRequestServer";
+	private static final int SERVERPORT = 55555;
+
+	private ServerSocket serverSocket;
+	
+	private Thread receiverThread;
+	private Receiver receiver;
+
+	private final Context mContext;
+	
+	public static SparseIntArray mNodes = new SparseIntArray();
+	private int currentNode = 0;
+	
+	private static ArrayList<String> clientIPs = new ArrayList<String>();
+	private ArrayList<Thread> receiverThreads;
+	
+	public Listener(Context context)
+	{
+		mContext = context;
+		receiverThreads = new ArrayList<Thread>();
+	}
+	
+	public void terminate()
+	{
+		try
+		{
+			if(receiverThreads.size() > 0)
+			{
+				for(Thread t : receiverThreads)
+					t.interrupt();
+			}
+			serverSocket.close();
+
+			
+		}
+		catch (IOException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public static ArrayList<String> getClientIPs(){
+	    return clientIPs;
+	}
+	
+	@Override
+	public void run()
+	{
+		Socket socket = null;
+		
+		try
+		{
+			serverSocket = new ServerSocket(SERVERPORT);
+			
+			while (!Thread.currentThread().isInterrupted())
+			{
+				Log.d(TAG, "RemoteRequestServer successfully started!");
+				socket = serverSocket.accept();
+				//17.01.31
+
+				socket.setTcpNoDelay(true);
+				socket.setKeepAlive(true);
+				socket.setSoTimeout(0);
+				//socket.setReceiveBufferSize(128*1024*1024);
+
+				String currentClientIP = socket.getInetAddress().getHostAddress();
+				
+				Log.i(TAG, "Client Connected: " + currentClientIP);
+				
+				clientIPs.add(currentClientIP);
+
+				Log.d(TAG, mNodes.toString());
+				
+				RemoteService.deviceToSN.put(currentClientIP, ++currentNode);
+				
+				receiver = new Receiver(mContext, socket, currentNode);
+				receiverThread = new Thread(receiver);
+				receiverThreads.add(receiverThread);
+
+				
+				receiverThread.start();
+			}
+			//socket.close();
+			
+		}
+		catch (IOException e)
+		{
+			e.printStackTrace();
+		}
+	}	
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/MainLooperSpy.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/MainLooperSpy.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/MainLooperSpy.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/MainLooperSpy.java	2017-01-29 02:51:16.649856000 +0900
@@ -0,0 +1,48 @@
+package com.android.server.remote;
+
+import java.lang.reflect.Field;
+
+import android.os.Looper;
+import android.os.Message;
+import android.os.MessageQueue;
+import android.util.Log;
+
+public class MainLooperSpy {
+	  private final Field messagesField;
+	  private final Field nextField;
+	  private final MessageQueue mainMessageQueue;
+
+	  public MainLooperSpy() {
+	    try {
+	      Field queueField = Looper.class.getDeclaredField("mQueue");
+	      queueField.setAccessible(true);
+	      messagesField = MessageQueue.class.getDeclaredField("mMessages");
+	      messagesField.setAccessible(true);
+	      nextField = Message.class.getDeclaredField("next");
+	      nextField.setAccessible(true);
+	      Looper mainLooper = Looper.getMainLooper();
+	      mainMessageQueue = (MessageQueue) queueField.get(mainLooper);
+	    } catch (Exception e) {
+	      throw new RuntimeException(e);
+	    }
+	  }
+
+	  public void dumpQueue() {
+	    try {
+	      Message nextMessage = (Message) messagesField.get(mainMessageQueue);
+	      Log.d("MainLooperSpy", "Begin dumping queue");
+	      dumpMessages(nextMessage);
+	      Log.d("MainLooperSpy", "End dumping queue");
+	    } catch (IllegalAccessException e) {
+	      throw new RuntimeException(e);
+	    }
+	  }
+
+	  public void dumpMessages(Message message) throws IllegalAccessException {
+	    if (message != null) {
+	      Log.d("MainLooperSpy", message.toString());
+	      Message next = (Message) nextField.get(message);
+	      dumpMessages(next);
+	    }
+	  }
+	}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/ObjectSizeCalculator.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/ObjectSizeCalculator.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/ObjectSizeCalculator.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/ObjectSizeCalculator.java	2017-01-29 02:51:16.641856000 +0900
@@ -0,0 +1,190 @@
+package com.android.server.remote;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ObjectSizeCalculator
+{
+
+	private static final int REFERENCE_SIZE;
+	private static final int HEADER_SIZE;
+	private static final int LONG_SIZE = 8;
+	private static final int INT_SIZE = 4;
+	private static final int BYTE_SIZE = 1;
+	private static final int BOOLEAN_SIZE = 1;
+	private static final int CHAR_SIZE = 2;
+	private static final int SHORT_SIZE = 2;
+	private static final int FLOAT_SIZE = 4;
+	private static final int DOUBLE_SIZE = 8;
+	private static final int ALIGNMENT = 8;
+
+	static
+	{
+		try
+		{
+			if (System.getProperties().get("java.vm.name").toString()
+					.contains("64"))
+			{
+				// java.vm.name is something like “Java HotSpot(TM) 64-Bit
+				// Server VM”
+				REFERENCE_SIZE = 8;
+				HEADER_SIZE = 16;
+			} else
+			{
+				REFERENCE_SIZE = 4;
+				HEADER_SIZE = 8;
+			}
+		} catch (Exception ex)
+		{
+			ex.printStackTrace();
+			throw new AssertionError(ex);
+		}
+	}
+
+	public static long sizeOf(Object o) throws IllegalAccessException
+	{
+		return sizeOf(o, new HashSet());
+	}
+
+	private static long sizeOf(Object o, Set visited)
+			throws IllegalAccessException
+	{
+		if (o == null)
+		{
+			return 0;
+		}
+		ObjectWrapper objectWrapper = new ObjectWrapper(o);
+		if (visited.contains(objectWrapper))
+		{
+			// We have reference graph with cycles.
+			return 0;
+		}
+		visited.add(objectWrapper);
+		long size = HEADER_SIZE;
+		Class clazz = o.getClass();
+		if (clazz.isArray())
+		{
+			if (clazz == long[].class)
+			{
+				long[] objs = (long[]) o;
+				size += objs.length * LONG_SIZE;
+			} else if (clazz == int[].class)
+			{
+				int[] objs = (int[]) o;
+				size += objs.length * INT_SIZE;
+			} else if (clazz == byte[].class)
+			{
+				byte[] objs = (byte[]) o;
+				size += objs.length * BYTE_SIZE;
+			} else if (clazz == boolean[].class)
+			{
+				boolean[] objs = (boolean[]) o;
+				size += objs.length * BOOLEAN_SIZE;
+			} else if (clazz == char[].class)
+			{
+				char[] objs = (char[]) o;
+				size += objs.length * CHAR_SIZE;
+			} else if (clazz == short[].class)
+			{
+				short[] objs = (short[]) o;
+				size += objs.length * SHORT_SIZE;
+			} else if (clazz == float[].class)
+			{
+				float[] objs = (float[]) o;
+				size += objs.length * FLOAT_SIZE;
+			} else if (clazz == double[].class)
+			{
+				double[] objs = (double[]) o;
+				size += objs.length * DOUBLE_SIZE;
+			} else
+			{
+				Object[] objs = (Object[]) o;
+				for (int i = 0; i < objs.length; i++)
+				{
+					size += sizeOf(objs[i], visited) + REFERENCE_SIZE;
+				}
+			}
+			size += INT_SIZE;
+		} else
+		{
+			Field[] fields = o.getClass().getDeclaredFields();
+			for (int i = 0; i < fields.length; i++)
+			{
+				if (Modifier.isStatic(fields[i].getModifiers()))
+				{
+					continue;
+				}
+				fields[i].setAccessible(true);
+				String fieldType = fields[i].getGenericType().toString();
+				if (fieldType.equals("long"))
+				{
+					size += LONG_SIZE;
+				} else if (fieldType.equals("int"))
+				{
+					size += INT_SIZE;
+				} else if (fieldType.equals("byte"))
+				{
+					size += BYTE_SIZE;
+				} else if (fieldType.equals("boolean"))
+				{
+					size += BOOLEAN_SIZE;
+				} else if (fieldType.equals("char"))
+				{
+					size += CHAR_SIZE;
+				} else if (fieldType.equals("short"))
+				{
+					size += SHORT_SIZE;
+				} else if (fieldType.equals("float"))
+				{
+					size += FLOAT_SIZE;
+				} else if (fieldType.equals("double"))
+				{
+					size += DOUBLE_SIZE;
+				} else
+				{
+					size += sizeOf(fields[i].get(o), visited) + REFERENCE_SIZE;
+				}
+			}
+		}
+		if ((size % ALIGNMENT) != 0)
+		{
+			size = ALIGNMENT * (size / ALIGNMENT) + ALIGNMENT;
+		}
+		return size;
+	}
+
+	private static final class ObjectWrapper
+	{
+
+		private Object object;
+
+		public ObjectWrapper(Object object)
+		{
+			this.object = object;
+		}
+
+		@Override
+		public boolean equals(Object obj)
+		{
+			if (obj == this)
+			{
+				return true;
+			}
+			if ((obj == null) || (obj.getClass() != ObjectWrapper.class))
+			{
+				return false;
+			}
+			return object == ((ObjectWrapper) obj).object;
+		}
+
+		@Override
+		public int hashCode()
+		{
+			int hash = 3;
+			hash = 47 * hash + System.identityHashCode(object);
+			return hash;
+		}
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Receiver.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Receiver.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Receiver.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Receiver.java	2017-09-22 12:45:10.899756000 +0900
@@ -0,0 +1,1410 @@
+
+package com.android.server.remote;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.net.Socket;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.zip.DataFormatException;
+import java.util.zip.Inflater;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.ActivityThread;
+import android.app.AlarmManager;
+import android.app.Instrumentation;
+import android.app.PackageInstallObserver;
+import android.app.PendingIntent;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.content.pm.ManifestDigest;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageInstaller;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageParser;
+import android.content.pm.PackageUserState;
+import android.content.pm.ResolveInfo;
+import android.content.pm.VerificationParams;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Point;
+import android.hardware.input.IInputManager;
+import android.hardware.input.InputManager;
+import android.location.ILocationManager;
+import android.location.Location;
+import android.location.LocationManager;
+import android.media.AudioFormat;
+import android.media.AudioManager;
+import android.media.AudioTrack;
+import android.media.MediaCodec;
+import android.media.MediaFormat;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.IVibratorService;
+import android.os.Message;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemClock;
+import android.os.SystemVibrator;
+import android.os.Vibrator;
+import android.service.devicemanagement.Device;
+import android.service.remote.AppendingObjectOutputStream;
+import android.service.remote.IRemoteService;
+import android.service.remote.RemoteRequest;
+import android.service.samd.ISAMDService;
+import android.service.samd.SAMDMessage;
+import android.service.remote.SdPackage;
+//import android.support.v4.content.IntentCompat;
+import android.util.ArrayMap;
+import android.util.AndroidRuntimeException;
+import android.util.Log;
+import android.view.Display;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.WindowManager;
+
+import com.android.server.pm.PackageManagerService;
+import com.android.server.samd.SAMDService;
+
+public class Receiver implements Runnable {
+    private static final String TAG = "Receiver";
+    //INSTALL APK
+    PackageManager mPm;
+    PackageInstaller mInstaller;
+    ApplicationInfo mAppInfo;
+    public static ApplicationInfo SAMDAppInfo;
+    PackageParser.Package parsed;
+    PackageInfo mPkgInfo;
+    ManifestDigest mPkgDigest;
+    public static Intent mLaunchIntent;
+    public static Context SAMDContext;
+
+    private final int INSTALL_COMPLETE = 1;
+
+    private Socket clientSocket;
+    private ObjectOutputStream outToClient;
+    private AppendingObjectOutputStream oos;
+    private ObjectInputStream inFromClient;
+    private int hashValue;
+    private int sourceDevice;
+
+    // private ObjectOutputStream
+    private final Context mContext;
+    private final String mPackageName;
+    private final IVibratorService mService;
+
+    private SystemVibrator mVibratorService;
+    private Vibrator mVibrator;
+
+    private final IInputManager mInputService;
+    private final Instrumentation mInstrumentation;
+    private final ILocationManager mLocationManager;
+    private final IRemoteService mRemoteService;
+
+    ////////////////////////////////////////////////////////
+    private MediaFormat format;
+    private MediaCodec codec;
+    private AudioTrack audioTrack;
+
+    // variables of format
+    private String mime = "";
+    private int sampleRate = 0, channels = 0, bitrate = 0;
+    private long duration = 0;
+    ByteBuffer[] codecInputBuffers;
+    ByteBuffer[] codecOutputBuffers;
+    // decode start
+    final long TIMEOUT_US = 5000;
+    MediaCodec.BufferInfo info = new MediaCodec.BufferInfo();
+    boolean sawInputEOS = false;
+    boolean sawOutputEOS = false;
+    int noOutputCounter = 0;
+    int noOutputCounterLimit = 10;
+    private int test = 0;
+
+    boolean stop = false;
+    long presentationTimeUs = 0;
+    int sampleSize = 0;
+    // /////////////////////////////////////////////
+
+    private int Xdefault;
+    private int Ydefault;
+
+    // private Object input = null;;
+    private Location location = new Location("");
+
+    // Native Functions
+    /*native void sendRemoteEvent(int type, int sensor, float[] values, int accuracy, long timestamp,
+            int sourceDevice);*/
+    public Receiver(Context context, Socket clientSocket, int _sourceDevice) {
+        mContext = context;
+        mPackageName = ActivityThread.currentPackageName();
+        mService = IVibratorService.Stub.asInterface(ServiceManager
+                .getService("vibrator"));
+
+        mVibratorService = new SystemVibrator(mContext);
+
+        mInputService = IInputManager.Stub.asInterface(ServiceManager.getService("input"));
+        mInstrumentation = new Instrumentation();
+
+        mLocationManager = ILocationManager.Stub.asInterface(ServiceManager.getService("location"));
+
+        mRemoteService = IRemoteService.Stub.asInterface(ServiceManager.getService(Context.REMOTE_SERVICE));
+
+        this.clientSocket = clientSocket;
+        hashValue = clientSocket.getInetAddress().getHostAddress().hashCode();
+        this.sourceDevice = _sourceDevice;
+
+        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+        Display display = wm.getDefaultDisplay();
+        Point size = new Point();
+        display.getSize(size);
+
+
+        Xdefault = size.x;
+        Ydefault = size.y;
+
+        Log.d(TAG, "request from: "
+                + this.clientSocket.getInetAddress().getHostAddress());
+
+        try {
+
+            outToClient = new ObjectOutputStream(this.clientSocket.getOutputStream());
+            oos = new AppendingObjectOutputStream(this.clientSocket.getOutputStream());
+            inFromClient = new ObjectInputStream(
+                    this.clientSocket.getInputStream());
+
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void terminate() {
+
+    }
+
+    public void unzip(String _zipFile, String _targetLocation) {
+        //create target location folder if not exist
+        dirChecker(_targetLocation);
+        try {
+            FileInputStream fin = new FileInputStream(_zipFile);
+            ZipInputStream zin = new ZipInputStream(fin);
+            ZipEntry ze = null;
+            while ((ze = zin.getNextEntry()) != null) {
+
+                //create dir if required while unzipping
+                if (ze.isDirectory()) {
+                    dirChecker(ze.getName());
+                } else {
+                    FileOutputStream fout = new FileOutputStream(_targetLocation + ze.getName());
+                    for (int c = zin.read(); c != -1; c = zin.read()) {
+                        fout.write(c);
+                    }
+
+                    zin.closeEntry();
+                    fout.close();
+                }
+
+            }
+            zin.close();
+        } catch (Exception e) {
+            System.out.println(e);
+        }
+    }
+
+    private void dirChecker(String dir) {
+        File f = new File(dir);
+        if (!f.isDirectory()) {
+            f.mkdirs();
+        }
+    }
+
+
+    @Override
+    public void run() {
+        int ClientDeviceNum = 0;
+        // TODO Auto-generated method stub
+        try {
+            while (!Thread.currentThread().isInterrupted()) {
+                Object input = inFromClient.readObject();
+                // request for resources
+                if (input instanceof ResourceRequest) {
+                    // ask RemoteService whether this device is allowed for the resources
+                    ResourceRequest rr = (ResourceRequest) input;
+                    Log.d(TAG, "Requested: " + Arrays.toString(rr.getRequestedResources()));
+                    //client is [server output] add
+                    RemoteService.waitForResponse.put(clientSocket.getInetAddress().getHostAddress(), outToClient);
+                    oos.flush();
+                    mRemoteService.isAllowedForResource(rr.getDeviceName(), clientSocket.getInetAddress().getHostAddress(), rr.getRequestedResources());
+                    for (int i : rr.getRequestedResources()) {
+                        if (i == Device.RESOURCE_TYPE_REMOTE_ACTIVITY) {
+                            RemoteService.toRemoteActivityServer.add(oos);
+                            RemoteService.deviceToOutput.
+                                    put(this.clientSocket.getInetAddress().getHostAddress(), oos);
+                            Device d = new Device();
+                            SAMDService.cachedActivityResourceDevices.add(d);
+                            ArrayList<String> list = new ArrayList<String>();
+                            SAMDService.callActivityStackPerDevice.append(ClientDeviceNum++,list);
+                            Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+                            Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+                            Log.d(TAG, this.clientSocket.getInetAddress().getHostAddress() + "SBJJJJJJJJJJJ");
+                            Log.d(TAG, RemoteService.deviceToOutput.size() + "SBJJJJJJJJJJJJJJ");
+                            Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+                            Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+                        }
+                    }
+                    //outToClient.writeObject(test);
+                } else if (input instanceof String) {
+                    Log.d(TAG, "String: " + input.toString());
+                    if (input.toString().equals("Hello")) {
+                        Log.d(TAG, "just got Hellooo from client"
+                                + RemoteService.mSensorHandles.toString());
+                        Log.d(TAG, "SBJJJJJJJJJJJJJJJJJ");
+                        oos.writeObject("Gooooood");
+                        oos.flush();
+                        Log.d(TAG, "SBJJJJJJJJJJJJJJJJJ");
+                    }
+                } /*else if (input instanceof ResourceAapt) {
+                    final long origId = Binder.clearCallingIdentity();
+
+                    try{
+                        new aaptTask().execute((ResourceAapt) input);
+                    }finally {
+                        Binder.restoreCallingIdentity(origId);
+                    }
+                } else if (input instanceof DexCode) {
+                    final long origId = Binder.clearCallingIdentity();
+                    try{
+                        new dexTask().execute((DexCode) input);
+                    }finally {
+                        Binder.restoreCallingIdentity(origId);
+                    }
+                }*/ else if (input instanceof RemoteRequest) {
+                    RemoteRequest request = (RemoteRequest) input;
+
+                    Log.d(TAG, "Request: " + request.toString());
+
+                    // Handle Request Here!
+                    final long origId = Binder.clearCallingIdentity();
+
+                    try {
+                        if (request.getType().equalsIgnoreCase("systemcall")) {
+                            if (request.getMethod().compareTo("vibrate") == 0) {
+//                                Log.d(TAG, "vibrated" + sourceDevice);
+                                mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+                                mVibrator.vibrate((Long) request.getPara().get(0));
+                                Log.d(TAG, "vibrated" + sourceDevice);
+//                                mVibratorService.vibrate((Long) request.getPara().get(0));
+                            } else if (request.getMethod().compareTo("vibrate2") == 0) {
+                                mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+                                mVibrator.vibrate((long[]) request.getPara().get(0),
+                                        (Integer) request.getPara().get(1));
+//                                mVibratorService.vibrate((long[]) request.getPara().get(0),
+//                                                (Integer) request.getPara().get(1));
+                            }
+                        } else if (request.getType().equals("RemoteMusic")) {
+                            Log.d(TAG, "you are in RemoteRequest, in if RemoteMusic");
+                            RemoteRequest rr = (RemoteRequest) input;
+                            format = new MediaFormat();
+                            try {
+                                // format = MediaFormat.createAudioFormat(mime,
+                                // sampleRate,
+                                // channels);
+                                // format = ee.getTrackFormat(0);
+                                Log.d(TAG, "the mime is  "
+                                        + (String) rr.getPara().get(0));
+                                format.setString(MediaFormat.KEY_MIME,
+                                        mime = (String) rr.getPara().get(0));
+                                format.setInteger(MediaFormat.KEY_SAMPLE_RATE,
+                                        sampleRate = (Integer) rr.getPara()
+                                                .get(1));
+                                format.setInteger(
+                                        MediaFormat.KEY_CHANNEL_COUNT,
+                                        channels = (Integer) rr.getPara()
+                                                .get(2));
+                                format.setLong(MediaFormat.KEY_DURATION,
+                                        duration = (Long) rr.getPara().get(3));
+
+                            } catch (Exception e) {
+                                Log.e(TAG,
+                                        "Reading format parameters exception:"
+                                                + e.getMessage());
+                            }
+                            codec = MediaCodec.createDecoderByType("audio/mpeg");
+                            codec.configure(format, null, null, 0);
+                            codec.start();
+
+                            codecInputBuffers = codec.getInputBuffers();
+                            codecOutputBuffers = codec.getOutputBuffers();
+
+                            int channelConfiguration = 0;
+                            if (channels == 1)
+                                channelConfiguration = AudioFormat.CHANNEL_OUT_MONO;
+                            else
+                                channelConfiguration = AudioFormat.CHANNEL_OUT_STEREO;
+
+                            int minSize = AudioTrack.getMinBufferSize(sampleRate,
+                                    channelConfiguration,
+                                    AudioFormat.ENCODING_PCM_16BIT);
+                            audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
+                                    sampleRate, channelConfiguration,
+                                    AudioFormat.ENCODING_PCM_16BIT, minSize,
+                                    AudioTrack.MODE_STREAM);
+                            // feeding
+                            audioTrack.play();
+
+                            Log.d(TAG, "the codec is waiting for you");
+                            test = 0;
+                        }
+                        // music stop
+                        else if (request.getType().equals("StopMusic")) {
+                            Log.d(TAG, "stopping...");
+
+                            if (codec != null) {
+                                codec.stop();
+                                codec.release();
+                                codec = null;
+                            }
+                            if (audioTrack != null) {
+                                audioTrack.flush();
+                                audioTrack.release();
+                                audioTrack = null;
+                            }
+                            Log.d(TAG, "music play is done");
+
+                        }
+
+                        // video streaming
+                        else if (request.getType().equalsIgnoreCase("video_streaming")) {
+                            Log.d(TAG, "11111111111");
+                            if (request.getMethod().equalsIgnoreCase("get_surface")) {
+                                Log.d(TAG, "2222222222");
+                                ComponentName compName = new ComponentName(
+                                        "com.example.surfaceprovider"
+                                        , "com.remote.surfaceprovider.SurfaceProvider");
+
+                                Intent intent = new Intent(Intent.ACTION_MAIN);
+                                intent.addCategory("android.intent.category.VIDEO_STREAMING");
+                                intent.setComponent(compName);
+                                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+                                int port = (Integer) request.getPara().get(1);
+                                Log.d(TAG, request.toString() + "  " + port);
+                                intent.putExtra("mode", "video");
+                                intent.putExtra("dcslab", port);
+                                mContext.startActivity(intent);
+
+                                // Intent intent =
+                                // context.getPackageManager().getLaunchIntentForPackage("ParkageName");
+                                // startActivity(intent);
+                            }
+                        } else if (request.getType().equalsIgnoreCase("request")) {
+                            if (request.getMethod().equalsIgnoreCase("motion")) {
+                                mRemoteService.connectToServer(clientSocket.getInetAddress().getHostAddress());
+                            } else if (request.getMethod().equalsIgnoreCase("dummyApp")) {
+                                Log.d(TAG, "HELLO");
+                                ComponentName compName = new ComponentName(
+                                        "com.example.surfaceprovider"
+                                        , "com.remote.surfaceprovider.SurfaceProvider");
+
+                                Intent intent = new Intent(Intent.ACTION_MAIN);
+                                intent.addCategory("android.intent.category.VIDEO_STREAMING");
+                                intent.setComponent(compName);
+                                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+                                intent.putExtra("mode", "dummyApp");
+
+                                mContext.startActivity(intent);
+                            }
+                        } else if (request.getType().equalsIgnoreCase("initializeAR")) {
+                            if (request.getMethod().equalsIgnoreCase("init")) {
+                                Log.d("uuuuuuu_initializeAR",
+                                        "s-----------------------------------------------------------------------------------------------");
+                                SAMDService.CURRENT_APP_NAME = (String) request.getPara().get(0);
+
+                                SAMDService.resourcesPerActivity.clear();
+                                //SAMDService.callActivityStack.clear();
+                                SAMDService.callResourceStack.clear();
+
+                                DeleteRecursiveFiles(new File("/collaboroid/agent/activity_res/"));
+                                DeleteRecursiveFiles(new File("/collaboroid/agent/dex/"));
+                                File f = new File("/collaboroid/agent/abc.apk");
+                                if(f.exists()){
+                                    f.delete();
+                                }
+
+                                oos.writeObject("init ok");
+                                oos.flush();
+
+                                Log.d("uuuuuuu_initializeAR", "SAMDService.CURRENT_APP_NAME : " + SAMDService.CURRENT_APP_NAME);
+
+                                Log.d("uuuuuuu_initializeAR",
+                                        "e-----------------------------------------------------------------------------------------------");
+                            }
+                        } else if (request.getType().equalsIgnoreCase("sendMessage")) {
+                            if (request.getMethod().equalsIgnoreCase("getMessageLR")) {
+                                //int(Player) && String(msg)
+                                try {
+                                    SAMDMessage message =
+                                            new SAMDMessage((int) request.getPara().get(0),
+                                                    SAMDService.remote_device_number,
+                                                    (String) request.getPara().get(1));
+                                    SAMDService.dispatchMessage(message);
+
+                                } catch (AndroidRuntimeException are) {
+                                    Log.d(TAG, "ERROR!!!");
+                                }
+                            }
+                            if (request.getMethod().equalsIgnoreCase("getMessageRL")) {
+
+                                SAMDMessage message =
+                                        new SAMDMessage((int) request.getPara().get(0),
+                                                0,
+                                                (String) request.getPara().get(1));
+
+                                message.setStime((long)request.getPara().get(2));
+
+                                SAMDService.dispatchMessage(message);
+
+                            }
+                        } else if (request.getType().equalsIgnoreCase("sendActivity")) {
+                            Log.d(TAG, "sendActivity!!!!!!");
+                            if (request.getMethod().equalsIgnoreCase("OnlyName")) {
+                                String activityName = (String) request.getPara().get(0);
+                                Log.d("samd experiment"," sendActivity/onlyname ["+activityName+"]");
+                                File f = new File("/collaboroid/agent/activity_res/"+activityName+"/abc.apk");
+                                if(!f.exists()){
+                                    SAMDService.callResourceStack.add(activityName);
+                                }else{
+                                    ISAMDService ss = ISAMDService.Stub.asInterface(ServiceManager.getService(Context.SAMD_SERVICE));
+                                    ss.popUpActivity(activityName);
+                                }
+                            }
+                            if (request.getMethod().equalsIgnoreCase("WithResource")) {
+                                Log.d("uuuuuuu_sendActivity/WithResource",
+                                        "s-----------------------------------------------------------------------------------------------");
+                                String activityName = (String) request.getPara().get(0);
+                                Log.d("samd experiment","[withResource]receive Dex & Resources : " + activityName);
+                                //PRE RESOURCES
+                                int preResourcesNum = (int) request.getPara().get(1);
+                                //REAL RESOURCES
+                                int resourcesNum = (int) request.getPara().get(2+preResourcesNum);
+                                ArrayList<String> addResourcesPerActivity = new ArrayList<String>();
+                                Log.d("uuuuuuu_sendActivity/WithResource", "preResourcesNum : " + preResourcesNum);
+                                for (int i = 0, j = 2; i < preResourcesNum; i++, j ++) {
+                                    Log.d("uuuuuuu_sendActivity/WithResource", "getResourcesLR pre receive : " + (String) request.getPara().get(j));
+                                    //SBJ_A/res/drawable/a.png?
+                                    String resDirectory = (String) request.getPara().get(j);
+                                    Log.d("uuuuuuu_sendActivity/WithResource","resDirectory : " + resDirectory);
+                                    //add resources
+                                    File src = new File("collaboroid/agent/activity_res/"+resDirectory);
+                                    String dstResDirectory = resDirectory.replace(resDirectory.split("\\/")[0],activityName);
+                                    Log.d("uuuuuuu_sendActivity/WithResource","dstResDirectory : " + dstResDirectory);
+                                    File dst = new File("collaboroid/agent/activity_res/"+dstResDirectory);
+                                    copy(src, dst);
+                                    addResourcesPerActivity.add(resDirectory);
+                                }
+                                Log.d("uuuuuuu_sendActivity/WithResource", "resourcesNum : " + resourcesNum);
+                                for (int i = 0, j = 2+preResourcesNum+1; i < resourcesNum; i++, j += 2) {
+                                    Log.d("uuuuuuu_sendActivity/WithResource", "getResourcesLR receive : " + (String) request.getPara().get(j));
+                                    String activityResDirectory = (String) request.getPara().get(j);
+                                    //add resources
+                                    addResourcesPerActivity.add(activityResDirectory);
+                                    //create directory
+                                    createDirAndFile(activityResDirectory,(byte[]) request.getPara().get(j + 1));
+                                }
+                                for(String s : addResourcesPerActivity){
+                                    Log.d("uuuuuuu_sendActivity/WithResource", "Resources Per Activity : : " + s);
+                                }
+                                AndroidManifestDummy(activityName);
+                                SAMDService.resourcesPerActivity.put(activityName, addResourcesPerActivity);
+
+                                for(int i=0; i<addResourcesPerActivity.size(); i++){
+                                    addResourcesPerActivity.set(i,
+                                            addResourcesPerActivity.get(i).replace(addResourcesPerActivity.get(i).split("\\/")[0]+"/assets/",""));
+                                }
+
+                                File f = new File("collaboroid/agent/activity_res/"+activityName+"/assets");
+                                if(f.exists()){
+                                    IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+                                    try {
+                                        pm.aaptPackageWithAssets("/collaboroid/agent/activity_res/"+activityName+"/res",
+                                                "collaboroid/agent/activity_res/"+activityName+"/assets",
+                                                "/collaboroid/agent/activity_res/"+activityName+"/AndroidManifest.xml",
+                                                "/collaboroid/agent/activity_res/"+activityName+"/abc.apk");
+                                    } catch (RemoteException e) {
+                                        e.printStackTrace();
+                                    }
+
+                                }else{
+                                    IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+                                    try {
+                                        pm.aaptPackage("/collaboroid/agent/activity_res/"+activityName+"/res",
+                                                "/collaboroid/agent/activity_res/"+activityName+"/AndroidManifest.xml",
+                                                "/collaboroid/agent/activity_res/"+activityName+"/abc.apk");
+                                    } catch (RemoteException e) {
+                                        e.printStackTrace();
+                                    }
+
+                                }
+
+                                File abcFile = new File("/collaboroid/agent/activity_res/"+activityName+"/abc.apk");
+                                File dst_f = new File("/collaboroid/agent/abc.apk");
+                                copy(abcFile, dst_f);
+
+                                IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+
+                                if (SAMDService.DUMMY_BIT) {
+                                    Log.d("samd experiment","aapt add/remove start["+activityName+"]");
+                                    pm.aaptAdd(2, "/system/priv-app/Dummy1/Dummy1.apk", "classes.dex");
+                                    File dexFile = new File("/collaboroid/agent/dex/" + activityName + "_classes.dex");
+                                    File classesDex = new File("/collaboroid/agent/dex/classes.dex");
+                                    dexFile.renameTo(classesDex);
+
+                                    pm.aaptAdd(1, "/system/priv-app/Dummy1/Dummy1.apk", "/collaboroid/agent/dex/classes.dex");
+                                    classesDex.renameTo(dexFile);
+
+                                    Log.d("samd experiment","aapt add/remove end["+activityName+"]");
+
+                                    ComponentName compName = new ComponentName(
+                                            "com.collaboroid.dummy1", "com.collaboroid.dummy1.MainActivity");
+
+                                    Intent intent = new Intent(Intent.ACTION_MAIN);
+                                    intent.setComponent(compName);
+
+                                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+                                    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+                                    String resListarray[] = new String[addResourcesPerActivity.size()];
+                                    resListarray = addResourcesPerActivity.toArray(resListarray);
+                                    //resListarray[resListarray.length-1] = String.valueOf(SAMDService.remote_device_number);
+
+                                    intent.putExtra("SAWR", resListarray);
+
+                                    mContext.startActivity(intent);
+                                    SAMDService.DUMMY_BIT = !SAMDService.DUMMY_BIT;
+
+                                    ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+                                    List<ActivityManager.RunningAppProcessInfo> pidsTask = activityManager.getRunningAppProcesses();
+
+                                    for (int i = 0; i < pidsTask.size(); i++) {
+                                        Log.d("SBJSBJ processName", "SBJSBJ processName : " + pidsTask.get(i).processName);
+                                        Log.d("SBJSBJ processName", "SBJSBJ uid : " + pidsTask.get(i).uid);
+                                        Log.d("SBJSBJ processName", "SBJSBJ pid : " + pidsTask.get(i).pid);
+                                        if (pidsTask.get(i).processName.equals("com.collaboroid.dummy2")) {
+                                            android.os.Process.killProcess(pidsTask.get(i).pid);
+                                        }
+                                    }
+
+                                } else {
+                                    Log.d("samd experiment","aapt add/remove start["+activityName+"]");
+                                    pm.aaptAdd(2, "/system/priv-app/Dummy2/Dummy2.apk", "classes.dex");
+                                    File dexFile = new File("/collaboroid/agent/dex/" + activityName + "_classes.dex");
+                                    File classesDex = new File("/collaboroid/agent/dex/classes.dex");
+                                    dexFile.renameTo(classesDex);
+                                    pm.aaptAdd(1, "/system/priv-app/Dummy2/Dummy2.apk", "/collaboroid/agent/dex/classes.dex");
+                                    classesDex.renameTo(dexFile);
+
+                                    Log.d("samd experiment","aapt add/remove end["+activityName+"]");
+
+                                    ComponentName compName = new ComponentName(
+                                            "com.collaboroid.dummy2", "com.collaboroid.dummy2.MainActivity");
+
+                                    Intent intent = new Intent(Intent.ACTION_MAIN);
+
+                                    intent.setComponent(compName);
+
+                                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+                                    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+                                    String resListarray[] = new String[addResourcesPerActivity.size()];
+                                    resListarray = addResourcesPerActivity.toArray(resListarray);
+                                    //resListarray[resListarray.length-1] = String.valueOf(SAMDService.remote_device_number);
+                                    intent.putExtra("SAWR", resListarray);
+
+
+                                    mContext.startActivity(intent);
+                                    SAMDService.DUMMY_BIT = !SAMDService.DUMMY_BIT;
+
+                                    ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+                                    List<ActivityManager.RunningAppProcessInfo> pidsTask = activityManager.getRunningAppProcesses();
+
+                                    for (int i = 0; i < pidsTask.size(); i++) {
+                                        Log.d("SBJSBJ processName", "SBJSBJ processName : " + pidsTask.get(i).processName);
+                                        Log.d("SBJSBJ processName", "SBJSBJ uid : " + pidsTask.get(i).uid);
+                                        Log.d("SBJSBJ processName", "SBJSBJ pid : " + pidsTask.get(i).pid);
+                                        if (pidsTask.get(i).processName.equals("com.collaboroid.dummy1")) {
+                                            android.os.Process.killProcess(pidsTask.get(i).pid);
+                                        }
+                                    }
+                                }
+
+                                Log.d("uuuuuuu_sendActivity/WithResource",
+                                        "e-----------------------------------------------------------------------------------------------");
+                            }
+                        }else if(request.getType().equalsIgnoreCase("ResourcesTransfer")){
+                            if(request.getMethod().equalsIgnoreCase("getResourcesRL")){
+                                int remoteDeviceNum = (int) request.getPara().get(0);
+                                Log.d("samd experiment","receive mosaic image from "+ remoteDeviceNum);
+                                String appName = (String) request.getPara().get(1);
+                                int resourcesNum = (int) request.getPara().get(2);
+                                for (int i = 0, j = 3; i < resourcesNum; i++, j ++) {
+                                    String activityResDirectory = (String) request.getPara().get(j);
+                                    String split[] = activityResDirectory.split("/");
+                                    String baseDir = "/data/collaboroid/preprocess/" + appName+"/";
+                                    for(int z=0; z<split.length-1; z++){
+                                        baseDir += split[z]+"/";
+                                        File directory = new File(baseDir);
+                                        if(!directory.exists()){
+                                            directory.mkdir();
+                                        }
+                                    }
+                                    try {
+                                        //activity res
+                                        File activityResFile = new File("/data/collaboroid/preprocess/" + appName +"/"+activityResDirectory);
+                                        FileOutputStream fileOutputStream = new FileOutputStream(activityResFile);
+                                        fileOutputStream.write((byte[])request.getPara().get(j+1));
+                                        fileOutputStream.flush();
+                                        fileOutputStream.close();
+                                    } catch (Exception e) {
+                                        e.printStackTrace();
+                                    }
+                                }
+                            }
+                        }else if (request.getType().equalsIgnoreCase("sendFile")) {
+                            if (request.getMethod().equalsIgnoreCase("getAPK")) {
+
+                                Log.d("sendFile/getAPK",
+                                        "s-----------------------------------------------------------------------------------------------");
+                                Log.d("samd experiment", "receive APK File");
+
+
+                                byte[] APKbyte = (byte[]) request.getPara().get(0);
+                                String dir = (String) request.getPara().get(1);
+                                String pathSplit[] = dir.split("/");
+                                File APKFile = new File(dir);
+
+                                //check directory
+                                //0.03 ~ 0.04 sec
+                                String baseDir = "/";
+                                String permission = "777";
+                                for (int z = 1; z < pathSplit.length; z++) {
+                                    if(!pathSplit[z].contains(".apk")){
+                                        baseDir += pathSplit[z] +"/";
+                                        File directory = new File(baseDir);
+                                        if (!directory.exists()) {
+                                            directory.mkdir();
+                                        }
+                                    }else{
+                                        baseDir += pathSplit[z];
+                                        //0.01sec
+                                        FileOutputStream fileOutputStream = new FileOutputStream(APKFile);
+                                        fileOutputStream.write(APKbyte);
+                                        fileOutputStream.flush();
+                                        fileOutputStream.close();
+                                    }
+                                    
+                                    try {
+                                        String command = "chmod " + permission + " " + baseDir;
+                                        Runtime runtime = Runtime.getRuntime();
+                                        runtime.exec(command);
+                                    } catch (IOException e) {
+                                        e.printStackTrace();
+                                    }
+
+                                }
+
+                                Thread.sleep(3000);
+
+//                                final ApplicationManager am = new ApplicationManager(mContext);
+//                                am.setOnInstalledPackaged(new OnInstalledPackaged() {
+//                                    public void packageInstalled(String packageName, int returnCode) {
+//                                        if(returnCode == ApplicationManager.INSTALL_SUCCEEDED)
+//                                        {
+//                                            Log.d("samd experiment", "Install succeeded");
+//                                            Log.d("sendFile/getAPK",
+//                                                    "e-----------------------------------------------------------------------------------------------");
+//
+//                                            ComponentName compName = new ComponentName(
+//                                                    packageName, packageName+".SBJ_A");
+//
+//                                            Intent intent = new Intent(Intent.ACTION_MAIN);
+//
+//                                            intent.setComponent(compName);
+//
+//                                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+//                                            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+//                                            intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+//
+//                                            mContext.startActivity(intent);
+//                                        }else{
+//                                            Log.d("samd experiment", "Install failed: " + returnCode);
+//                                        }
+//                                    }
+//                                });
+//
+//                                Log.d("samd experiment",
+//                                        "APK file Install ["
+//                                                +
+//                                                dir.split("/")[dir.split("/").length-1] + "] start");
+//                                try {
+//                                    am.installPackage(dir);
+//                                } catch (Exception e) {
+//                                    e.printStackTrace();
+//                                }
+
+                            }
+                        }
+                    } finally {
+                        Binder.restoreCallingIdentity(origId);
+                    }
+                } else if (input instanceof RemoteMotionEvent) {
+                    // MotionEvent event = (MotionEvent)input;
+                    RemoteMotionEvent rme = (RemoteMotionEvent) input;
+
+                    // Log.d(TAG, "RemoteMotionEvent: " + rme.toString());
+
+                    /*
+                     * MotionEvent event = MotionEvent.obtain(
+                     * SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
+                     * rme.getAction(), rme.getX() *
+                     * RemoteRequestHandler.Xdefault, rme.getY() *
+                     * RemoteRequestHandler.Ydefault, 0);
+                     */
+                    /*
+                     * MotionEvent event = MotionEvent.obtain(rme.getDownTime(),
+                     * rme.getEventTime(), rme.getAction(), rme.getX()
+                     * RemoteRequestHandler.Xdefault, rme.getY()
+                     * RemoteRequestHandler.Ydefault, 0);
+                     * event.setSource(rme.getSource());
+                     */
+
+                    MotionEvent event = MotionEvent.obtain(
+                            SystemClock.uptimeMillis(),
+                            SystemClock.uptimeMillis(),
+                            rme.getAction(),
+                            rme.getX() * Xdefault,
+                            rme.getY() * Ydefault, sourceDevice << 24);
+
+                    event.setSource(rme.getSource());
+
+                    /*Log.d(TAG, "Node: " + sourceDevice);
+                    MotionEvent event;
+                    if (sourceDevice != 1) {
+                        event = MotionEvent.obtain(SystemClock.uptimeMillis(),
+                                SystemClock.uptimeMillis(), rme.getAction(), 500, 500, 0);
+                        event.setSource(rme.getSource());
+                    }
+                    else {
+                        event = MotionEvent.obtain(
+                                SystemClock.uptimeMillis(),
+                                SystemClock.uptimeMillis(),
+                                (rme.getAction() + (sourceDevice << 24)),
+                                rme.getX() * RemoteRequestHandler.Xdefault,
+                                rme.getY() * RemoteRequestHandler.Ydefault, 0);
+
+                        event.setSource(rme.getSource());
+                    }*/
+                    try {
+                        if (!mInputService.injectInputEvent(event,
+                                InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT)) {
+                            Log.d(TAG, "FAIL!!!!!");
+                        }
+                    } finally {
+                        event.recycle();
+                    }
+                }
+                /*
+                 * else if(input instanceof RemoteKeyEvent) { }
+                 */
+
+                else if (input instanceof RemoteKeyEvent) {
+                    RemoteKeyEvent rke = (RemoteKeyEvent) input;
+                    // Log.d(TAG, rke.toString());
+
+                    mInstrumentation.sendKeyDownUpSync(rke.getCode());
+                    if (rke.getAction() == KeyEvent.ACTION_DOWN) {
+                        Log.d("KeyLatency", "KeyLatency - server: " + sourceDevice);
+                    }
+                    /*
+                     * KeyEvent event = new KeyEvent(rke.getAction(),
+                     * rke.getCode()); event.setSource(rke.getSource()); try {
+                     * if (!mInputService.injectInputEvent(event,
+                     * InputManager.INJECT_INPUT_EVENT_MODE_ASYNC)) { Log.d(TAG,
+                     * "FAIL!!!!!"); } } finally { event.recycle(); }
+                     */
+                } else if (input instanceof RemoteSensorEvent) {
+                    RemoteSensorEvent rse = (RemoteSensorEvent) input;
+
+                    /*if(rse.getType() == Sensor.TYPE_PROXIMITY)
+                    	sendRemoteEvent(21, 21, rse.getValues(),
+                                rse.getAccuracy(),
+                                rse.getTimestamp(),
+                                sourceDevice);
+                    else
+                    	sendRemoteEvent(rse.getType(),
+                    		RemoteService.mSensorHandles.get(rse.getType()),
+                    		rse.getValues(),
+                    		rse.getAccuracy(),
+                    		rse.getTimestamp(),
+                    		sourceDevice);*/
+                } else if (input instanceof SdPackage) {
+                    // Log.d(TAG,
+                    // "music play start from request handler (SdPackage)");
+                    noOutputCounter++;
+                    // read a buffer before feeding it to the decoder
+                    if (!sawInputEOS) {
+                        int inputBufIndex = codec.dequeueInputBuffer(TIMEOUT_US);
+                        if (inputBufIndex >= 0) {
+                            ByteBuffer dstBuf = codecInputBuffers[inputBufIndex];
+
+                            SdPackage sdp = (SdPackage) input;
+                            // Log.i(TAG, sdp.toString());
+
+                            sampleSize = sdp.getSampleSize();
+                            byte[] temp_bytearray = new byte[sampleSize];
+                            temp_bytearray = sdp.getSampleData();
+                            // Log.i(TAG, Arrays.toString(temp_bytearray));
+                            dstBuf.clear();
+                            // dstBuf = ByteBuffer.wrap(temp_bytearray);
+                            dstBuf.put(temp_bytearray);
+                            presentationTimeUs = sdp.getPresentationTime();
+
+                            codec.queueInputBuffer(inputBufIndex, 0,
+                                    sampleSize, presentationTimeUs, 0);
+
+                            // Log.d(TAG, "client: queued to inputbuffer " +
+                            // inputBufIndex);
+                            // if (!sawInputEOS) //remote
+                            // extractor.advance(); //remote
+
+                        } else {
+                            // Log.e(TAG, "client: inputBufIndex " +
+                            // inputBufIndex);
+                        }
+                    } // !sawInputEOS
+
+                    // ///////////////////////////////////////////////////////
+                    // MediaCodecInfo df = codec.getCodecInfo();
+                    // byte[] dddd = new byte[8192];
+                    // for(int i=0;i<codecInputBuffers.length;i++){
+                    // for(int j=0;j<codecInputBuffers[i].limit();j++){
+                    // dddd[j] = codecInputBuffers[i].get(j);
+                    // }
+                    // Log.d("debugging", Arrays.toString(dddd));
+                    // }
+
+                    // /////////////////////////////////////////////////////
+
+                    // for (int i = 0; i < codecOutputBuffers.length; i++) {
+                    // Log.d(TAG, String.valueOf(codecOutputBuffers[i]
+                    // .remaining()));
+                    // }
+
+                    // decode to PCM and push it to the AudioTrack player
+                    int res = codec.dequeueOutputBuffer(info, 5000);
+
+                    if (res >= 0) {
+                        int outputBufIndex = res;
+                        ByteBuffer buf = codecOutputBuffers[outputBufIndex];
+                        // ByteBuffer buf =
+                        // codec.getOutputBuffer(outputBufIndex);
+
+                        final byte[] chunk = new byte[info.size];
+                        buf.get(chunk);
+                        buf.clear();
+                        if (chunk.length > 0) {
+                            audioTrack.write(chunk, 0, chunk.length);
+                        }
+
+                        codec.releaseOutputBuffer(outputBufIndex, false);
+
+                        if ((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
+                            Log.d(TAG, "saw output EOS.");
+                            sawOutputEOS = true;
+                        }
+                    } else if (res == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
+                        Log.d(TAG,
+                                "oh! information of output buffer has been changed");
+                        codecOutputBuffers = codec.getOutputBuffers();
+                        Log.d(TAG, "output buffers have changed.");
+                    } else if (res == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
+                        Log.d(TAG, "oh! the output format changed!");
+                        MediaFormat oformat = codec.getOutputFormat();
+                        Log.d(TAG, "output format has changed to "
+                                + oformat);
+                    } else {
+                        Log.d(TAG, "dequeueOutputBuffer returned " + res);
+                    }
+
+                    // Log.d("TAG", String.valueOf(noOutputCounter));
+
+                } else if (input instanceof RemoteLocation) {
+                    RemoteLocation RL = (RemoteLocation) input;
+
+                    location = new Location("");
+
+                    // location.reset();
+                    // location.setProvider(RL.getProvider());
+                    location.setProvider(LocationManager.REMOTE_PROVIDER);
+                    // location.setTime(RL.getTime());
+                    location.setTime(System.currentTimeMillis());
+                    // location.setElapsedRealtimeNanos(RL.getElapsedRealtimeNanos());
+                    location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
+                    location.setLatitude(RL.getLatitude());
+                    location.setLongitude(RL.getLongitude());
+
+                    if (RL.getAltitude() != 0.0f)
+                        location.setAltitude(RL.getAltitude());
+                    if (RL.getSpeed() != 0.0f)
+                        location.setSpeed(RL.getSpeed());
+                    if (RL.getBearing() != 0.0f)
+                        location.setBearing(RL.getBearing());
+                    if (RL.getAccuracy() != 0.0f)
+                        location.setAccuracy(RL.getAccuracy());
+
+                    location.setExtras(RL.getExtras());
+                    location.setIsFromMockProvider(RL.isFromMockProvider());
+
+                    if (location.getExtras() != null)
+                        location.getExtras().putInt("SourceDevice", sourceDevice);
+                    else {
+                        Bundle bundle = new Bundle();
+                        bundle.putInt("SourceDevice", sourceDevice);
+                        location.setExtras(bundle);
+                    }
+
+                    mLocationManager.reportLocation(location, false);
+                } else
+                    Log.d(TAG, "What is this??");
+
+                // input.
+            }
+
+            clientSocket.close();
+            inFromClient.close();
+            outToClient.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public PackageParser.Package getPackageInfo(File sourceFile) {
+        final PackageParser parser = new PackageParser();
+        try {
+            PackageParser.Package pkg = parser.parseMonolithicPackage(sourceFile, 0);
+            parser.collectManifestDigest(pkg);
+            return pkg;
+        } catch (PackageParser.PackageParserException e) {
+            return null;
+        }
+    }
+
+    public Intent apkInstall(Uri apkUri, File APKFile) {
+        boolean enabled = false;
+        //apk Install Process
+        mPm = mContext.getPackageManager();
+        mInstaller = mPm.getPackageInstaller();
+        parsed = getPackageInfo(APKFile);
+
+        mPkgInfo = PackageParser.generatePackageInfo(parsed, null,
+                PackageManager.GET_PERMISSIONS, 0, 0, null,
+                new PackageUserState());
+        mPkgDigest = parsed.manifestDigest;
+        String pkgName = mPkgInfo.packageName;
+        // Check if there is already a package on the device with this name
+        // but it has been renamed to something else.
+        String[] oldName = mPm.canonicalToCurrentPackageNames(new String[]{pkgName});
+        if (oldName != null && oldName.length > 0 && oldName[0] != null) {
+            pkgName = oldName[0];
+            mPkgInfo.packageName = pkgName;
+            mPkgInfo.applicationInfo.packageName = pkgName;
+        }
+        try {
+            // This is a little convoluted because we want to get all uninstalled
+            // apps, but this may include apps with just data, and if it is just
+            // data we still want to count it as "installed".
+            mAppInfo = mPm.getApplicationInfo(pkgName,
+                    PackageManager.GET_UNINSTALLED_PACKAGES);
+            if ((mAppInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
+                mAppInfo = null;
+            }
+        } catch (PackageManager.NameNotFoundException e) {
+            mAppInfo = null;
+        }
+
+        String installerPackageName = null;
+        //installerPackageName is null
+
+        Uri originatingURI = apkUri;
+        //exist
+
+        int originatingUid = 1000;
+
+        ManifestDigest manifestDigest = mPkgDigest;
+        //exist
+
+        VerificationParams verificationParams = new VerificationParams(null, originatingURI,
+                null, originatingUid, manifestDigest);
+        int installFlags = 0;
+        try {
+            PackageInfo pi = mPm.getPackageInfo(mAppInfo.packageName,
+                    PackageManager.GET_UNINSTALLED_PACKAGES);
+            if (pi != null) {
+                installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
+            }
+        } catch (PackageManager.NameNotFoundException e) {
+        }
+        if ((installFlags & PackageManager.INSTALL_REPLACE_EXISTING) != 0) {
+            Log.w(TAG, "Replacing package:" + mAppInfo.packageName);
+        }
+
+
+        PackageInstallObserver observer = new PackageInstallObserver();
+
+        mPm.installPackageWithVerificationAndEncryption(apkUri, observer, installFlags,
+                installerPackageName, verificationParams, null);
+        //2th observer = nulls
+        //but is not confident
+
+        mLaunchIntent = mContext.getPackageManager().getLaunchIntentForPackage(
+                mAppInfo.packageName);
+
+        if (mLaunchIntent != null) {
+            List<ResolveInfo> list = mContext.getPackageManager().
+                    queryIntentActivities(mLaunchIntent, 0);
+            if (list != null && list.size() > 0) {
+                enabled = true;
+            }
+        }
+        return mLaunchIntent;
+    }
+
+    public Activity getActivity() {
+        Activity activity = null;
+        try {
+            Class activityThreadClass = Class.forName("android.app.ActivityThread");
+            Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
+            Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
+            activitiesField.setAccessible(true);
+            ArrayMap activities = (ArrayMap) activitiesField.get(activityThread);
+            for (Object activityRecord : activities.values()) {
+                Class activityRecordClass = activityRecord.getClass();
+                Field pausedField = activityRecordClass.getDeclaredField("paused");
+                pausedField.setAccessible(true);
+                if (!pausedField.getBoolean(activityRecord)) {
+                    Field activityField = activityRecordClass.getDeclaredField("activity");
+                    activityField.setAccessible(true);
+                    activity = (Activity) activityField.get(activityRecord);
+
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return activity;
+    }
+
+    public void restart(Context context, int delay) {
+        if (delay == 0) {
+            delay = 1;
+        }
+        Log.d("SBJSBJ restart", "SBJSBJ retart");
+        Intent restartIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
+        PendingIntent intent = PendingIntent.getActivity(context, 0, restartIntent, Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+        manager.set(AlarmManager.RTC, System.currentTimeMillis() + delay, intent);
+        System.exit(2);
+    }
+
+    public static boolean saveBitmaptoJpeg(Bitmap bitmap, String folder, String name) {
+        String ex_storage = "collaboroid/preprocess/MosaicApp/";
+        // Get Absolute Path in External Sdcard
+        String foler_name = "/" + folder + "/";
+        String file_name = name + ".jpg";
+        String string_path = ex_storage + foler_name;
+
+        File file_path;
+        try {
+            file_path = new File(string_path);
+            if (!file_path.isDirectory()) {
+                file_path.mkdirs();
+            }
+            FileOutputStream out = new FileOutputStream(string_path + file_name);
+
+            bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
+
+            out.close();
+
+        } catch (FileNotFoundException exception) {
+            Log.e("FileNotFoundException", exception.getMessage());
+        } catch (IOException exception) {
+            Log.e("IOException", exception.getMessage());
+        }
+
+        return true;
+    }
+
+    private Bitmap combineImage(Bitmap first, Bitmap second, boolean isVerticalMode) {
+        BitmapFactory.Options option = new BitmapFactory.Options();
+        option.inDither = true;
+        option.inPurgeable = true;
+        Bitmap bitmap = null;
+        if (isVerticalMode)
+            bitmap = Bitmap.createScaledBitmap(first, first.getWidth(), first.getHeight() + second.getHeight(), true);
+        else
+            bitmap = Bitmap.createScaledBitmap(first, first.getWidth() + second.getWidth(), first.getHeight(), true);
+        Paint p = new Paint();
+        p.setDither(true);
+        p.setFlags(Paint.ANTI_ALIAS_FLAG);
+        Canvas c = new Canvas(bitmap);
+        c.drawBitmap(first, 0, 0, p);
+        if (isVerticalMode)
+            c.drawBitmap(second, 0, first.getHeight(), p);
+        else
+            c.drawBitmap(second, first.getWidth(), 0, p);
+        first.recycle();
+        second.recycle();
+        return bitmap;
+    }
+
+    public byte[] bitmapToByteArray(Bitmap $bitmap) {
+        ByteArrayOutputStream stream = new ByteArrayOutputStream();
+        $bitmap.compress(Bitmap.CompressFormat.JPEG, 90, stream);
+        byte[] byteArray = stream.toByteArray();
+        return byteArray;
+    }
+
+    public Bitmap byteArrayToBitmap(byte[] $byteArray) {
+        Bitmap bitmap = BitmapFactory.decodeByteArray($byteArray, 0, $byteArray.length);
+        return bitmap;
+    }
+
+    private Bitmap decodeFile(File f) {
+        try {
+            BitmapFactory.Options o = new BitmapFactory.Options();
+            o.inJustDecodeBounds = true;
+            BitmapFactory.decodeStream(new FileInputStream(f), null, o);
+
+            final int REQUIRED_SIZE = 70;
+
+            int scale = 1;
+            while (o.outWidth / scale / 2 >= REQUIRED_SIZE &&
+                    o.outHeight / scale / 2 >= REQUIRED_SIZE) {
+                scale *= 2;
+            }
+
+            BitmapFactory.Options o2 = new BitmapFactory.Options();
+            o2.inSampleSize = scale;
+            return BitmapFactory.decodeStream(new FileInputStream(f), null, o2).copy(Bitmap.Config.ARGB_8888, true);
+        } catch (FileNotFoundException e) {
+        }
+        return null;
+    }
+
+    private byte[] decompress(byte[] data) throws IOException, DataFormatException {
+        Inflater inflater = new Inflater();
+        inflater.setInput(data);
+
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
+        byte[] buffer = new byte[4096];
+        while (!inflater.finished()) {
+            int count = inflater.inflate(buffer);
+            outputStream.write(buffer, 0, count);
+        }
+        outputStream.close();
+        byte[] output = outputStream.toByteArray();
+
+        inflater.end();
+
+        Log.d("mosaic_distribute", "Original : " + data.length);
+        Log.d("mosaic_distribute", "UnCompressed : " + output.length);
+
+        return output;
+    }
+
+    private void DeleteRecursiveFiles(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursive(child);
+
+    }
+
+    private void DeleteRecursive(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursive(child);
+
+        fileOrDirectory.delete();
+
+    }
+
+    private void DeleteRecursiveFilesNotFolder(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursiveNotFolder(child);
+
+    }
+
+    private void DeleteRecursiveNotFolder(File fileOrDirectory) {
+        if (fileOrDirectory.isDirectory()) {
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursive(child);
+        } else {
+            fileOrDirectory.delete();
+        }
+    }
+
+    public static void LaunchInstalledAPK(Message msg) {
+        final int INSTALL_COMPLETE = 1;
+        Log.d("install apk", "LaunchInstalledAPK msg.what : " + msg.what);
+        Log.d("install apk", "LaunchInstalledAPK msg.arg1 : " + msg.arg1);
+        switch (msg.what) {
+            case INSTALL_COMPLETE:
+                if (msg.arg1 == PackageManager.INSTALL_SUCCEEDED) {
+                    Log.d("install apk", "LaunchInstalledAPK PackageManagerService.SAMDMessage.arg1 : " +
+                            PackageManagerService.SAMDMessage.arg1);
+                    mLaunchIntent = SAMDContext.
+                            getPackageManager().
+                            getLaunchIntentForPackage(
+                                    SAMDAppInfo.packageName);
+                    boolean enabled = false;
+                    if (mLaunchIntent != null) {
+                        List<ResolveInfo> list = SAMDContext.
+                                getPackageManager().
+                                queryIntentActivities(mLaunchIntent, 0);
+                        if (list != null && list.size() > 0) {
+                            enabled = true;
+                        }
+                    }
+                    if (enabled) {
+                        //설치완료되면 button 활성화
+                        Log.d("install apk", "enabled is true");
+                        mLaunchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                        mLaunchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+                        mLaunchIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+                        SAMDContext.startActivity(mLaunchIntent);
+                    }
+                }
+        }
+
+    }
+
+    public void copy(File src, File dst) throws IOException{
+        InputStream in = new FileInputStream(src);
+        try{
+            OutputStream out = new FileOutputStream(dst);
+            try{
+                byte[] buf = new byte[4096];
+                int len;
+                while( (len=in.read(buf)) > 0){
+                    out.write(buf, 0, len);
+                }
+            }finally {
+                out.close();
+
+            }
+        }finally {
+            in.close();
+        }
+    }
+    public void createDirAndFile(String dir, byte[] dexByte){
+        String pathSplit[] = dir.split("/");
+        String baseDir = "/collaboroid/agent/activity_res/";
+        for (int z = 0; z < pathSplit.length; z++) {
+            if(pathSplit[z].contains(".png") || pathSplit[z].contains(".xml")
+                    || pathSplit[z].contains(".jpg") || pathSplit[z].contains(".jpeg")){
+                baseDir += pathSplit[z];
+                File activityResFile = new File("/collaboroid/agent/activity_res/" + dir);
+                try {
+                    //activity res
+                    FileOutputStream fileOutputStream = new FileOutputStream(activityResFile);
+                    fileOutputStream.write(dexByte);
+                    fileOutputStream.flush();
+                    fileOutputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }else{
+                baseDir += pathSplit[z] +"/";
+                File directory = new File(baseDir);
+                if (!directory.exists()) {
+                    directory.mkdir();
+                }
+            }
+            Log.d("uuuuuuu_DexCode", "baseDir : : " + baseDir);
+        }
+    }
+    public void AndroidManifestDummy(String dexName) {
+        String[] DummyxmlLine =
+                {"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
+                        "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"",
+                        "package=\"com.collaboroid.dummy1\">",
+                        "android:versionCode=\"1\"",
+                        "android:versionName=\"1.0\"",
+                        "<uses-permission android:name=\"android.permission.INTERNET\"/>",
+                        "<uses-permission android:name=\"android.permission.KILL_BACKGROUND_PROCESSES\"/>",
+                        "<application",
+                        "android:icon=\"@drawable/ic_launcher\"",
+                        "android:label=\"@string/Main_title\">",
+                        "<activity android:name=\".MainActivity\"",
+                        "android:label=\"@string/Main_title\"",
+                        "android:launchMode=\"singleTask\"",
+                        "android:clearTaskOnLaunch=\"true\">",
+                        "<intent-filter>",
+                        "<action android:name=\"android.intent.action.MAIN\" />",
+                        "<category android:name=\"android.intent.category.LAUNCHER\" />",
+                        "</intent-filter>",
+                        "</activity>",
+                        "</application>",
+                        "</manifest>"};
+        String dummy1FileName = "/collaboroid/agent/activity_res/"+dexName+"/AndroidManifest.xml";
+        BufferedWriter bw = null;
+        try {
+            bw = new BufferedWriter(new FileWriter(dummy1FileName));
+            for(int i=0; i<DummyxmlLine.length; i++){
+                bw.write(DummyxmlLine[i]);
+                bw.newLine();
+
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally{
+            try {
+                if (bw != null)
+                    bw.close();
+            } catch (IOException e) {
+
+            }
+        }
+    }
+
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteKeyEvent.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteKeyEvent.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteKeyEvent.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteKeyEvent.java	2017-01-29 02:51:16.645856000 +0900
@@ -0,0 +1,34 @@
+package com.android.server.remote;
+
+import java.io.Serializable;
+
+public class RemoteKeyEvent implements Serializable
+{
+	private static final long serialVersionUID = 1L;
+
+	private final int action;
+	private final int code;
+	private final int source;
+	
+	public RemoteKeyEvent(int action, int code, int source)
+	{
+		this.action = action;
+		this.code = code;
+		this.source = source;
+	}
+	
+	public int getAction()
+	{
+		return action;
+	}
+	
+	public int getCode()
+	{
+		return code;
+	}
+	
+	public int getSource()
+	{
+		return source;
+	}
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteLocation.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteLocation.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteLocation.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteLocation.java	2017-01-29 02:51:16.649856000 +0900
@@ -0,0 +1,93 @@
+package com.android.server.remote;
+
+import java.io.Serializable;
+
+import android.location.Location;
+import android.os.Bundle;
+
+public class RemoteLocation implements Serializable
+{
+	private static final long serialVersionUID = 1L;
+	
+	private final String mProvider;
+    private final long mTime;
+    private final long mElapsedRealtimeNanos;
+    private final double mLatitude;
+    private final double mLongitude;
+    private final double mAltitude;
+    private final float mSpeed;
+    private final float mBearing;
+    private final float mAccuracy;
+    private final Bundle mExtras;
+    private final boolean mIsFromMockProvider;
+    
+    public RemoteLocation(Location l)
+    {
+    	mProvider = l.getProvider();
+        mTime = l.getTime();
+        mElapsedRealtimeNanos = l.getElapsedRealtimeNanos();
+        mLatitude = l.getLatitude();
+        mLongitude = l.getLongitude();
+        mAltitude = l.getAltitude();
+        mSpeed = l.getSpeed();
+        mBearing = l.getBearing();
+        mAccuracy = l.getAccuracy();
+        mExtras = (l.getExtras() == null) ? null : new Bundle(l.getExtras());
+        mIsFromMockProvider = l.isFromMockProvider();
+    }
+    
+    public String getProvider()
+    {
+    	return mProvider;
+    }
+
+	public long getTime()
+	{
+		return mTime;
+	}
+
+	public long getElapsedRealtimeNanos()
+	{
+		return mElapsedRealtimeNanos;
+	}
+
+	public double getLatitude()
+	{
+		return mLatitude;
+	}
+
+	public double getLongitude()
+	{
+		return mLongitude;
+	}
+
+	public double getAltitude()
+	{
+		return mAltitude;
+	}
+
+	public float getSpeed()
+	{
+		return mSpeed;
+	}
+
+	public float getBearing()
+	{
+		return mBearing;
+	}
+
+	public float getAccuracy()
+	{
+		return mAccuracy;
+	}
+
+	public Bundle getExtras()
+	{
+		return mExtras;
+	}
+
+	public boolean isFromMockProvider()
+	{
+		return mIsFromMockProvider;
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteMotionEvent.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteMotionEvent.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteMotionEvent.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteMotionEvent.java	2017-01-29 02:51:16.637856000 +0900
@@ -0,0 +1,60 @@
+package com.android.server.remote;
+
+import java.io.Serializable;
+
+public class RemoteMotionEvent implements Serializable
+{
+	private static final long serialVersionUID = 1L;
+	
+	private final long downTime;
+	private final long eventTime;
+	private final float x;
+	private final float y;
+	private final int action;
+	private final int source;
+	
+	public RemoteMotionEvent(long downTime, long eventTime, float x, float y, int action, int source)
+	{
+		this.downTime = downTime;
+		this.eventTime = eventTime;
+		this.x = x;
+		this.y = y;
+		this.action = action;
+		this.source = source;
+	}
+	
+	public long getDownTime()
+	{
+		return downTime;
+	}
+	
+	public long getEventTime()
+	{
+		return eventTime;
+	}
+	
+	public float getX()
+	{
+		return x;
+	}
+	
+	public float getY()
+	{
+		return y;
+	}
+	
+	public int getAction()
+	{
+		return action;
+	}
+	
+	public int getSource()
+	{
+		return source;
+	}
+	
+	public String toString()
+	{
+		return "(" + x + ", " + y + ")";
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteSensorEvent.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteSensorEvent.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteSensorEvent.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteSensorEvent.java	2017-01-29 02:51:16.637856000 +0900
@@ -0,0 +1,53 @@
+package com.android.server.remote;
+
+import java.io.Serializable;
+
+public class RemoteSensorEvent implements Serializable
+{
+	private static final long serialVersionUID = 1L;
+	
+	private int type;
+	private int sensor;
+	private float values[];
+	private int accuracy;
+	private long timestamp;
+	
+	public RemoteSensorEvent(int type, int sensor, float[] values, int accuracy, long timestamp)
+	{
+		this.type = type;
+		this.sensor = sensor;
+		this.values = values;
+		this.accuracy = accuracy;
+		this.timestamp = timestamp;
+	}
+	
+	public int getType()
+	{
+		return type;
+	}
+	
+	public int getSensor()
+	{
+		return sensor;
+	}
+	
+	public float[] getValues()
+	{
+		return values;
+	}
+	
+	public int getAccuracy()
+	{
+		return accuracy;
+	}
+	
+	public long getTimestamp()
+	{
+		return timestamp;
+	}
+	
+	public String toString()
+	{
+		return "(" + type + ": " + values[0] + ", " + values[1] + ")";
+	}
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteService.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteService.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/RemoteService.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/RemoteService.java	2017-09-15 16:57:43.013970000 +0900
@@ -0,0 +1,928 @@
+package com.android.server.remote;
+
+import java.io.*;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import com.android.server.devicemanagement.DeviceManagementService;
+//import android.hardware.SensorEventQueue2;
+
+import android.content.Context;
+import android.content.pm.IPackageManager;
+import android.content.res.ABCManager;
+import android.hardware.Sensor;
+import android.hardware.SensorEventListener;
+import android.hardware.input.IInputManager;
+import android.hardware.input.InputManager;
+import android.location.ILocationManager;
+import android.location.Location;
+import android.location.LocationManager;
+import android.media.MediaPlayer;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemClock;
+import android.os.Vibrator;
+import android.service.collaboroid.IGeneralMessageListener;
+import android.service.devicemanagement.Device;
+import android.service.devicemanagement.IDeviceManagementService;
+import android.service.remote.AppendingObjectOutputStream;
+import android.service.remote.IRemoteService;
+import android.service.remote.RemoteRequest;
+import android.service.remote.SdPackage;
+import android.util.Log;
+import android.util.SparseArray;
+import android.util.SparseIntArray;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+
+public class RemoteService extends IRemoteService.Stub
+{
+	private String dexServerIP = "192.168.219.104";
+	IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+	private static final String TAG = "RemoteService";
+	// private static final int SERVERPORT = 55555;
+
+	// For Settings
+	// private static boolean isEnabled = false;
+	public static boolean ServerOn = false;
+	public static boolean isConnectedToServer = false;
+
+	private static String serverIP;
+
+	// For Server
+	private Listener server = null;
+	private Thread serverThread = null;
+	private List<String> clientIPs = new ArrayList<String>();
+
+	// For Data Server
+	private DataListener dataServer = null;
+	private Thread dataServerThread = null;
+
+	/*
+	 * private Socket clientSocket; private ObjectInputStream inFromClient;
+	 */
+
+	// For Client
+	private Thread clientThread = null;
+	private List<String> serverIPs = new ArrayList<String>();
+
+	// For handling connected devices
+	public static ArrayList<String> connectedDevices;
+	public static HashMap<String, Socket> deviceToSocket;
+	public static HashMap<String, AppendingObjectOutputStream> deviceToOutput;
+	public static HashMap<String, ObjectInputStream> deviceToInput;
+	public static SparseArray<ArrayList<AppendingObjectOutputStream>> resourceToOutput;
+	public static SparseArray<ArrayList<ObjectInputStream>> resourceToInput;
+	public static ArrayList<AppendingObjectOutputStream> toRemoteActivityServer;
+	public static HashMap<String, Integer> deviceToSN; // device ip to source device number
+
+
+	public static HashMap<String, Socket> deviceToSocketforData; // device ip to source device number for resource and dex
+	public static HashMap<String, AppendingObjectOutputStream> deviceToOutputforData;
+	public static HashMap<String, ObjectInputStream> deviceToInputforData;
+	public static HashMap<String, Integer> deviceToSNforData; // device ip to source device number
+	public static SparseArray<ArrayList<AppendingObjectOutputStream>> resourceToOutputforData;
+	public static SparseArray<ArrayList<ObjectInputStream>> resourceToInputforData;
+
+	/*
+     * devices which wait for response of resource request
+     * device ip to output stream
+     */
+
+	public static HashMap<String, ObjectOutputStream> waitForResponse;
+
+	/*
+	 * private static Socket socketToServer; private static ObjectOutputStream
+	 * out; private static AppendingObjectOutputStream outToServer;
+	 */
+	public static Sender mSender;
+
+	private DeviceManagementService mDeviceService;
+	//private IInputManager im;
+
+	// for SensorEvent
+	public static SparseIntArray mSensorHandles = new SparseIntArray();
+	public static SparseIntArray mTypeToNumber = new SparseIntArray();
+	public static SparseIntArray mNumberToType = new SparseIntArray();
+	private boolean remoteSensorOn = false;
+	public static SensorEventListener mRemoteListener = null;
+
+	// for sending activity
+	public static final int NUM_DUMMY = 2;
+	public static int CURRENT_DUMMY = 2;
+	public String privText = "BUTTON";
+	public static boolean isFirstTime = true;
+	public static ABCManager ABCForDummy[] = new ABCManager[NUM_DUMMY];
+
+	public static Context mContext;
+
+	public static int testValue = 0;
+
+	// for general message
+	private final RemoteCallbackList<IGeneralMessageListener> mListeners = new RemoteCallbackList<IGeneralMessageListener>();
+
+	// native functions
+	//native void setServerOn(boolean flag);
+	//native void sendRemoteEvent(int type, int sensor, float[] values, int accuracy, long timestamp, int sourceDevice);
+
+	public RemoteService(Context context)
+	{
+		mContext = context;
+		mSender = new Sender(context);
+
+		initRemoteService();
+
+	}
+
+	public boolean isServerOn()
+	{
+		return ServerOn;
+	}
+
+	public void initRemoteService()
+	{
+
+
+		connectedDevices = new ArrayList<String>();
+		deviceToOutput = new HashMap<String, AppendingObjectOutputStream>();
+		deviceToInput = new HashMap<String, ObjectInputStream>();
+		deviceToSocket = new HashMap<String, Socket>();
+		resourceToOutput = new SparseArray<ArrayList<AppendingObjectOutputStream>>();
+		resourceToInput = new SparseArray<ArrayList<ObjectInputStream>>();
+
+		waitForResponse = new HashMap<String, ObjectOutputStream>();
+		deviceToSN = new HashMap<String, Integer>();
+		toRemoteActivityServer = new ArrayList<AppendingObjectOutputStream>();
+
+		//SAMD
+		resourceToOutputforData = new SparseArray<ArrayList<AppendingObjectOutputStream>>();
+		resourceToInputforData = new SparseArray<ArrayList<ObjectInputStream>>();
+		deviceToSocketforData = new HashMap<String, Socket>(); // device ip to source device number for resource and dex
+		deviceToOutputforData = new HashMap<String, AppendingObjectOutputStream>();
+		deviceToInputforData = new HashMap<String, ObjectInputStream>();
+		deviceToSNforData = new HashMap<String, Integer>(); // device ip to source device number
+
+		for(int i=0; i<Device.RESOURCE_TYPE_SIZE; i++){
+			resourceToOutput.append(i, new ArrayList<AppendingObjectOutputStream>());
+			resourceToInput.append(i, new ArrayList<ObjectInputStream>());
+			//SAMD
+			resourceToOutputforData.append(i, new ArrayList<AppendingObjectOutputStream>());
+			resourceToInputforData.append(i, new ArrayList<ObjectInputStream>());
+
+		}
+
+
+		mTypeToNumber.put(Sensor.TYPE_ORIENTATION, 0);
+		mTypeToNumber.put(Sensor.TYPE_PROXIMITY, 1);
+
+		mNumberToType.put(0, Sensor.TYPE_ORIENTATION);
+		mNumberToType.put(1, Sensor.TYPE_PROXIMITY);
+
+	}
+
+	public void initConnections()
+	{
+		try
+		{
+			if(connectedDevices.size() > 0)
+				for(String deviceIP : connectedDevices)
+				{
+					deviceToSocket.get(deviceIP).close();
+					deviceToOutput.get(deviceIP).close();
+				}
+		}
+		catch (IOException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		connectedDevices.clear();
+		deviceToOutput.clear();
+		deviceToSocket.clear();
+		//resourceToOutput.clear();
+		waitForResponse.clear();
+		deviceToSN.clear();
+
+		for(int i=0; i<Device.RESOURCE_TYPE_SIZE; i++){
+			resourceToOutput.get(i).clear();
+			resourceToOutputforData.get(i).clear();
+		}
+
+		toRemoteActivityServer.clear();
+
+		mTypeToNumber.clear();
+		mTypeToNumber.put(Sensor.TYPE_ORIENTATION, 0);
+		mTypeToNumber.put(Sensor.TYPE_PROXIMITY, 1);
+
+		mNumberToType.clear();
+		mNumberToType.put(0, Sensor.TYPE_ORIENTATION);
+		mNumberToType.put(1, Sensor.TYPE_PROXIMITY);
+	}
+
+	@Override
+	public boolean startServer()
+	{
+		// TODO Auto-generated method stub
+		//collaboroid settings -> left right button
+		if (!ServerOn)
+		{
+			server = new Listener(mContext);
+			serverThread = new Thread(server);
+			Log.d(TAG, "Starting Listener!");
+			serverThread.start();
+
+
+			//SADM
+			dataServer = new DataListener(mContext);
+			dataServerThread = new Thread(dataServer);
+			Log.d(TAG, "Starting Data Listener");
+			dataServerThread.start();
+
+			ServerOn = true;
+			//setServerOn(true);
+
+			ILocationManager mLocationManager = ILocationManager.Stub.asInterface(ServiceManager.getService("location"));
+			try
+			{
+				mLocationManager.setRemoteProviderEnabled(true);
+			} catch (RemoteException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+
+		//Client 1
+		Log.d(TAG, "startServer - onServer: " + ServerOn);
+
+		return ServerOn;
+	}
+
+	@Override
+	public boolean stopServer()
+	{
+		Log.d(TAG, "HELLO - 0");
+
+		// TODO Auto-generated method stub
+		if (ServerOn)
+		{
+			Log.d(TAG, "Stopping Listener: " + serverThread);
+			if (serverThread != null)
+			{
+				server.terminate();
+				serverThread.interrupt();
+
+				//SAMD
+				dataServer.terminate();
+				dataServerThread.interrupt();
+
+				ServerOn = false;
+				//setServerOn(false);
+
+				ILocationManager mLocationManager = ILocationManager.Stub.asInterface(ServiceManager.getService("location"));
+				try
+				{
+					mLocationManager.setRemoteProviderEnabled(false);
+				} catch (RemoteException e)
+				{
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		}
+
+		Log.d(TAG, "End stopServer - onServer: " + ServerOn);
+
+		return !ServerOn;
+	}
+
+	@Override
+	public List<String> getClientIPs(){
+		return clientIPs = Listener.getClientIPs();
+	}
+
+	@Override
+	public List<String> getServerIPs(){
+		return serverIPs;
+	}
+
+
+
+	@Override
+	public void sendAllrequest(RemoteRequest request)
+	{
+		mSender.sendRequestToEveryDevices(request);
+	}
+
+	@Override
+	public void sendAllMusic(int sampleSize, byte[] sampleData, long presentationTime){
+//        Log.d(TAG, "Music testing");
+
+		SdPackage MDtoSend = new SdPackage(sampleSize, sampleData, presentationTime);
+
+
+        /*Collection<AppendingObjectOutputStream> temp = connectedDevices.values();
+        for (AppendingObjectOutputStream outToServer : temp){
+            try {
+                outToServer.writeObject(MDtoSend);
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }*/
+	}
+
+	@Override
+	public void setConfiguration()
+	{
+		// TODO Auto-generated method stub
+		Log.d(TAG, "RemoteRequesT!!!!");
+	}
+
+	@Override
+	public void setEnabled(boolean isEnabled) throws RemoteException
+	{
+		// TODO Auto-generated method stub
+		// RemoteRequestHandler.isEnabled = isEnabled;
+	}
+
+	@Override
+	public boolean connectToServer(String ip)
+	{
+
+
+		return isConnectedToServer;
+	}
+
+	@Override
+	public void disconnectToServer()
+	{
+		serverIPs.clear();
+		clientIPs.clear();
+		connectedDevices.clear();
+		if (isConnectedToServer)
+		{
+			clientThread.interrupt();
+
+			// client.terminate();
+			isConnectedToServer = false;
+			// Settings.System.putString(mContext.getContentResolver(),
+			// "enableRemoteRequest", "false");
+			ILocationManager mLocationManager = ILocationManager.Stub.asInterface(ServiceManager.getService("location"));
+			try
+			{
+				mLocationManager.setRemoteProviderEnabled(false);
+			} catch (RemoteException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		// }
+		/*
+		 * catch (InterruptedException e) { // TODO Auto-generated catch block
+		 * e.printStackTrace(); }
+		 */
+	}
+
+	public boolean setRemoteSensorOn(boolean flag, SensorEventListener listener)
+	{
+		remoteSensorOn = flag;
+		mRemoteListener = listener;
+
+		return remoteSensorOn;
+	}
+
+	@Override
+	public boolean sendResourceRequests(List<Device> requestDeviceList) throws RemoteException {
+		// TODO Auto-generated method stub
+		mSender.connectToRemoteDevices(requestDeviceList);
+
+		return true;
+	}
+
+	@Override
+	/*public int[] isAllowedForResource(String device, int[] resources) throws RemoteException
+	{
+		// TODO Auto-generated method stub
+		IDeviceManager deviceManager = IDeviceManager.Stub.asInterface(ServiceManager.getService(Context.DEVICE_MANAGEMENT_SERVICE));
+		ArrayList<Integer> allowed = new ArrayList<Integer>();
+
+		for(int resource : resources)
+			if(deviceManager.isAllowedForResource(device, resource))
+				allowed.add(resource);
+
+		mSender.addRemoteDevice(allowed, device);
+		int[] ret = new int[allowed.size()];
+
+		for(int i=0; i<allowed.size(); i++)
+			ret[i] = allowed.get(i);
+
+		return ret;
+	}*/
+
+	public boolean isAllowedForResource(String deviceName, String deviceIP, int[] resources) throws RemoteException
+	{
+		// TODO Auto-generated method stub
+		IDeviceManagementService deviceManager = IDeviceManagementService.Stub.asInterface(ServiceManager.getService(Context.DEVICE_MANAGEMENT_SERVICE));
+
+		deviceManager.showRequestDialog(deviceName, deviceIP, resources);
+
+		return true;
+	}
+
+	public boolean respondAllowedResources(String deviceIP, int[] resources)
+	{
+		try {
+			// add remote device
+			mSender.addRemoteDevice(resources, deviceIP);
+
+			waitForResponse.get(deviceIP).writeObject(resources);
+			waitForResponse.remove(deviceIP);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return true;
+	}
+
+
+
+
+	@Override
+	public boolean sendRequest(RemoteRequest request)
+	{
+		if(isConnectedToServer)
+		{
+		}
+		return false;
+	}
+
+	//for MotionEvent
+	@Override
+	public void sendMotionEvent(MotionEvent event)
+	{
+		Log.d(TAG, event.toString());
+		if(isConnectedToServer)
+			mSender.sendMotionEvent(event);
+	}
+
+	// for KeyEvent
+	@Override
+	public void sendKeyEvent(KeyEvent event) throws RemoteException
+	{
+		// TODO Auto-generated method stub
+//		RemoteKeyEvent rke = new RemoteKeyEvent(event.getAction(),
+//				event.getKeyCode(), event.getSource());
+//
+//		if (isConnectedToServer)
+//			client.sendKeyEvent(rke);
+	}
+
+	@Override
+	public void addSensorHandle(int type, int handle)
+	{
+		// TODO Auto-generated method stub
+		Log.d(TAG, mSensorHandles.toString());
+
+		mSensorHandles.put(type, handle);
+	}
+
+	@Override
+	public void removeSensorHandle(int type)
+	{
+		// TODO Auto-generated method stub
+		Log.d(TAG, "type: " + type);
+		mSensorHandles.delete(type);
+	}
+
+	@Override
+	public void sendSensorEvent(int type, int sensor, float[] values,
+								int accuracy, long timestamp)
+	{
+		RemoteSensorEvent rse = new RemoteSensorEvent(type, sensor, values,
+				accuracy, timestamp);
+
+		if (isConnectedToServer)
+			mSender.sendSensorEvent(rse);
+	}
+
+	@Override
+	public int getVideoPlayers(){
+		int numberOfPlayers = 0;
+		if(isConnectedToServer){
+			numberOfPlayers = resourceToOutput.get(Device.RESOURCE_TYPE_VIDEO).size();
+		}
+		return numberOfPlayers;
+	}
+
+	@Override
+	public void sendVideoSignal(int vport){
+		if(isConnectedToServer){
+			mSender.sendVideoSignal(vport);
+		}
+	}
+
+
+	public void sendMusicData(int sampleSize, byte[] sampleData, long presentationTime){
+
+
+		SdPackage MDtoSend = new SdPackage(sampleSize, sampleData, presentationTime);
+
+		if(isConnectedToServer){
+			mSender.sendMusicData(MDtoSend);
+		}
+	}
+
+	@Override
+	public void sendLocation(Location location)
+	{
+		if(isConnectedToServer)
+			mSender.sendLocation(location);
+	}
+
+	Object sendRountTripRequest(RemoteRequest request)
+	{
+		return null;
+	}
+
+
+
+	static String APP_NAME = "Dummy" + CURRENT_DUMMY;
+	static String APP_DATA_DIR = "/data/local/tmp/" + APP_NAME;
+	static String basePkg = "com.collaboroid.dummy" + CURRENT_DUMMY;
+	static String OUT_ODEX_PATH = "/system/priv-app/"+APP_NAME+"/oat/arm64/"+APP_NAME+".odex";
+	static String DEX_PATH = APP_DATA_DIR + "/classes.dex";
+	static String XML_PATH = APP_DATA_DIR + "/AndroidManifest.xml";
+
+	/*
+ 	*
+ 	* Zips a file at a location and places the resulting zip file at the toLocation
+ 	* Example: zipFileAtPath("downloads/myfolder", "downloads/myFolder.zip");
+ 	*/
+	public boolean zipFileAtPath(String sourcePath, String toLocation) {
+		final int BUFFER = 2048;
+
+		File sourceFile = new File(sourcePath);
+		try {
+			BufferedInputStream origin = null;
+			FileOutputStream dest = new FileOutputStream(toLocation);
+			ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
+					dest));
+			if (sourceFile.isDirectory()) {
+				zipSubFolder(out, sourceFile, sourceFile.getParent().length());
+			} else {
+				byte data[] = new byte[BUFFER];
+				FileInputStream fi = new FileInputStream(sourcePath);
+				origin = new BufferedInputStream(fi, BUFFER);
+				ZipEntry entry = new ZipEntry(getLastPathComponent(sourcePath));
+				out.putNextEntry(entry);
+				int count;
+				while ((count = origin.read(data, 0, BUFFER)) != -1) {
+					out.write(data, 0, count);
+				}
+			}
+			out.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+			return false;
+		}
+		return true;
+	}
+
+	/*
+	 *
+	 * Zips a subfolder
+	 *
+	 */
+
+	private void zipSubFolder(ZipOutputStream out, File folder,
+							  int basePathLength) throws IOException {
+
+		final int BUFFER = 2048;
+
+		File[] fileList = folder.listFiles();
+		BufferedInputStream origin = null;
+		for (File file : fileList) {
+			if (file.isDirectory()) {
+				zipSubFolder(out, file, basePathLength);
+			} else {
+				byte data[] = new byte[BUFFER];
+				String unmodifiedFilePath = file.getPath();
+				String relativePath = unmodifiedFilePath
+						.substring(basePathLength);
+				FileInputStream fi = new FileInputStream(unmodifiedFilePath);
+				origin = new BufferedInputStream(fi, BUFFER);
+				ZipEntry entry = new ZipEntry(relativePath);
+				out.putNextEntry(entry);
+				int count;
+				while ((count = origin.read(data, 0, BUFFER)) != -1) {
+					out.write(data, 0, count);
+				}
+				origin.close();
+			}
+		}
+	}
+
+	/*
+     * gets the last path component
+     *
+     * Example: getLastPathComponent("downloads/example/fileToZip");
+     * Result: "fileToZip"
+     */
+	public String getLastPathComponent(String filePath) {
+		String[] segments = filePath.split("/");
+		if (segments.length == 0)
+			return "";
+		String lastPathComponent = segments[segments.length - 1];
+		return lastPathComponent;
+	}
+	public void playMusic()
+	{
+		Log.d(TAG, "playMusic - START!");
+		MediaPlayer mp = new MediaPlayer();
+		try
+		{
+			mp.setDataSource("/storage/emulated/legacy/Music/sabbun.mp3");
+			mp.prepare();
+		} catch (IllegalArgumentException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (SecurityException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IllegalStateException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		// mp.start();
+	}
+
+	public void testMethod(int value)
+	{
+		testValue = value;
+	}
+
+	@Override
+	public void testVibrate() throws RemoteException
+	{
+		// TODO Auto-generated method stub
+//	    ArrayList<Object> para = new ArrayList<Object>();
+//	    para.add("100");
+//	    RemoteRequest request = new RemoteRequest("systemCall", "vibrate", para);
+//
+//        client.send(request);
+		Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+
+		v.vibrate(200);
+
+	}
+	@Override
+	public void testMusic() throws RemoteException
+	{
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void testVideo() throws RemoteException
+	{
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void testTouch() throws RemoteException
+	{
+		// TODO Auto-generated method stub
+		IInputManager mInputService = IInputManager.Stub.asInterface(ServiceManager.getService("input"));
+
+		MotionEvent event = MotionEvent.obtain(
+				SystemClock.uptimeMillis(),
+				SystemClock.uptimeMillis(),
+				(MotionEvent.ACTION_DOWN + (1 << 24)),
+				100,
+				100, 0);
+
+		event.setSource(MotionEvent.TOOL_TYPE_FINGER);
+
+		try
+		{
+			if (!mInputService.injectInputEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT))
+			{
+				Log.d(TAG, "FAIL!!!!!");
+			}
+		}
+		finally
+		{
+			event.recycle();
+		}
+
+		for(int i=1; i<10; i++)
+		{
+			MotionEvent event1 = MotionEvent.obtain(
+					SystemClock.uptimeMillis(),
+					SystemClock.uptimeMillis(),
+					(MotionEvent.ACTION_MOVE + (1 << 24)),
+					100 * i,
+					100 * i, 0);
+
+			event1.setSource(MotionEvent.TOOL_TYPE_FINGER);
+
+			try
+			{
+				if (!mInputService.injectInputEvent(event1, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT))
+				{
+					Log.d(TAG, "FAIL!!!!!");
+				}
+			}
+			finally
+			{
+				event.recycle();
+			}
+		}
+
+		MotionEvent event2 = MotionEvent.obtain(
+				SystemClock.uptimeMillis(),
+				SystemClock.uptimeMillis(),
+				(MotionEvent.ACTION_UP + (1 << 24)),
+				900,
+				900, 0);
+
+		event2.setSource(MotionEvent.TOOL_TYPE_FINGER);
+
+		try
+		{
+			if (!mInputService.injectInputEvent(event2, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT))
+			{
+				Log.d(TAG, "FAIL!!!!!");
+			}
+		}
+		finally
+		{
+			event.recycle();
+		}
+	}
+
+	@Override
+	public void testKey() throws RemoteException
+	{
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void testSensor() throws RemoteException
+	{
+		// TODO Auto-generated method stub
+		new Thread(new Runnable()
+		{
+			@Override
+			public void run()
+			{
+				float[] temp;
+
+				for(int i=0; i<10; i++)
+				{
+					temp = new float[3];
+					temp[0] = 10;
+					temp[1] = 20;
+					temp[2] = 30;
+
+
+					//SensorEvent se = new SensorEvent(temp, 0, 0, 0);
+
+					//Log.d(TAG, remoteSensorOn + " - " + se.toString());
+
+					//sendRemoteEvent(Sensor.TYPE_REMOTE_SENSOR, Sensor.TYPE_REMOTE_SENSOR, temp, 0, 1000, 1);
+
+				/*sendRemoteEvent(3,
+						32,
+						temp,
+						0,
+						System.currentTimeMillis(),
+						1);*/
+
+				}
+			}
+		}).start();
+	}
+
+	@Override
+	public void testLocation() throws RemoteException
+	{
+		// TODO Auto-generated method stub
+		new Thread(new Runnable()
+		{
+			@Override
+			public void run()
+			{
+				ILocationManager mLocationManager = ILocationManager.Stub.asInterface(ServiceManager.getService("location"));
+
+				for(int i=0; i<10; i++)
+				{
+					Location location = new Location(LocationManager.GPS_PROVIDER);
+					//location.setProvider(LocationManager.GPS_PROVIDER);
+					location.setAccuracy(34);
+					location.setTime(System.currentTimeMillis());
+					location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
+					location.setLatitude((Math.random()*10));
+					location.setLongitude((Math.random()*10));
+
+					try
+					{
+						mLocationManager.reportLocation(location, false);
+					}
+					catch (RemoteException e)
+					{
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+
+					try {
+						Thread.sleep(1000);
+					} catch (InterruptedException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+
+//					Location location2 = new Location(LocationManager.REMOTE_PROVIDER);
+					//location.setProvider(LocationManager.GPS_PROVIDER);
+//					location2.setAccuracy(34);
+//					location2.setTime(System.currentTimeMillis());
+//					location2.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
+//					location2.setLatitude((10-i)*123.456);
+//					location2.setLongitude((10-i)*123.456);
+//
+//					try
+//					{
+//						mLocationManager.reportLocation(location2, false);
+//					}
+//					catch (RemoteException e)
+//					{
+//						// TODO Auto-generated catch block
+//						e.printStackTrace();
+//					}
+					//location.reset();
+				}
+			}
+		}).start();
+	}
+
+	public void requestMotionEvents() throws RemoteException{
+		ArrayList<Object> para = new ArrayList<Object>();
+		RemoteRequest request = new RemoteRequest("request", "motion", para);
+		sendAllrequest(request);
+	}
+	@Override
+	public void registerListener(IGeneralMessageListener listener) throws RemoteException {
+		// TODO Auto-generated method stub
+		mListeners.register(listener);
+	}
+	@Override
+	public void unregisterListener(IGeneralMessageListener listener) throws RemoteException {
+		// TODO Auto-generated method stub
+		mListeners.unregister(listener);
+	}
+
+	public void sendMessageToListener(String msg)
+	{
+		final int length = mListeners.beginBroadcast();
+		for(int i=0; i<length; i++)
+		{
+			final IGeneralMessageListener listener = mListeners.getBroadcastItem(i);
+			if(listener != null)
+			{
+				try {
+					listener.onMessageReceived(msg);
+				} catch (RemoteException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		}
+		mListeners.finishBroadcast();
+	}
+	public void refreshDevices(){
+		IDeviceManagementService deviceManager = IDeviceManagementService.Stub.asInterface(ServiceManager.getService(Context.DEVICE_MANAGEMENT_SERVICE));
+		try {
+			deviceManager.getDeviceList(1);
+		} catch (RemoteException e) {
+			e.printStackTrace();
+		}
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/ResourceRequest.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/ResourceRequest.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/ResourceRequest.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/ResourceRequest.java	2017-01-29 02:51:16.649856000 +0900
@@ -0,0 +1,27 @@
+package com.android.server.remote;
+
+import java.io.Serializable;
+
+public class ResourceRequest implements Serializable
+{
+	private static final long serialVersionUID = 1L;
+	
+	private String deviceName;
+	private int[] resources;
+	
+	public ResourceRequest(String dn, int[] rs)
+	{
+		deviceName = dn;
+		resources = rs;
+	}
+	
+	public String getDeviceName()
+	{
+		return deviceName;
+	}
+
+	public int[] getRequestedResources()
+	{
+		return resources;
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Sender2.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Sender2.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Sender2.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Sender2.java	2017-07-30 02:57:15.162620000 +0900
@@ -0,0 +1,291 @@
+package com.android.server.remote;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import android.content.Context;
+import android.graphics.Point;
+import android.location.Location;
+import android.service.devicemanagement.Device;
+import android.service.remote.AppendingObjectOutputStream;
+import android.service.remote.RemoteRequest;
+import android.service.remote.SdPackage;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.Display;
+import android.view.MotionEvent;
+import android.view.WindowManager;
+
+
+public class Sender2 implements Runnable
+{
+	private static final String TAG = "RemoteService_Sender2";
+    private static final int SERVERPORT = 55555;
+
+	private static final int DATASERVERPORT = 33333;
+	
+    private ArrayList<String> connectedDevices;
+    private HashMap<String, AppendingObjectOutputStream> deviceToOutput;
+    private SparseArray<ArrayList<AppendingObjectOutputStream>> resourceToOutput;
+
+    
+    private int Xdefault;
+	private int Ydefault;
+	
+	public Sender2(Context context)
+	{
+
+		connectedDevices = new ArrayList<String>();
+		deviceToOutput = new HashMap<String, AppendingObjectOutputStream>();
+		resourceToOutput = new SparseArray<ArrayList<AppendingObjectOutputStream>>();
+
+		
+		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+		Display display = wm.getDefaultDisplay();
+		Point size = new Point();
+		display.getSize(size);
+		
+		Xdefault = size.x;
+		Ydefault = size.y;
+	}
+	
+	// for resource request
+	public boolean connectToRemoteDevice(Device device)
+	{
+		try 
+		{
+			InetAddress deviceAddr;
+			Socket socketToDevice;
+			AppendingObjectOutputStream outToDevice;
+	    
+			deviceAddr = InetAddress.getByName(device.ipaddress);
+	        socketToDevice = new Socket(deviceAddr, SERVERPORT);
+			//17.01.29
+			socketToDevice.setTcpNoDelay(false);
+			socketToDevice.setKeepAlive(false);
+			socketToDevice.setSoTimeout(0);
+			/*
+			socketToDevice.setTcpNoDelay(true);
+	        socketToDevice.setKeepAlive(true);
+	        socketToDevice.setSoTimeout(0);
+			*/
+	        // serverIPs.add(serverAddr.getHostAddress());
+
+	        
+	        ObjectOutputStream out = new ObjectOutputStream(socketToDevice
+	                .getOutputStream());
+	        ObjectInputStream in = new ObjectInputStream(socketToDevice.getInputStream());
+	
+	        out.writeObject(device.askedResources);
+	        int[] responseFromServer = (int[])in.readObject();
+	
+	        if (responseFromServer.length > 0)
+	        {
+	            Log.d(TAG, "Successfully connected to: " + deviceAddr
+	            		+ "allowed: " + responseFromServer.toString());
+	            RemoteService.isConnectedToServer = true;
+	            outToDevice = new AppendingObjectOutputStream(socketToDevice.getOutputStream());
+	            
+	            connectedDevices.add(device.ipaddress);
+	            RemoteService.deviceToSocket.put(device.ipaddress, socketToDevice);
+	            deviceToOutput.put(device.ipaddress, outToDevice);
+	        }
+	        else
+	        	socketToDevice.close();
+        
+		} catch (UnknownHostException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ClassNotFoundException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+		
+		return true;
+	}
+	
+	// for communication
+	public boolean connectToRemoteDevice(String deviceIP)
+	{
+		try 
+		{
+			InetAddress deviceAddr;
+			Socket socketToDevice;
+			AppendingObjectOutputStream outToDevice;
+	    
+			deviceAddr = InetAddress.getByName(deviceIP);
+	        socketToDevice = new Socket(deviceAddr, SERVERPORT);
+	        socketToDevice.setTcpNoDelay(true);
+	        socketToDevice.setKeepAlive(true);
+	        socketToDevice.setSoTimeout(0);
+	        // serverIPs.add(serverAddr.getHostAddress());
+	        
+	        ObjectOutputStream out = new ObjectOutputStream(socketToDevice
+	                .getOutputStream());
+	        ObjectInputStream in = new ObjectInputStream(socketToDevice.getInputStream());
+	
+	        out.writeObject("Hello");
+			Log.d(TAG, "SBJJJJJJJJJJJJJJJJJ at Sender2");
+	        String responseFromServer = in.readObject().toString();
+			Log.d(TAG, "SBJJJJJJJJJJJJJJJJJ at Sender2");
+	
+	        if (responseFromServer.equals("Gooooood"))
+	        {
+	            Log.d(TAG, "Successfully connected to: " + deviceAddr);
+	            RemoteService.isConnectedToServer = true;
+	            outToDevice = new AppendingObjectOutputStream(socketToDevice.getOutputStream());
+	            
+	            connectedDevices.add(deviceIP);
+	            RemoteService.deviceToSocket.put(deviceIP, socketToDevice);
+	            deviceToOutput.put(deviceIP, outToDevice);
+	        }
+	        else
+	        	socketToDevice.close();
+        
+		} catch (UnknownHostException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ClassNotFoundException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+		
+		return true;
+	}
+	
+	public boolean connectToRemoteDevices(List<Device> devices)
+	{
+		for(Device device : devices)
+			connectToRemoteDevice(device);
+	        
+		return true;
+	}
+	
+	public boolean disconnectAllDevices()
+	{
+		try 
+		{
+			for(String device : connectedDevices)
+			{
+				RemoteService.deviceToSocket.get(device).close();
+				deviceToOutput.get(device).close();
+	        }
+			RemoteService.deviceToSocket.clear();
+			deviceToOutput.clear();
+		}
+		catch (IOException e) 
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		return true;
+	}
+	
+	public boolean addRemoteDevice(ArrayList<Integer> resources, String deviceIP)
+	{
+		if(!RemoteService.deviceToSocket.containsKey(deviceIP))
+			connectToRemoteDevice(deviceIP);
+		
+		for(int resource : resources)
+		{
+			if(resourceToOutput.get(resource) == null)
+				resourceToOutput.put(resource, new ArrayList<AppendingObjectOutputStream>());  
+		
+			resourceToOutput.get(resource).add(deviceToOutput.get(deviceIP));
+		}
+		return true;
+	}
+	
+	public boolean sendRequest(RemoteRequest request)
+	{
+		
+        return true;
+	}
+	
+	public void sendMotionEvent(MotionEvent event)
+	{
+		float x = event.getX();
+		float y = event.getY();
+		
+		RemoteMotionEvent rme = new RemoteMotionEvent(event.getDownTime(),
+				event.getEventTime(), x / Xdefault, y / Ydefault,
+				event.getAction(), event.getSource());
+
+		try 
+		{
+			for (AppendingObjectOutputStream output : resourceToOutput.get(Device.RESOURCE_TYPE_TOUCH))
+				output.writeObject(rme);
+		} 
+		catch (IOException e) 
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public void sendSensorEvent(RemoteSensorEvent rse)
+	{
+		try 
+		{
+			for (AppendingObjectOutputStream output : resourceToOutput.get(Device.RESOURCE_TYPE_SENSOR))
+				output.writeObject(rse);
+		} 
+		catch (IOException e) 
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public void sendLocation(Location location)
+	{
+		// TODO Auto-generated method stub
+		RemoteLocation RL = new RemoteLocation(location);
+		
+		try 
+		{
+			for (AppendingObjectOutputStream output : resourceToOutput.get(Device.RESOURCE_TYPE_LOCATION))
+				output.writeObject(RL);
+		} 
+		catch (IOException e) 
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public void sendMusicData(SdPackage MDtoSend)
+	{
+		try 
+		{
+			for (AppendingObjectOutputStream output : resourceToOutput.get(Device.RESOURCE_TYPE_AUDIO))
+				output.writeObject(MDtoSend);
+		} 
+		catch (IOException e) 
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	@Override
+	public void run() 
+	{
+		// TODO Auto-generated method stub
+		
+	}
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Sender_.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Sender_.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Sender_.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Sender_.java	2017-09-02 18:25:44.961892000 +0900
@@ -0,0 +1,231 @@
+package com.android.server.remote;
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.nio.channels.SocketChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import android.service.devicemanagement.Device;
+import android.service.remote.AppendingObjectOutputStream;
+import android.util.Log;
+
+public class Sender_ implements Runnable
+{
+	private static final String TAG = "RemoteService_Sender";
+	private static final int SERVERPORT = 55555;
+
+	private static final int DATASERVERPORT = 33333;
+
+	String dstAddr;
+	int[] resourceTypes;
+	boolean isRequest;
+
+	private String myName;
+
+	// native functions
+	native void setServerOn(boolean flag);
+
+	public Sender_(String myName, String deviceIP)
+	{
+		this.myName = myName;
+		dstAddr = deviceIP;
+		isRequest = false;
+	}
+
+	public Sender_(String myName, String deviceIP, int[] resources)
+	{
+		this.myName = myName;
+		dstAddr = deviceIP;
+		isRequest = true;
+		ArrayList<Integer> temp = new ArrayList<Integer>();
+
+		for(int i=0; i<Device.RESOURCE_TYPE_SIZE; i++)
+			if(resources[i] == 1)
+				temp.add(i);
+
+		resourceTypes = new int[temp.size()];
+
+		for(int i=0; i<temp.size(); i++)
+			resourceTypes[i] = temp.get(i);
+	}
+
+	@Override
+	public void run() {
+		// TODO Auto-generated method stub
+		try
+		{
+			InetAddress deviceAddr;
+			Socket socketToDevice;
+			AppendingObjectOutputStream outToDevice;
+
+
+			deviceAddr = InetAddress.getByName(dstAddr);
+			socketToDevice = new Socket(deviceAddr, SERVERPORT);
+
+			SocketChannel sChannel = SocketChannel.open();
+
+
+
+			//17.01.29
+			socketToDevice.setTcpNoDelay(true);
+			socketToDevice.setKeepAlive(true);
+			socketToDevice.setSoTimeout(0);
+			//socketToDevice.setSendBufferSize(128*1024*1024);
+
+
+			ObjectOutputStream out = new ObjectOutputStream(socketToDevice
+					.getOutputStream());
+			ObjectInputStream in = new ObjectInputStream(socketToDevice.getInputStream());
+
+
+			//SAMD
+			Socket dataSocketToDevice;
+			AppendingObjectOutputStream dataOutToDevice;
+			dataSocketToDevice = new Socket(deviceAddr, DATASERVERPORT);
+
+			dataSocketToDevice.setTcpNoDelay(true);
+			dataSocketToDevice.setKeepAlive(true);
+			dataSocketToDevice.setSoTimeout(0);
+			//dataSocketToDevice.setSendBufferSize(128*1024*1024);
+
+			ObjectOutputStream dataOut = new ObjectOutputStream(dataSocketToDevice
+					.getOutputStream());
+			ObjectInputStream dataIn = new ObjectInputStream(dataSocketToDevice.getInputStream());
+
+			if(isRequest)
+			{
+				out.writeObject(new ResourceRequest(myName, resourceTypes));
+
+				//여기서 쓰고나서 대기하는것 같다. 아래가 수행되기 위해서
+				//즉Client가 리스트(Sensor, Vibrator, ..., R.Activity)의 요청들을 보내고, 서버에서 그 응답을 기다림.
+				int[] responseFromServer = (int[])in.readObject();
+				Log.d(TAG, "Allowed: " + Arrays.toString(responseFromServer));
+
+				if (responseFromServer.length > 0)
+				{
+					if(responseFromServer.length != resourceTypes.length)
+						Log.d(TAG, "ask != allowed");
+
+					for(int i : responseFromServer)
+						if(i == Device.RESOURCE_TYPE_SENSOR)
+						{
+							setServerOn(true);
+							break;
+						}
+
+					Log.d(TAG, "Successfully connected to: " + deviceAddr);
+					RemoteService.isConnectedToServer = true;
+					outToDevice = new AppendingObjectOutputStream(socketToDevice.getOutputStream());
+
+					RemoteService.connectedDevices.add(dstAddr);
+					RemoteService.deviceToSocket.put(dstAddr, socketToDevice);
+
+					//SAMD
+					dataOutToDevice = new AppendingObjectOutputStream(dataSocketToDevice.getOutputStream());
+					RemoteService.deviceToSocketforData.put(dstAddr, dataSocketToDevice);
+
+					for(int i : resourceTypes) {
+						if (i == Device.RESOURCE_TYPE_REMOTE_ACTIVITY) {
+							RemoteService.deviceToOutput.put(dstAddr, outToDevice);
+
+							//SAMD
+							RemoteService.deviceToOutputforData.put(dstAddr, dataOutToDevice);
+
+							Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+							Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+							Log.d(TAG, dstAddr + "  SBJJJJJJJJJJJ");
+							Log.d(TAG, RemoteService.deviceToOutput.size() + "SBJJJJJJJJJJJJJJ");
+							Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+							Log.d(TAG, "SBJJJJJJJJJJJJJJJJJJJJJJJ");
+
+						}
+					}
+
+					for(String addr : RemoteService.connectedDevices)
+						Log.d(TAG, "connected: " + addr);
+				}
+				else{
+					socketToDevice.close();
+				}
+			}
+			else
+			{
+				//서버가 클라이언트한테 hello를 쓴다.
+				out.writeObject("Hello");
+				dataOut.writeObject("DataHello");
+				//여기서 쓰고나서 대기하는것 같다. 아래가 수행되기 위해서
+				String responseFromServer = in.readObject().toString();
+				String responseFromServerforData = dataIn.readObject().toString();
+
+				if (responseFromServer.equals("Gooooood"))
+				{
+					Log.d(TAG, "Successfully connected to: " + deviceAddr);
+					RemoteService.isConnectedToServer = true;
+					///////////////////////////////////////////////////
+					outToDevice = new AppendingObjectOutputStream(new BufferedOutputStream(socketToDevice.getOutputStream()));
+
+					///////////////////////////////////////////////////
+//					outToDevice = new AppendingObjectOutputStream(socketToDevice.getOutputStream());
+
+					RemoteService.connectedDevices.add(dstAddr);
+
+					RemoteService.deviceToSocket.put(dstAddr, socketToDevice);
+					if(RemoteService.deviceToOutput.containsKey(dstAddr)) {
+						RemoteService.deviceToOutput.remove(dstAddr);
+						RemoteService.deviceToOutput.put(dstAddr, outToDevice);
+						RemoteService.deviceToInput.put(dstAddr, in);
+					}else{
+						RemoteService.deviceToOutput.put(dstAddr, outToDevice);
+						RemoteService.deviceToInput.put(dstAddr, in);
+					}
+
+
+				}else{
+					socketToDevice.close();
+				}
+				//DataGooooood
+				if(responseFromServerforData.equals("DataGooooood")){
+					Log.d(TAG, "Successfully connected to: " + deviceAddr + " for Data");
+					//SAMD
+					//server is [client output] add
+					//dataOutToDevice = new AppendingObjectOutputStream(dataSocketToDevice.getOutputStream());
+
+					dataOutToDevice = new AppendingObjectOutputStream(new BufferedOutputStream(dataSocketToDevice.getOutputStream()));
+
+
+					RemoteService.deviceToSocketforData.put(dstAddr, dataSocketToDevice);
+					if(RemoteService.deviceToOutputforData.containsKey(dstAddr)){
+						RemoteService.deviceToOutputforData.remove(dstAddr);
+						RemoteService.deviceToOutputforData.put(dstAddr, dataOutToDevice);
+
+						RemoteService.deviceToInputforData.put(dstAddr, dataIn);
+					}else{
+						RemoteService.deviceToOutputforData.put(dstAddr, dataOutToDevice);
+
+						RemoteService.deviceToInputforData.put(dstAddr, dataIn);
+					}
+				}else{
+					dataSocketToDevice.close();
+				}
+
+			}
+
+		} catch (UnknownHostException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (ClassNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Sender.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Sender.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/remote/Sender.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/remote/Sender.java	2017-09-22 03:20:53.485270000 +0900
@@ -0,0 +1,948 @@
+package com.android.server.remote;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+import java.util.zip.Deflater;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Point;
+import android.location.Location;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.provider.Settings.Secure;
+import android.service.devicemanagement.Device;
+import android.service.remote.AppendingObjectOutputStream;
+import android.service.remote.DexCode;
+import android.service.remote.RemoteRequest;
+import android.service.remote.ResourceAapt;
+import android.service.remote.SdPackage;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.Display;
+import android.view.MotionEvent;
+import android.view.WindowManager;
+
+import com.android.server.samd.SAMDService;
+
+//import com.google.common.io.ByteStreams;
+
+public class Sender {
+
+	private static final String TAG = "RemoteService_Sender";
+	private static final int SERVERPORT = 55555;
+
+	private int Xdefault;
+	private int Ydefault;
+
+	/*private ArrayList<String> connectedDevices = RemoteService.connectedDevices;
+	private HashMap<String, Socket> deviceToSocket = RemoteService.deviceToSocket;
+	private HashMap<String, AppendingObjectOutputStream> deviceToOutput = RemoteService.deviceToOutput;
+    private SparseArray<ArrayList<AppendingObjectOutputStream>> resourceToOutput = RemoteService.resourceToOutput;*/
+
+	private Thread connectionThread;
+
+	//SAMD
+	private Sender_ mSender;
+	private final Context mContext;
+	private String myName;
+
+	public Sender(Context context) {
+		mContext = context;
+		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+		Display display = wm.getDefaultDisplay();
+		Point size = new Point();
+		display.getSize(size);
+
+		Xdefault = size.x;
+		Ydefault = size.y;
+
+		//myName = capitalize(Secure.getString(context.getContentResolver(),
+		//            Secure.ANDROID_ID));
+
+		myName = capitalize(Build.SERIAL);
+	}
+
+	// for resource request
+	public boolean connectToRemoteDevice(Device device) {
+		mSender = new Sender_(myName, device.ipaddress, device.askedResources);
+		connectionThread = new Thread(mSender);
+		connectionThread.start();
+
+		return true;
+	}
+
+	// for communication
+	public boolean connectToRemoteDevice(String deviceIP) {
+		mSender = new Sender_(myName, deviceIP);
+		connectionThread = new Thread(mSender);
+		connectionThread.start();
+
+
+		return true;
+	}
+
+	public boolean connectToRemoteDevices(List<Device> devices) {
+		for (Device device : devices)
+			connectToRemoteDevice(device);
+
+		return true;
+	}
+
+	public boolean disconnectAllDevices() {
+		try {
+			for (String device : RemoteService.connectedDevices) {
+				RemoteService.deviceToSocket.get(device).close();
+				RemoteService.deviceToOutput.get(device).close();
+
+				RemoteService.deviceToSocketforData.get(device).close();
+				RemoteService.deviceToOutputforData.get(device).close();
+			}
+			RemoteService.deviceToSocket.clear();
+			RemoteService.deviceToOutput.clear();
+			RemoteService.deviceToSocketforData.clear();
+			RemoteService.deviceToOutputforData.clear();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return true;
+	}
+
+	public boolean addRemoteDevice(ArrayList<Integer> resourceTypes, String deviceIP) {
+		if (!RemoteService.deviceToSocket.containsKey(deviceIP)) {
+			connectToRemoteDevice(deviceIP);
+			try {
+				connectionThread.join();
+			} catch (InterruptedException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+
+		for (int resourceType : resourceTypes) {
+			if (RemoteService.deviceToOutput.get(deviceIP) != null)
+				RemoteService.resourceToOutput.get(resourceType).add(RemoteService.deviceToOutput.get(deviceIP));
+			else
+				Log.d(TAG, resourceType + " is NULL!!!!!!!!");
+
+
+		}
+
+		return true;
+	}
+
+	public boolean addRemoteDevice(int[] resourceTypes, String deviceIP) {
+		Log.d("sbjsbjsbjsbjsbj","sbjsbjsbjsbjsbj addRemoteDevice");
+		if (!RemoteService.deviceToSocket.containsKey(deviceIP)) {
+			connectToRemoteDevice(deviceIP);
+			try {
+				connectionThread.join();
+			} catch (InterruptedException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		//SAMD
+		if (!RemoteService.deviceToSocketforData.containsKey(deviceIP)) {
+			connectToRemoteDevice(deviceIP);
+			try {
+				connectionThread.join();
+			} catch (InterruptedException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+
+		for (int resourceType : resourceTypes) {
+			if (RemoteService.deviceToOutput.get(deviceIP) != null)
+				RemoteService.resourceToOutput.get(resourceType).add(RemoteService.deviceToOutput.get(deviceIP));
+			else
+				Log.d(TAG, resourceType + " is NULL!!!!!!!!");
+
+			//SAMD
+			if(RemoteService.deviceToOutputforData.get(deviceIP) != null){
+				RemoteService.resourceToOutputforData.get(resourceType).add(RemoteService.deviceToOutputforData.get(deviceIP));
+			}
+			if(RemoteService.deviceToInputforData.get(deviceIP) != null){
+				RemoteService.resourceToInputforData.get(resourceType).add(RemoteService.deviceToInputforData.get(deviceIP));
+			}
+			if(RemoteService.deviceToInput.get(deviceIP) != null){
+				RemoteService.resourceToInput.get(resourceType).add(RemoteService.deviceToInput.get(deviceIP));
+			}
+
+		}
+
+		return true;
+	}
+
+	public boolean respondAllowedResources(String deviceIP, int[] resources) {
+		if (RemoteService.deviceToOutput.get(deviceIP) != null) {
+			try {
+				AppendingObjectOutputStream output = RemoteService.deviceToOutput.get(deviceIP);
+				output.writeObject(resources);
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			return true;
+		}
+
+		return false;
+	}
+
+	public boolean sendRequestToEveryDevices(RemoteRequest request) {
+		try {
+			for (String deviceIP : RemoteService.connectedDevices)
+				RemoteService.deviceToOutput.get(deviceIP).writeObject(request);
+
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return true;
+	}
+
+	public void sendMotionEvent(MotionEvent event) {
+		//Log.d(TAG, "1: " + event.toString());
+
+		float x = event.getX();
+		float y = event.getY();
+
+		RemoteMotionEvent rme = new RemoteMotionEvent(event.getDownTime(),
+				event.getEventTime(), x / Xdefault, y / Ydefault,
+				event.getAction(), event.getSource());
+
+
+		try {
+			//Log.d(TAG, "2: " + RemoteService.resourceToOutput.get(Device.RESOURCE_TYPE_TOUCH).size());
+
+			for (AppendingObjectOutputStream output : RemoteService.resourceToOutput.get(Device.RESOURCE_TYPE_TOUCH)) {
+				if (output == null)
+					Log.d(TAG, "NULL!!!!!!!!");
+				else
+					output.writeObject(rme);
+			}
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void sendSensorEvent(RemoteSensorEvent rse) {
+		try {
+			//Log.d(TAG, rse.toString());
+
+			for (AppendingObjectOutputStream output : RemoteService.resourceToOutput.get(Device.RESOURCE_TYPE_SENSOR))
+				output.writeObject(rse);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void sendLocation(Location location) {
+		// TODO Auto-generated method stub
+		RemoteLocation RL = new RemoteLocation(location);
+
+		try {
+			for (AppendingObjectOutputStream output : RemoteService.resourceToOutput.get(Device.RESOURCE_TYPE_LOCATION))
+				output.writeObject(RL);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void sendMusicData(SdPackage MDtoSend) {
+		try {
+			for (AppendingObjectOutputStream output : RemoteService.resourceToOutput.get(Device.RESOURCE_TYPE_AUDIO))
+				output.writeObject(MDtoSend);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	public void sendVideoSignal(int vport) {
+		Log.d(TAG, "VideoSignal: " + vport);
+
+		RemoteRequest request = new RemoteRequest();
+		ArrayList<Object> vInfo = new ArrayList<Object>();
+		vInfo.add(0, vport);
+		vInfo.add(1, vport);
+		request.set("video_streaming", "get_surface", vInfo);
+
+		for (AppendingObjectOutputStream output : RemoteService.resourceToOutput.get(Device.RESOURCE_TYPE_VIDEO)) {
+			if (output == null) {
+				Log.d(TAG, "NULL!!!!!!");
+			} else {
+				try {
+					output.writeObject(request);
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+			vport = vport + 2;
+			vInfo.set(1, vport);
+		}
+	}
+	private String capitalize(String s) {
+		if (s == null || s.length() == 0) {
+			return "";
+		}
+		char first = s.charAt(0);
+		if (Character.isUpperCase(first)) {
+			return s;
+		} else {
+			return Character.toUpperCase(first) + s.substring(1);
+		}
+	}
+	public boolean initializeAR(int deviceNum, String appName){
+		boolean result = false;
+		if(appName != null){
+			Log.d("uuuuuuu_initializeAR",
+					"s-----------------------------------------------------------------------------------------------");
+			SAMDService.CURRENT_APP_NAME = appName;
+
+			ArrayList<Object> zipInfo = new ArrayList<Object>();
+			zipInfo.add(0, appName);
+
+			RemoteRequest request = new RemoteRequest();
+			request.set("initializeAR", "init", zipInfo);
+			ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutput
+					.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+			ArrayList<ObjectInputStream> input_list = RemoteService.resourceToInput
+					.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+			AppendingObjectOutputStream output = output_list.get(deviceNum);
+			ObjectInputStream input = input_list.get(deviceNum);
+			if (output == null) {
+				Log.d(TAG, "NULL!!!!!!");
+			} else {
+				try {
+					output.writeObject(request);
+					output.flush();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+			try{
+				String responseFromClient = input.readObject().toString();
+				if(responseFromClient.equals("init ok")){
+					Log.d("uuuuuuu_initializeAR","receive from client : " + responseFromClient);
+					result = true;
+
+				}
+			}catch(Exception e){
+				e.printStackTrace();
+			}
+
+			Log.d("uuuuuuu_initializeAR",
+					"e-----------------------------------------------------------------------------------------------");
+		}
+		return result;
+	}
+	public boolean sendDexActivity(int deviceNumber, String DexFile, List<String> resourceFiles){
+
+		Log.d("uuuuuuu_sendDexActivity",
+				"s-----------------------------------------------------------------------------------------------");
+		//17.03.02
+		//dex files transfer
+		FileInputStream fileInputStream = null;
+		ByteArrayOutputStream bos = null;
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		boolean turn = true;
+		try {
+			//dexes
+			zipInfo.add(0, deviceNumber+1);
+			Log.d("uuuuuuu_sendDexActivity", "dexFiles : " + DexFile);
+			File dexFile = new File("/collaboroid/preprocess/" + SAMDService.CURRENT_APP_NAME + "/dex/" + DexFile + "_classes.dex");
+
+			fileInputStream = new FileInputStream(dexFile);
+			bos = new ByteArrayOutputStream();
+			byte[] buf = new byte[4096];
+			for (int readNum; (readNum = fileInputStream.read(buf)) != -1; ) {
+				bos.write(buf, 0, readNum);
+			}
+			byte[] classesByte = bos.toByteArray();
+
+			zipInfo.add(1, DexFile);
+			zipInfo.add(2, classesByte);
+			//resources
+			if(resourceFiles.size()!=0){
+
+				List<String> preResourceFiles = new ArrayList<String>();
+				for(int i=0; i<resourceFiles.size(); i++){
+					if(resourceFiles.get(i).contains("!")){
+						preResourceFiles.add(resourceFiles.get(i).split("!")[1]);
+						resourceFiles.remove(i);
+						i--;
+					}
+				}
+				try {
+					//Pre Sended
+					zipInfo.add(3, preResourceFiles.size());
+					int preResourceNum = preResourceFiles.size();
+					Log.d("uuuuuuu_sendResourcesLR", "send preResourceNum : " + preResourceNum);
+					for(int i=0, j=4; i<preResourceNum; i++, j++){
+						zipInfo.add(j, preResourceFiles.get(i));
+						Log.d("uuuuuuu_sendResourcesLR", "j : "+j+"/ preresource zipInfo.add : " + preResourceFiles.get(i));
+					}
+					//Now Sended
+					zipInfo.add(4+preResourceNum, resourceFiles.size());
+					Log.d("uuuuuuu_sendResourcesLR", "send resourceFilesNum : " + resourceFiles.size());
+					for (int i=0, j=5+preResourceNum; i<resourceFiles.size(); i++,j+=2) {
+						File resourceFile = new File("/collaboroid/preprocess/"
+								+ SAMDService.CURRENT_APP_NAME +
+								"/" +
+								resourceFiles.get(i).replace(resourceFiles.get(i).split("\\/")[0]+"/",""));
+
+						if(resourceFile.isFile()){
+							fileInputStream = new FileInputStream(resourceFile);
+
+							bos = new ByteArrayOutputStream();
+							Log.d("fileData","fileData start : " + resourceFile.toString());
+							for (int readNum; (readNum = fileInputStream.read(buf, 0, buf.length)) != -1; ) {
+								bos.write(buf, 0, readNum);
+							}
+							//Dynamic3r3 a1.png, a2.png  = delay 0.2sec
+							Log.d("fileData","fileData end : " + resourceFile.toString());
+							classesByte = bos.toByteArray();
+							Log.d("fileData","fileData classByte : " + classesByte.length);
+
+							bos.flush();
+							bos.reset();
+							bos = null;
+
+							zipInfo.add(j, resourceFiles.get(i));
+							zipInfo.add(j+1, classesByte);
+
+						}else{
+							resourceFiles.remove(i);
+							i-=1;
+							j-=2;
+						}
+					}
+					zipInfo.set(4+preResourceNum, resourceFiles.size());
+					ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutputforData
+							.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+					ResourceAapt resourceAapt = new ResourceAapt();
+					resourceAapt.set("sendActivity", "withResource", zipInfo);
+					AppendingObjectOutputStream output = output_list.get(deviceNumber);
+					if (output == null) {
+						Log.d(TAG, "NULL!!!!!!!!");
+					} else {
+						output.writeObject(resourceAapt);
+						output.flush();
+					}
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+			if(bos != null){
+				bos.close();
+			}
+			if(fileInputStream != null){
+				fileInputStream.close();
+			}
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		Log.d("uuuuuuu_sendDexActivity",
+				"e-----------------------------------------------------------------------------------------------");
+		return true;
+	}
+	public boolean sendDex(int deviceNumber, String DexFile, List<String> resourceFiles) {
+		Log.d("uuuuuuu_sendDex",
+				"s-----------------------------------------------------------------------------------------------");
+		//17.03.02
+		//dex files transfer
+		FileInputStream fileInputStream = null;
+		ByteArrayOutputStream bos = null;
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		boolean turn = true;
+		try {
+			//dexes
+			zipInfo.add(0, deviceNumber+1);
+			Log.d("uuuuuuu_sendDex", "dexFiles : " + DexFile);
+			File dexFile = new File("/collaboroid/preprocess/" + SAMDService.CURRENT_APP_NAME + "/dex/" + DexFile + "_classes.dex");
+
+			fileInputStream = new FileInputStream(dexFile);
+			bos = new ByteArrayOutputStream();
+			byte[] buf = new byte[4096];
+			for (int readNum; (readNum = fileInputStream.read(buf)) != -1; ) {
+				bos.write(buf, 0, readNum);
+			}
+			byte[] classesByte = bos.toByteArray();
+
+			zipInfo.add(1, DexFile);
+			zipInfo.add(2, classesByte);
+			//resources
+			if(resourceFiles.size()!=0){
+
+				List<String> preResourceFiles = new ArrayList<String>();
+				for(int i=0; i<resourceFiles.size(); i++){
+					if(resourceFiles.get(i).contains("!")){
+						preResourceFiles.add(resourceFiles.get(i).split("!")[1]);
+						resourceFiles.remove(i);
+						i--;
+					}
+				}
+				try {
+					//Pre Sended
+					zipInfo.add(3, preResourceFiles.size());
+					int preResourceNum = preResourceFiles.size();
+					Log.d("uuuuuuu_sendResourcesLR", "send preResourceNum : " + preResourceNum);
+					for(int i=0, j=4; i<preResourceNum; i++, j++){
+						zipInfo.add(j, preResourceFiles.get(i));
+						Log.d("uuuuuuu_sendResourcesLR", "j : "+j+"/ preresource zipInfo.add : " + preResourceFiles.get(i));
+					}
+
+					//Now Sended
+					zipInfo.add(4+preResourceNum, resourceFiles.size());
+					Log.d("uuuuuuu_sendResourcesLR", "send resourceFilesNum : " + resourceFiles.size());
+					for (int i=0, j=5+preResourceNum; i<resourceFiles.size(); i++,j+=2) {
+						File resourceFile = new File("/collaboroid/preprocess/"
+								+ SAMDService.CURRENT_APP_NAME +
+								"/" +
+								resourceFiles.get(i).replace(resourceFiles.get(i).split("\\/")[0]+"/",""));
+
+						if(resourceFile.isFile()){
+							fileInputStream = new FileInputStream(resourceFile);
+
+							bos = new ByteArrayOutputStream();
+							Log.d("fileData","fileData start : " + resourceFile.toString());
+							for (int readNum; (readNum = fileInputStream.read(buf, 0, buf.length)) != -1; ) {
+								bos.write(buf, 0, readNum);
+							}
+							//Dynamic3r3 a1.png, a2.png  = delay 0.2sec
+							Log.d("fileData","fileData end : " + resourceFile.toString());
+							classesByte = bos.toByteArray();
+							Log.d("fileData","fileData classByte : " + classesByte.length);
+
+							bos.flush();
+							bos.reset();
+							bos = null;
+
+							zipInfo.add(j, resourceFiles.get(i));
+							zipInfo.add(j+1, classesByte);
+
+						}else{
+							resourceFiles.remove(i);
+							i-=1;
+							j-=2;
+						}
+					}
+					zipInfo.set(4+preResourceNum, resourceFiles.size());
+
+					ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutputforData
+							.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+
+					DexCode dexCode = new DexCode();
+					dexCode.set("multiDexTransfer", "getMultiDex", zipInfo);
+					AppendingObjectOutputStream output = output_list.get(deviceNumber);
+					if (output == null) {
+						Log.d(TAG, "NULL!!!!!!!!");
+					} else {
+						Log.d("samd sub experiment", "File write objects start");
+						output.writeObject(dexCode);
+						output.flush();
+						Log.d("samd sub experiment", "File write objects end");
+					}
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+			if(bos != null){
+				bos.close();
+			}
+			if(fileInputStream != null){
+				fileInputStream.close();
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		Log.d("uuuuuuu_sendDex",
+				"e-----------------------------------------------------------------------------------------------");
+		return true;
+	}
+	public void sendResourcesRL(List<String> resourceFiles, String appName) {
+
+		Log.d("sendResourcesRL",
+				"s-----------------------------------------------------------------------------------------------");
+		FileInputStream fileInputStream = null;
+		ByteArrayOutputStream bos = null;
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		if(resourceFiles.size()!=0){
+			try {
+				zipInfo.add(0, SAMDService.remote_device_number);
+				zipInfo.add(1, appName);
+				zipInfo.add(2, resourceFiles.size());
+
+				for (int i=0, j=3; i<resourceFiles.size(); i++,j+=2) {
+					File dexFiles = new File("/data/collaboroid/preprocess/" + appName + "/" + resourceFiles.get(i));
+					Log.d("samd experiment", "appName : " + appName);
+					Log.d("samd experiment", "resource : " + resourceFiles.get(i));
+					if(dexFiles.isFile()){
+						fileInputStream = new FileInputStream(dexFiles);
+						bos = new ByteArrayOutputStream();
+						byte[] buf = new byte[4096];
+						for (int readNum; (readNum = fileInputStream.read(buf)) != -1; ) {
+							bos.write(buf, 0, readNum);
+						}
+						byte[] classesByte = bos.toByteArray();
+						zipInfo.add(j, resourceFiles.get(i));
+						zipInfo.add(j+1, classesByte);
+					}else{
+						resourceFiles.remove(i);
+						i-=1;
+						j-=2;
+					}
+				}
+				zipInfo.set(2, resourceFiles.size());
+
+				Log.d("sendResourcesRL", "resource size : " + resourceFiles.size());
+
+				for(int i=0; i<resourceFiles.size(); i++){
+					Log.d("sendResourcesRL", "resourceFiles : " + resourceFiles.get(i));
+				}
+
+				if(bos != null){
+					bos.close();
+				}
+				if(fileInputStream != null){
+					fileInputStream.close();
+				}
+
+				if(resourceFiles.size() > 0){
+					for (AppendingObjectOutputStream output : RemoteService.deviceToOutput.values()) {
+						RemoteRequest request = new RemoteRequest();
+						request.set("ResourcesTransfer", "getResourcesRL", zipInfo);
+						if (output == null) {
+							Log.d(TAG, "NULL!!!!!!!!");
+						} else {
+							output.writeObject(request);
+							output.flush();
+						}
+					}
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		Log.d("sendResourcesRL",
+				"e-----------------------------------------------------------------------------------------------");
+	}
+
+	public void sendResourcesLR(int deviceNumber, List<String> resourceFiles) {
+		Log.d("uuuuuuu_sendResourcesLR",
+				"s-----------------------------------------------------------------------------------------------");
+		FileInputStream fileInputStream = null;
+		ByteArrayOutputStream bos = null;
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		if(resourceFiles.size()!=0){
+			try {
+				zipInfo.add(0, resourceFiles.size());
+				for (int i=0, j=1; i<resourceFiles.size(); i++,j+=2) {
+					File dexFiles = new File("/data/collaboroid/preprocess/" + SAMDService.CURRENT_APP_NAME + "/" + resourceFiles.get(i));
+					if(dexFiles.isFile()){
+						fileInputStream = new FileInputStream(dexFiles);
+						bos = new ByteArrayOutputStream();
+						byte[] buf = new byte[4096];
+						for (int readNum; (readNum = fileInputStream.read(buf)) != -1; ) {
+							bos.write(buf, 0, readNum);
+						}
+						byte[] classesByte = bos.toByteArray();
+
+						zipInfo.add(j, resourceFiles.get(i));
+						zipInfo.add(j+1, classesByte);
+
+					}else{
+						resourceFiles.remove(i);
+						i-=1;
+						j-=2;
+					}
+				}
+				zipInfo.set(0, resourceFiles.size());
+				if(bos != null){
+					bos.flush();
+					bos.close();
+				}
+				if(fileInputStream != null){
+					fileInputStream.close();
+				}
+				Log.d("sendResourcesLR", "resource size : " + resourceFiles.size());
+				for(int i=0; i<resourceFiles.size(); i++){
+					Log.d("uuuuuuu_sendResourcesLR", "send resourceFiles : " + resourceFiles.get(i));
+				}
+				if(resourceFiles.size() > 0){
+					ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutputforData
+							.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+
+					ArrayList<ObjectInputStream> input_list = RemoteService.resourceToInputforData
+							.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+					ResourceAapt resource = new ResourceAapt();
+
+					resource.set("ResourcesTransfer", "getResourcesLR", zipInfo);
+					AppendingObjectOutputStream output = output_list.get(deviceNumber);
+					ObjectInputStream input = input_list.get(deviceNumber);
+
+					if (output == null) {
+						Log.d(TAG, "NULL!!!!!!!!");
+					} else {
+						output.writeObject(resource);
+						output.flush();
+					}
+
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+		Log.d("uuuuuuu_sendResourcesLR",
+				"e-----------------------------------------------------------------------------------------------");
+	}
+	public void sendActivity(int deviceNumber, String toSendActivityName) {
+		Log.d("uuuuuuu_sendActivity",
+				"s-----------------------------------------------------------------------------------------------");
+		try {
+			Log.d("uuuuuuu_sendActivity", toSendActivityName + " is Send!!!!");
+			ArrayList<Object> zipInfo = new ArrayList<Object>();
+			zipInfo.add(0, toSendActivityName);
+			RemoteRequest request = new RemoteRequest();
+			request.set("sendActivity", "OnlyName", zipInfo);
+			ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutput
+					.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+			AppendingObjectOutputStream output = output_list.get(deviceNumber);
+			if (output == null) {
+				Log.d(TAG, "NULL!!!!!!!!");
+			} else {
+				output.writeObject(request);
+				output.flush();
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		Log.d("uuuuuuu_sendActivity",
+				"e-----------------------------------------------------------------------------------------------");
+	}
+	public boolean sendActivityWithRes(int deviceNumber, String toSendActivityName, List<String> resourceFiles) {
+
+		// index 0 = toSendActivityName
+		// index 1 = pre Resources Size
+		// index 1+Size+1 = Resourcecs Size
+		Log.d("uuuuuuu_sendActivityWithRes",
+				"s-----------------------------------------------------------------------------------------------");
+		FileInputStream fileInputStream = null;
+		ByteArrayOutputStream bos = null;
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		try {
+			//dexes
+			zipInfo.add(0, toSendActivityName);
+			//resources
+			if(resourceFiles.size()!=0){
+				List<String> preResourceFiles = new ArrayList<String>();
+				for(int i=0; i<resourceFiles.size(); i++){
+					if(resourceFiles.get(i).contains("!")){
+						preResourceFiles.add(resourceFiles.get(i).split("!")[1]);
+						resourceFiles.remove(i);
+						i--;
+					}
+				}
+				try {
+					//Pre Sended
+					zipInfo.add(1, preResourceFiles.size());
+					int preResourceNum = preResourceFiles.size();
+					Log.d("uuuuuuu_sendActivityWithRes", "send preResourceNum : " + preResourceNum);
+					for(int i=0, j=2; i<preResourceNum; i++, j++){
+						zipInfo.add(j, preResourceFiles.get(i));
+						Log.d("uuuuuuu_sendActivityWithRes", "j : "+j+"/ preresource zipInfo.add : " + preResourceFiles.get(i));
+					}
+					//Now Sended
+					zipInfo.add(2+preResourceNum, resourceFiles.size());
+					Log.d("uuuuuuu_sendActivityWithRes", "send resourceFilesNum : " + resourceFiles.size());
+					for (int i=0, j=3+preResourceNum; i<resourceFiles.size(); i++,j+=2) {
+						File resourceFile = new File("/collaboroid/preprocess/"
+								+ SAMDService.CURRENT_APP_NAME +
+								"/" +
+								resourceFiles.get(i).replace(resourceFiles.get(i).split("\\/")[0]+"/",""));
+						if(resourceFile.isFile()){
+							fileInputStream = new FileInputStream(resourceFile);
+							bos = new ByteArrayOutputStream();
+							byte[] buf = new byte[4096];
+							for (int readNum; (readNum = fileInputStream.read(buf)) != -1; ) {
+								bos.write(buf, 0, readNum);
+							}
+							byte[] classesByte = bos.toByteArray();
+							Log.d("uuuuuuu_sendActivityWithRes","j : "+j+"/ resource zipInfo.add  : " + resourceFiles.get(i));
+							Log.d("uuuuuuu_sendActivityWithRes","j : "+j+"/ resource zipInfo.add for dir : "
+									+ resourceFiles.get(i).replace(resourceFiles.get(i).split("\\/")[0]+"/",""));
+							zipInfo.add(j, resourceFiles.get(i));
+							zipInfo.add(j+1, classesByte);
+						}else{
+							resourceFiles.remove(i);
+							i-=1;
+							j-=2;
+						}
+					}
+					zipInfo.set(2+preResourceNum, resourceFiles.size());
+
+					ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutput
+							.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+					RemoteRequest request = new RemoteRequest();
+					request.set("sendActivity", "WithResource", zipInfo);
+					AppendingObjectOutputStream output = output_list.get(deviceNumber);
+					if (output == null) {
+						Log.d(TAG, "NULL!!!!!!!!");
+					} else {
+						output.writeObject(request);
+						output.flush();
+					}
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+			if(bos != null){
+				bos.flush();
+				bos.close();
+			}
+			if(fileInputStream != null){
+				fileInputStream.close();
+			}
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		Log.d("uuuuuuu_sendActivityWithRes",
+				"e-----------------------------------------------------------------------------------------------");
+		return true;
+	}
+	public void sendMessageLRD(int deviceNum, String msg) {
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		zipInfo.add(0, 0);
+		zipInfo.add(1, msg);
+		RemoteRequest request = new RemoteRequest();
+		request.set("sendMessage", "getMessageLR", zipInfo);
+
+		ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutput
+				.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+
+		AppendingObjectOutputStream output = output_list.get(deviceNum);
+
+
+		if (output == null) {
+			Log.d(TAG, "NULL!!!!!!");
+		} else {
+			try {
+				output.writeObject(request);
+				output.flush();
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+
+	}
+
+	public void sendMessageRL(String msg) {
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		zipInfo.add(0,SAMDService.remote_device_number);
+		zipInfo.add(1, msg);
+		zipInfo.add(2, System.currentTimeMillis());
+		RemoteRequest request = new RemoteRequest();
+		request.set("sendMessage", "getMessageRL", zipInfo);
+
+		for (AppendingObjectOutputStream output : RemoteService.deviceToOutput.values()) {
+			if (output == null) {
+				Log.d(TAG, "NULL!!!!!!!!");
+			} else {
+				try {
+					output.writeObject(request);
+					output.flush();
+				}catch (IOException e){
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+
+	public void sendAPKFile(int deviceNum, String dir){
+		File APKfile = new File(dir);
+
+		FileInputStream fileInputStream = null;
+		ByteArrayOutputStream bos = null;
+		byte[] classesByte = null;
+		byte[] sbj_byte = null;
+		byte[] sbj_bb = null;
+
+		try {
+			Log.d("samd experiment", "File read data start " + deviceNum);
+			fileInputStream = new FileInputStream(APKfile);
+
+			sbj_bb = new byte[(int)APKfile.length()];
+			fileInputStream.read(sbj_bb);
+
+
+
+//			Log.d("samd sub experiment", "File read data start");
+//			bos = new ByteArrayOutputStream();
+//			byte[] buf = new byte[4096];
+//			for (int readNum; (readNum = fileInputStream.read(buf)) != -1; ) {
+//				bos.write(buf, 0, readNum);
+//			}
+//			classesByte = bos.toByteArray();
+
+			//sbj_byte = ByteStreams.toByteArray(fileInputStream);
+//			Log.d("samd experiment", "ByteStreams read data end");
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		Log.d("samd sub experiment", "File read data end "  + deviceNum);
+
+
+
+		ArrayList<Object> zipInfo = new ArrayList<Object>();
+		//zipInfo.add(0, classesByte);
+		//zipInfo.add(0, sbj_byte);
+		zipInfo.add(0, sbj_bb);
+		zipInfo.add(1, dir);
+
+		RemoteRequest request = new RemoteRequest();
+		request.set("sendFile", "getAPK", zipInfo);
+
+
+		ArrayList<AppendingObjectOutputStream> output_list = RemoteService.resourceToOutput
+				.get(Device.RESOURCE_TYPE_REMOTE_ACTIVITY);
+		AppendingObjectOutputStream output = output_list.get(deviceNum);
+
+	}
+
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/samd/ApplicationManager.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/samd/ApplicationManager.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/samd/ApplicationManager.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/samd/ApplicationManager.java	2017-09-15 11:23:23.919487000 +0900
@@ -0,0 +1,333 @@
+package com.android.server.samd;
+
+import android.content.Context;
+import android.content.pm.IPackageInstallObserver;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.RemoteException;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Created by sbj on 17. 7. 31.
+ */
+
+public class ApplicationManager {
+
+    public final int INSTALL_REPLACE_EXISTING = 2;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} on success.
+     * @hide
+     */
+    public static final int INSTALL_SUCCEEDED = 1;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if the package is
+     * already installed.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if the package archive
+     * file is invalid.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_INVALID_APK = -2;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if the URI passed in
+     * is invalid.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_INVALID_URI = -3;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if the package manager
+     * service found that the device didn't have enough storage space to install the app.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if a
+     * package is already installed with the same name.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the requested shared user does not exist.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * a previously installed package of the same name has a different signature
+     * than the new package (and the old package's data was not removed).
+     * @hide
+     */
+    public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package is requested a shared user which is already installed on the
+     * device and does not have matching signature.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package uses a shared library that is not available.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package uses a shared library that is not available.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package failed while optimizing and validating its dex files,
+     * either because there was not enough storage or the validation failed.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_DEXOPT = -11;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package failed because the current SDK version is older than
+     * that required by the package.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_OLDER_SDK = -12;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package failed because it contains a content provider with the
+     * same authority as a provider already installed in the system.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package failed because the current SDK version is newer than
+     * that required by the package.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_NEWER_SDK = -14;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package failed because it has specified that it is a test-only
+     * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
+     * flag.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_TEST_ONLY = -15;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the package being installed contains native code, but none that is
+     * compatible with the the device's CPU_ABI.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package uses a feature that is not available.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
+
+    // ------ Errors related to sdcard
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * a secure container mount point couldn't be accessed on external media.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package couldn't be installed in the specified install
+     * location.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
+
+    /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)} if
+     * the new package couldn't be installed in the specified install
+     * location because the media is not available.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser was given a path that is not a file, or does not end with the expected
+     * '.apk' extension.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser was unable to retrieve the AndroidManifest.xml file.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser encountered an unexpected exception.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser did not find any certificates in the .apk.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser found inconsistent certificates on the files in the .apk.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser encountered a CertificateEncodingException in one of the
+     * files in the .apk.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser encountered a bad or missing package name in the manifest.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser encountered a bad shared user id name in the manifest.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser encountered some structural problem in the manifest.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
+
+    /**
+     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the parser did not find any actionable tags (instrumentation or application)
+     * in the manifest.
+     * @hide
+     */
+    public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
+
+    /**
+     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(Uri, IPackageInstallObserver, int)}
+     * if the system failed to install the package because of system issues.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
+
+    private PackageInstallObserver observer;
+    private PackageManager pm;
+    private Method method;
+
+    private OnInstalledPackaged onInstalledPackaged;
+
+    class PackageInstallObserver extends IPackageInstallObserver.Stub {
+
+        public void packageInstalled(String packageName, int returnCode) throws RemoteException {
+            if (onInstalledPackaged != null) {
+                onInstalledPackaged.packageInstalled(packageName, returnCode);
+            }
+        }
+    }
+
+    public ApplicationManager(Context context) throws SecurityException, NoSuchMethodException {
+
+        observer = new PackageInstallObserver();
+        pm = context.getPackageManager();
+
+        Class<?>[] types = new Class[] {Uri.class, IPackageInstallObserver.class, int.class, String.class};
+        method = pm.getClass().getMethod("installPackage", types);
+    }
+
+    public void setOnInstalledPackaged(OnInstalledPackaged onInstalledPackaged) {
+        this.onInstalledPackaged = onInstalledPackaged;
+    }
+
+    public void installPackage(String apkFile) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+        installPackage(new File(apkFile));
+    }
+
+    public void installPackage(File apkFile) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+        if (!apkFile.exists()) throw new IllegalArgumentException();
+        Uri packageURI = Uri.fromFile(apkFile);
+        installPackage(packageURI);
+    }
+
+    public void installPackage(Uri apkFile) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+        method.invoke(pm, new Object[] {apkFile, observer, INSTALL_REPLACE_EXISTING, null});
+    }
+
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/samd/OnInstalledPackaged.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/samd/OnInstalledPackaged.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/samd/OnInstalledPackaged.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/samd/OnInstalledPackaged.java	2017-09-15 11:23:23.891487000 +0900
@@ -0,0 +1,10 @@
+package com.android.server.samd;
+
+/**
+ * Created by sbj on 17. 7. 31.
+ */
+public interface OnInstalledPackaged {
+
+    public void packageInstalled(String packageName, int returnCode);
+
+}
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/samd/SAMDService.java SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/samd/SAMDService.java
--- Android_6.0.1_r11/frameworks/base/services/core/java/com/android/server/samd/SAMDService.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/java/com/android/server/samd/SAMDService.java	2017-09-22 00:34:47.005692000 +0900
@@ -0,0 +1,788 @@
+package com.android.server.samd;
+
+import android.app.ActivityManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.IPackageManager;
+import android.os.AsyncTask;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.service.devicemanagement.Device;
+import android.service.samd.ISAMDListener;
+import android.service.samd.ISAMDService;
+import android.service.samd.SAMDMessage;
+import android.util.ArrayMap;
+import android.util.Log;
+import android.util.SparseArray;
+
+import com.android.server.remote.RemoteService;
+import com.android.server.remote.Sender;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * Created by sbj on 17. 9. 14.
+ */
+public class SAMDService extends ISAMDService.Stub{
+    private HashMap<String, HashMap<String, List<String>>> ActivityTable = new HashMap<>();
+    //1.appName     2.packageName + MainActivityName ------- related activity
+    private HashMap<String, HashMap<String, List<String>>> ResourceTable = new HashMap<>();
+    //1.appName     2.packageName + ActivityName -------- related ResourceFile
+    public String CURRENT_APP;
+    public String CURRENT_PACKAGE;
+    public String CURRENT_ACTIVITY;
+
+    //Activity Per Resource with duplicate (remote use)
+    public static HashMap<String, ArrayList<String>> resourcesPerActivity;
+
+    //SAMD Stack Call Activity per Device (local use)
+    public static SparseArray<ArrayList<String>> callActivityStackPerDevice;
+
+    //SAMD Stack Call Activity (remote use)
+    public static ArrayList<String> callActivityStack;
+    //SAMD Stack Call Resource (remote use)
+    public static ArrayList<String> callResourceStack;
+
+    //collaboroid
+    public static boolean DUMMY_BIT = true;
+
+    //SAMD Cached device table (local use)
+    public static ArrayList<Device> cachedActivityResourceDevices;
+
+    //SAMD Listener
+    private static ArrayMap<IBinder, ISAMDListener> mSAMDListeners = new ArrayMap<IBinder, ISAMDListener>();
+
+
+    //samd
+    //for Remote De
+    public static int remote_device_number = 0;
+    public static String CURRENT_APP_NAME = "";
+    HashMap<String, String[]> smali$FileList = new HashMap<>();
+
+
+    public static Context mContext;
+
+    public SAMDService(Context context)
+    {
+        mContext = context;
+
+        initSAMDService();
+    }
+    public void initSAMDService(){
+        resourcesPerActivity = new HashMap<String, ArrayList<String>>();
+
+        cachedActivityResourceDevices = new ArrayList<Device>();
+        callActivityStackPerDevice = new SparseArray<ArrayList<String>>();
+        callActivityStack = new ArrayList<String>();
+        callResourceStack = new ArrayList<String>();
+    }
+    //samd
+    public boolean initialARTable(String appName){
+
+        ActivityTable.clear();
+        ResourceTable.clear();
+
+        this.CURRENT_APP = appName;
+
+        File deleteDirectory = new File("/collaboroid/preprocess/");
+        DeleteRecursiveFiles(deleteDirectory);
+
+        File sourceDirectory = new File("/data/collaboroid/preprocess/"+appName);
+        File targetDirectory = new File("/collaboroid/preprocess/"+appName);
+
+        if(targetDirectory.mkdir()){
+            try {
+                Log.d("samd experiment","copy start["+appName+"]");
+                if(copyDirectoryAll(sourceDirectory, targetDirectory)){
+                    Log.d("samd experiment","copy end["+appName+"]");
+                    if(RemoteService.connectedDevices!=null){
+                        Log.d("samd","table initialize");
+                        if(RemoteService.connectedDevices.size()!=0){
+                            for(int i=0; i<RemoteService.connectedDevices.size(); i++){
+                                if(RemoteService.mSender.initializeAR(i, appName)){
+                                    cachedActivityResourceDevices.get(i).dexTable.clear();
+                                    cachedActivityResourceDevices.get(i).resourceTable.clear();
+                                    //remove
+                                    callActivityStackPerDevice.remove(i);
+                                }
+                            }
+                        }
+                    }
+                }
+            }catch(Exception e){
+                e.printStackTrace();
+            }
+        }
+        return true;
+    }
+
+    public boolean initialARTableD(int deviceNum, String appName){
+
+        ActivityTable.clear();
+        ResourceTable.clear();
+
+        this.CURRENT_APP = appName;
+
+        File deleteDirectory = new File("/collaboroid/preprocess/");
+        DeleteRecursiveFiles(deleteDirectory);
+
+        File sourceDirectory = new File("/data/collaboroid/preprocess/"+appName);
+        File targetDirectory = new File("collaboroid/preprocess/"+appName);
+        if(targetDirectory.mkdir()){
+            try {
+                Log.d("samd experiment","start copyDirectory");
+                if(copyDirectoryAll(sourceDirectory, targetDirectory)){
+                    Log.d("samd experiment","end copyDirectory");
+                    RemoteService.mSender.initializeAR(deviceNum, appName);
+                    Device d = cachedActivityResourceDevices.get(deviceNum);
+                    d.dexTable.clear();
+                    d.resourceTable.clear();
+                    //remove
+                    callActivityStackPerDevice.remove(deviceNum);
+                }
+            }catch(Exception e){
+                e.printStackTrace();
+            }
+        }
+        return true;
+    }
+    //sendDexWithActivity
+    public void sendDexActivityD(int deviceNum, String DexFile){
+        getResourcesTable(DexFile);
+        HashMap<String, List<String>> ResourcesRelated = ResourceTable.get(CURRENT_APP);
+        SendDexDynamicAsync sendDexDynamicAsync = new SendDexDynamicAsync(deviceNum, DexFile, ResourcesRelated);
+        sendDexDynamicAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+    }
+    public void sendDexActivity(String DexFile){
+        getResourcesTable(DexFile);
+        HashMap<String, List<String>> ResourcesRelated = ResourceTable.get(CURRENT_APP);
+        for(int j=0 ;j<RemoteService.connectedDevices.size(); j++) {
+            SendDexDynamicAsync sendDexDynamicAsync = new SendDexDynamicAsync(j, DexFile, ResourcesRelated);
+            sendDexDynamicAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+        }
+    }
+    public void preSendDex(String currentActivity, String packageName){
+        CURRENT_ACTIVITY = currentActivity;
+        CURRENT_PACKAGE = packageName;
+        //save ActivityTable Hash from ActivityTable.txt
+        getActivityTable();
+        //add ResourceTable from Resources
+        getResourcesTable(ActivityTable.get(CURRENT_APP).get(CURRENT_PACKAGE+"."+CURRENT_ACTIVITY));
+        //sendActivityResources()
+        HashMap<String, List<String>> MainActivityRelated = ActivityTable.get(CURRENT_APP);
+        List<String> multiDexFile = MainActivityRelated.get(CURRENT_PACKAGE+"."+CURRENT_ACTIVITY);
+
+        HashMap<String, List<String>> ResourcesRelated = ResourceTable.get(CURRENT_APP);
+        // res/drawable , res/layout
+        for(int j=0 ;j<RemoteService.connectedDevices.size(); j++){
+            SendDexAsync sendDexAsync = new SendDexAsync(j, multiDexFile, ResourcesRelated);
+            sendDexAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+        }
+    }
+    public void preSendDexD(int deviceNum, String currentActivity, String packageName){
+
+        CURRENT_ACTIVITY = currentActivity;
+        CURRENT_PACKAGE = packageName;
+        //save ActivityTable Hash from ActivityTable.txt
+        getActivityTable();
+        //add ResourceTable from Resources
+        getResourcesTable(ActivityTable.get(CURRENT_APP).get(CURRENT_PACKAGE+"."+CURRENT_ACTIVITY));
+        //sendActivityResources()
+        HashMap<String, List<String>> MainActivityRelated = ActivityTable.get(CURRENT_APP);
+        List<String> multiDexFile = MainActivityRelated.get(CURRENT_PACKAGE+"."+CURRENT_ACTIVITY);
+
+        HashMap<String, List<String>> ResourcesRelated = ResourceTable.get(CURRENT_APP);
+        // res/drawable , res/layout
+        SendDexAsync sendDexAsync = new SendDexAsync(deviceNum, multiDexFile, ResourcesRelated);
+        sendDexAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+    }
+    public void sendResourcesToLocal(List<String> resourceFiles){
+        RemoteService.mSender.sendResourcesRL(resourceFiles, CURRENT_APP_NAME);
+    }
+
+    public void sendResourcesToRemote(List<String> resourceFiles, String toSendActivityName){
+        for(int i=0; i<RemoteService.connectedDevices.size(); i++){
+            List<String> listResources = checkResourceFile(i, (ArrayList)resourceFiles, toSendActivityName);
+            RemoteService.mSender.sendResourcesLR(i, listResources);
+            addResourceFile(i, listResources);
+        }
+    }
+    public void sendResourcesToRemoteD(int deviceNum, List<String> resourceFiles, String toSendActivityName){
+        List<String> listResources = checkResourceFile(deviceNum, (ArrayList)resourceFiles, toSendActivityName);
+        RemoteService.mSender.sendResourcesLR(deviceNum, listResources);
+        addResourceFile(deviceNum, listResources);
+    }
+    public void launchActivity(String toSendActivityName){
+        for(int i=0; i<RemoteService.connectedDevices.size(); i++){
+            RemoteService.mSender.sendActivity(i, toSendActivityName);
+        }
+    }
+    public void launchActivityD(int deviceNum, String toSendActivityName){
+        RemoteService.mSender.sendActivity(deviceNum, toSendActivityName);
+    }
+    public void launchActivityWithRes(String toSendActivityName, List<String> resourceFiles){
+        for(int i=0; i<RemoteService.connectedDevices.size(); i++){
+            SendDexWithResourceAsync sendDexWithResourceAsync
+                    = new SendDexWithResourceAsync(i,toSendActivityName,resourceFiles);
+            sendDexWithResourceAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+        }
+    }
+    public void launchActivityWithResD(int deviceNum, String toSendActivityName, List<String> resourceFiles){
+        SendDexWithResourceAsync sendDexWithResourceAsync
+                = new SendDexWithResourceAsync(deviceNum,toSendActivityName,resourceFiles);
+        sendDexWithResourceAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+    }
+    public void sendMessageToRemoteD(int deviceNum, String msg){
+        RemoteService.mSender.sendMessageLRD(deviceNum, msg);
+    }
+    public void sendMessageToRemote(String msg){
+        for(int i=0; i<RemoteService.connectedDevices.size(); i++){
+            RemoteService.mSender.sendMessageLRD(i, msg);
+        }
+    }
+    public void sendMessageToLocal(String msg){
+        RemoteService.mSender.sendMessageRL(msg);
+    }
+
+    public int getRemoteDeviceCount() { return RemoteService.connectedDevices.size(); }
+
+    public int getRemoteDeviceNumber() { return this.remote_device_number; }
+
+    public String getCurrentAppName(){
+        return CURRENT_APP_NAME;
+    }
+
+    public void requestSAMDListener(ISAMDListener listener){
+        mSAMDListeners.put(listener.asBinder(), listener);
+    }
+    public static void dispatchMessage(SAMDMessage message){
+        Log.d("mSAMDListeners", "mSAMDListeners size : " + mSAMDListeners.size());
+        for(ISAMDListener l : mSAMDListeners.values()){
+            try {
+                Log.d("mSAMDListeners", "mSAMDListeners write msg : " + message.getMessage());
+                l.onSAMDMsg(message);
+            } catch (RemoteException e) {
+                Log.d("dispatchMessage", "dispatchMessage error");
+            }
+        }
+    }
+
+    public void sendAPKFile(String dir){
+        for(int i=0; i<RemoteService.connectedDevices.size(); i++){
+            SendAPKAsync apkAsync = new SendAPKAsync(i,dir);
+            apkAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+        }
+
+    }
+    //add resource
+    private synchronized void addResourceFile(int deviceNum, List<String> resourceString){
+        // resourceString :
+        Device d = cachedActivityResourceDevices.get(deviceNum);
+        List<String> temp = d.resourceTable;
+        //remove !
+        for(int i=0; i<resourceString.size(); i++){
+            if(resourceString.get(i).contains("!")){
+                resourceString.set(i, resourceString.get(i).split("!")[1]);
+            }
+        }
+        //duplicate remove
+        for(String s : temp){
+            resourceString.remove(s);
+        }
+        d.resourceTable.addAll(resourceString);
+    }
+
+    //get resource dex
+    private List<String> getDexFile(int deviceNum){
+        Device d = cachedActivityResourceDevices.get(deviceNum);
+        return d.dexTable;
+    }
+
+    private List<String> getResourceFile(int deviceNum){
+        Device d = cachedActivityResourceDevices.get(deviceNum);
+        return d.resourceTable;
+    }
+
+    private synchronized boolean checkDexFile(int deviceNum, String dexFile){
+        List<String> temp = cachedActivityResourceDevices.get(deviceNum).dexTable;
+        return temp.contains(dexFile);
+    }
+
+    private synchronized List<String> checkResourceFile(int deviceNum, ArrayList<String> resourceList, String dexFile){
+        List<String> temp = cachedActivityResourceDevices.get(deviceNum).resourceTable;
+        CopyOnWriteArrayList<String> tempList = new CopyOnWriteArrayList<String>();
+        Iterator it = ((ArrayList<String>)resourceList.clone()).iterator();
+        while(it.hasNext()){
+            tempList.add((String)it.next());
+        }
+        for(int i=0; i<tempList.size(); i++){
+            boolean result = false;
+            for(String s : temp){
+                if(s.replace(s.split("\\/")[0]+"/", "").equals(tempList.get(i))){
+                    //exist
+                    tempList.set(i, "!"+s);
+                    result = true;
+                }
+            }
+            if(!result){
+                //not exist
+                tempList.set(i, dexFile+"/"+tempList.get(i));
+            }
+        }
+        return tempList;
+    }
+
+    public void ConvertDex(String appName){
+        String[] smaliArgs = {"-o",
+                "/reviseApp/"+appName+"/dexes/classes.dex",
+                "--",
+                "/reviseApp/"+appName+"/smalis"};
+        //com.android.smali.main.main(smaliArgs);
+        IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+        try {
+            pm.aaptAdd(2, "/system/priv-app/"+appName+"/"+appName+".apk", "classes.dex");
+            pm.aaptAdd(1, "/system/priv-app/"+appName+"/"+appName+".apk", "/reviseApp/"+appName+"/dexes/classes.dex");
+        } catch (RemoteException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public synchronized void popUpActivity(String activityName){
+        //abc.apk exists?
+        IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+        synchronized (this){
+            try{
+                File f = new File("/collaboroid/agent/activity_res/"+activityName+"/abc.apk");
+                File dst_f = new File("/collaboroid/agent/abc.apk");
+                copy(f, dst_f);
+
+                if(DUMMY_BIT){
+                    Log.d("samd experiment","aapt add/remove start["+activityName+"]");
+                    pm.aaptAdd(2, "/system/priv-app/Dummy1/Dummy1.apk", "classes.dex");
+                    File dexFile_ = new File("/collaboroid/agent/dex/" + activityName + "_classes.dex");
+                    File classesDex = new File("/collaboroid/agent/dex/classes.dex");
+                    dexFile_.renameTo(classesDex);
+                    pm.aaptAdd(1, "/system/priv-app/Dummy1/Dummy1.apk", "/collaboroid/agent/dex/classes.dex");
+                    classesDex.renameTo(dexFile_);
+                    Log.d("samd experiment","aapt add/remove end["+activityName+"]");
+
+
+                    ComponentName compName = new ComponentName(
+                            "com.collaboroid.dummy1", "com.collaboroid.dummy1.MainActivity");
+                    Intent intent = new Intent(Intent.ACTION_MAIN);
+                    intent.setComponent(compName);
+                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+                    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+
+                    mContext.startActivity(intent);
+
+                    DUMMY_BIT = !DUMMY_BIT;
+
+                    ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+                    List<ActivityManager.RunningAppProcessInfo> pidsTask = activityManager.getRunningAppProcesses();
+                    for (int i = 0; i < pidsTask.size(); i++) {
+                        if (pidsTask.get(i).processName.equals("com.collaboroid.dummy2")) {
+                            android.os.Process.killProcess(pidsTask.get(i).pid);
+                        }
+                    }
+                    callResourceStack.remove(activityName);
+                }else{
+                    Log.d("samd experiment","aapt add/remove start["+activityName+"]");
+                    pm.aaptAdd(2, "/system/priv-app/Dummy2/Dummy2.apk", "classes.dex");
+                    File dexFile_ = new File("/collaboroid/agent/dex/" + activityName + "_classes.dex");
+                    File classesDex = new File("/collaboroid/agent/dex/classes.dex");
+                    dexFile_.renameTo(classesDex);
+                    pm.aaptAdd(1, "/system/priv-app/Dummy2/Dummy2.apk", "/collaboroid/agent/dex/classes.dex");
+                    classesDex.renameTo(dexFile_);
+                    Log.d("samd experiment","aapt add/remove end["+activityName+"]");
+
+                    ComponentName compName = new ComponentName(
+                            "com.collaboroid.dummy2", "com.collaboroid.dummy2.MainActivity");
+                    Intent intent = new Intent(Intent.ACTION_MAIN);
+                    intent.setComponent(compName);
+                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+                    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+                    mContext.startActivity(intent);
+                    DUMMY_BIT = !DUMMY_BIT;
+
+                    ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+                    List<ActivityManager.RunningAppProcessInfo> pidsTask = activityManager.getRunningAppProcesses();
+                    for (int i = 0; i < pidsTask.size(); i++) {
+                        if (pidsTask.get(i).processName.equals("com.collaboroid.dummy1")) {
+                            android.os.Process.killProcess(pidsTask.get(i).pid);
+                        }
+                    }
+
+                    callResourceStack.remove(activityName);
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }
+
+    }
+    public static void copy(File src, File dst) throws IOException{
+
+        FileInputStream in = new FileInputStream(src);
+        FileOutputStream out = new FileOutputStream(dst);
+
+
+
+        FileChannel inChannel = in.getChannel();
+        FileChannel outChannel = out.getChannel();
+        inChannel.transferTo(0, inChannel.size(), outChannel);
+        inChannel.close();
+        outChannel.close();
+
+    }
+    private void DeleteRecursiveFiles(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursive(child);
+
+    }
+
+    private void DeleteRecursive(File fileOrDirectory) {
+
+        if (fileOrDirectory.isDirectory())
+            for (File child : fileOrDirectory.listFiles())
+                DeleteRecursive(child);
+
+        fileOrDirectory.delete();
+    }
+    class SendDexWithResourceAsync extends AsyncTask<Void,Void,Boolean> {
+        int deviceNum;
+        String DexFile;
+        List<String> ResourcesRelated;
+        public SendDexWithResourceAsync(int deviceNum, String DexFile, List<String> ResourcesRelated){
+            this.deviceNum = deviceNum;
+            this.DexFile = DexFile;
+            this.ResourcesRelated = ResourcesRelated;
+        }
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... voids) {
+
+            boolean result = false;
+            if(!checkDexFile(deviceNum, DexFile)){
+                List<String> listResources = checkResourceFile(deviceNum, (ArrayList)ResourcesRelated, DexFile);
+                result = RemoteService.mSender.sendActivityWithRes(deviceNum, DexFile, listResources);
+                addResourceFile(deviceNum, listResources);
+            }
+            return result;
+        }
+
+        // AsyncTask.cancel(boolean) 메소드가 true 인자로
+        // 실행되면 호출되는 콜백.
+        // background 작업이 취소될때 꼭 해야될 작업은  여기에 구현.
+        @Override
+        protected void onCancelled() {
+            // TODO Auto-generated method stub
+            super.onCancelled();
+        }
+    }
+    class SendDexAsync extends AsyncTask<Void,Void,Boolean> {
+        int deviceNum;
+        List<String> DexFile;
+        HashMap<String, List<String>> ResourcesRelated;
+        public SendDexAsync(int deviceNum, List<String> DexFile, HashMap<String, List<String>> ResourcesRelated){
+            this.deviceNum = deviceNum;
+            this.DexFile = DexFile;
+            this.ResourcesRelated = ResourcesRelated;
+        }
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... voids) {
+
+            boolean result = false;
+
+            if(DexFile.contains("")){
+                DexFile.remove("");
+            }
+            if(DexFile.size() != 0){
+                //compare cached dex to last aapt
+                //remove??
+                //dex and resourse dependancy
+                for(int i=0; i<DexFile.size(); i++){
+                    List<String> resourcesFiles = ResourcesRelated.get(CURRENT_PACKAGE+"."+DexFile.get(i));
+                    //send Dex
+
+                    List<String> values = new ArrayList<>();
+                    File valuesDirectory = new File("/collaboroid/preprocess/"+CURRENT_APP+"/res/values");
+                    for (File child : valuesDirectory.listFiles()) {
+                        values.add("res/values/"+child.getName());
+                    }
+                    values.add("res/drawable/ic_launcher.png");
+                    resourcesFiles.addAll(values);
+                    if(!checkDexFile(deviceNum, DexFile.get(i))){
+                        List<String> listResources = checkResourceFile(deviceNum, (ArrayList)resourcesFiles, DexFile.get(i));
+                        result = RemoteService.mSender.sendDex(deviceNum, DexFile.get(i), listResources);
+                        addResourceFile(deviceNum, listResources);
+                    }
+                }
+            }
+
+            return result;
+        }
+
+
+        // AsyncTask.cancel(boolean) 메소드가 true 인자로
+        // 실행되면 호출되는 콜백.
+        // background 작업이 취소될때 꼭 해야될 작업은  여기에 구현.
+        @Override
+        protected void onCancelled() {
+            // TODO Auto-generated method stub
+            super.onCancelled();
+        }
+    }
+    class SendDexDynamicAsync extends AsyncTask<Void,Void,Boolean> {
+        int deviceNum;
+        String DexFile;
+        HashMap<String, List<String>> ResourcesRelated;
+        public SendDexDynamicAsync(int deviceNum, String DexFile, HashMap<String, List<String>> ResourcesRelated){
+            this.deviceNum = deviceNum;
+            this.DexFile = DexFile;
+            this.ResourcesRelated = ResourcesRelated;
+        }
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... voids) {
+
+            boolean result = false;
+            //compare cached dex to last aapt
+            //remove??
+            //dex and resourse dependancy
+            List<String> resourcesFiles = ResourcesRelated.get(CURRENT_PACKAGE + "." + DexFile);
+            //send Dex
+
+            List<String> values = new ArrayList<>();
+            File valuesDirectory = new File("/collaboroid/preprocess/"+CURRENT_APP+"/res/values");
+            for (File child : valuesDirectory.listFiles()) {
+                values.add("res/values/"+child.getName());
+            }
+            values.add("res/drawable/ic_launcher.png");
+            resourcesFiles.addAll(values);
+            if (!checkDexFile(deviceNum, DexFile)) {
+                List<String> listResources = checkResourceFile(deviceNum, (ArrayList)resourcesFiles, DexFile);
+                Log.d("samd experiment", "start Dex & Resources : " + DexFile + " to " + (deviceNum + 1));
+                result = RemoteService.mSender.sendDexActivity(deviceNum, DexFile, listResources);
+                addResourceFile(deviceNum, listResources);
+            }
+            return result;
+        }
+
+
+        // AsyncTask.cancel(boolean) 메소드가 true 인자로
+        // 실행되면 호출되는 콜백.
+        // background 작업이 취소될때 꼭 해야될 작업은  여기에 구현.
+        @Override
+        protected void onCancelled() {
+            // TODO Auto-generated method stub
+            super.onCancelled();
+        }
+    }
+    class SendAPKAsync extends AsyncTask<Void,Void,Boolean> {
+        int deviceNum;
+        String dir;
+        public SendAPKAsync(int deviceNum, String dir){
+            this.deviceNum = deviceNum;
+            this.dir = dir;
+        }
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... voids) {
+            String dir_temp = "/system/priv-app/"+dir+"/"+dir+".apk";
+            RemoteService.mSender.sendAPKFile(deviceNum, dir_temp);
+            return true;
+        }
+
+
+        // AsyncTask.cancel(boolean) 메소드가 true 인자로
+        // 실행되면 호출되는 콜백.
+        // background 작업이 취소될때 꼭 해야될 작업은  여기에 구현.
+        @Override
+        protected void onCancelled() {
+            // TODO Auto-generated method stub
+            super.onCancelled();
+        }
+    }
+    private void getActivityTable(){
+        // read file and find appName -> packageName + mainActivityName ---- a,b,c,d,e
+        // create ArrayList<relatedActivity>  put a,b,c,d,e
+        // create Hashmap<packageName + mainActivityname , ArrayList<relatedActivity>> and put
+        // ActivityTable<appName, up HashMap> put
+        HashMap<String, List<String>> relatedActivity = new HashMap<>();
+        List<String> activities = new ArrayList<>();
+
+        File file = new File("/data/collaboroid/preprocess/"+CURRENT_APP+"/ActivityTable.txt");
+        BufferedReader br = null;
+        try {
+            br = new BufferedReader(new FileReader(file));
+            String line;
+            while ((line = br.readLine()) != null) {
+                String[] temp = line.toString().trim().split("\\@");
+                if(temp[0].equals(CURRENT_PACKAGE+"."+CURRENT_ACTIVITY)){
+                    for(int i=1; i<temp.length; i++){
+                        if(!activities.contains(temp[i]))
+                            activities.add(i-1, temp[i]);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (br != null)
+                    br.close();
+            } catch (IOException e) {
+                //
+            }
+        }
+
+        relatedActivity.put(CURRENT_PACKAGE+"."+CURRENT_ACTIVITY, activities);
+        ActivityTable.put(CURRENT_APP, relatedActivity);
+
+    }
+    private void getResourcesTable(String activitie){
+        // read file and find appName -> packageName + mainActivityName ---- a,b,c,d,e
+        // create ArrayList<relatedResources>  put a.png, b.xml, c.png, d.png, e.xml
+        // create Hashmap<packageName + mainActivityname , ArrayList<relatedActivity>> and put
+        // ActivityTable<appName, up HashMap> put
+        HashMap<String, List<String>> relatedResource = new HashMap<>();
+
+        File file = new File("/data/collaboroid/preprocess/"+CURRENT_APP+"/ResourceTable.txt");
+        BufferedReader br = null;
+        List<String> resources = new ArrayList<>();
+        try {
+            br = new BufferedReader(new FileReader(file));
+            String line;
+            while ((line = br.readLine()) != null) {
+                String[] temp = line.toString().trim().split("\\@");
+                if(temp[0].equals(CURRENT_PACKAGE+"."+activitie)){
+                    for(int j=1; j<temp.length; j++){
+                        if(!resources.contains(temp[j]))
+                            resources.add(j-1, temp[j]);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (br != null)
+                    br.close();
+            } catch (IOException e) {
+                //
+            }
+        }
+
+        relatedResource.put(CURRENT_PACKAGE+"."+activitie, resources);
+        ResourceTable.put(CURRENT_APP, relatedResource);
+    }
+
+    private void getResourcesTable(List<String> activities){
+        // read file and find appName -> packageName + mainActivityName ---- a,b,c,d,e
+        // create ArrayList<relatedResources>  put a.png, b.xml, c.png, d.png, e.xml
+        // create Hashmap<packageName + mainActivityname , ArrayList<relatedActivity>> and put
+        // ActivityTable<appName, up HashMap> put
+        HashMap<String, List<String>> relatedResource = new HashMap<>();
+
+        File file = new File("/data/collaboroid/preprocess/"+CURRENT_APP+"/ResourceTable.txt");
+
+        BufferedReader br = null;
+        for(int i=0; i<activities.size(); i++){
+            List<String> resources = new ArrayList<>();
+            try {
+                br = new BufferedReader(new FileReader(file));
+                String line;
+                while ((line = br.readLine()) != null) {
+                    String[] temp = line.toString().trim().split("\\@");
+                    if(temp[0].equals(CURRENT_PACKAGE+"."+activities.get(i))){
+                        for(int j=1; j<temp.length; j++){
+                            resources.add(j-1, temp[j]);
+                        }
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                try {
+                    if (br != null)
+                        br.close();
+                } catch (IOException e) {
+                    //
+                }
+            }
+
+            HashSet hs = new HashSet(resources);
+            List<String> newResources= new ArrayList<>(hs);
+
+
+            relatedResource.put(CURRENT_PACKAGE+"."+activities.get(i), resources);
+        }
+
+        ResourceTable.put(CURRENT_APP, relatedResource);
+    }
+
+    private boolean copyDirectoryAll(File sourceLocation, File targetLoacation) throws IOException {
+
+        //source is directory
+        if(sourceLocation.isDirectory()){
+            if(!targetLoacation.exists()){
+                targetLoacation.mkdir();
+            }
+            String[] children = sourceLocation.list();
+            for(int i=0; i<children.length; i++){
+                copyDirectoryAll(new File(sourceLocation, children[i]), new File(targetLoacation, children[i]));
+            }
+        }
+
+        else{
+            FileInputStream in = new FileInputStream(sourceLocation);
+            FileOutputStream out = new FileOutputStream(targetLoacation);
+
+            FileChannel inChannel = in.getChannel();
+            FileChannel outChannel = out.getChannel();
+            inChannel.transferTo(0, inChannel.size(), outChannel);
+            inChannel.close();
+            outChannel.close();
+
+        }
+        return true;
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/base/services/core/jni/Android.mk SAMD_6.0.1_r11_20170930/frameworks/base/services/core/jni/Android.mk
--- Android_6.0.1_r11/frameworks/base/services/core/jni/Android.mk	2017-09-27 02:07:57.551735999 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/jni/Android.mk	2016-11-01 17:36:40.414408000 +0900
@@ -33,6 +33,7 @@
     $(LOCAL_REL_DIR)/com_android_server_UsbHostManager.cpp \
     $(LOCAL_REL_DIR)/com_android_server_VibratorService.cpp \
     $(LOCAL_REL_DIR)/com_android_server_PersistentDataBlockService.cpp \
+    $(LOCAL_REL_DIR)/com_android_server_remote_RemoteService.cpp \
     $(LOCAL_REL_DIR)/onload.cpp
 
 LOCAL_C_INCLUDES += \
@@ -47,7 +48,7 @@
     system/security/keystore/include \
     $(call include-path-for, libhardware)/hardware \
     $(call include-path-for, libhardware_legacy)/hardware_legacy \
-
+    
 LOCAL_SHARED_LIBRARIES += \
     libandroid_runtime \
     libandroidfw \
@@ -71,4 +72,4 @@
     libEGL \
     libGLESv2 \
     libnetutils \
-
+    
diff -urN Android_6.0.1_r11/frameworks/base/services/core/jni/com_android_server_remote_RemoteService.cpp SAMD_6.0.1_r11_20170930/frameworks/base/services/core/jni/com_android_server_remote_RemoteService.cpp
--- Android_6.0.1_r11/frameworks/base/services/core/jni/com_android_server_remote_RemoteService.cpp	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/jni/com_android_server_remote_RemoteService.cpp	2016-11-01 17:36:40.414408000 +0900
@@ -0,0 +1,356 @@
+//#define LOG_TAG "RemoteService JNI"
+
+#include "jni.h"
+#include "JNIHelp.h"
+#include "android_os_MessageQueue.h"
+#include "android_runtime/AndroidRuntime.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include <dirent.h>
+#include <cutils/fs.h>
+#include <sys/stat.h>
+
+#include <gui/Sensor.h>
+#include <gui/SensorManager.h>
+
+#define PKG_PATH_MAX	256
+
+namespace android
+{
+
+void mkinnerdirs(char* path, int basepos, mode_t mode, int uid, int gid,
+        struct stat* statbuf)
+{
+    while (path[basepos] != 0) {
+        if (path[basepos] == '/') {
+            path[basepos] = 0;
+            if (lstat(path, statbuf) < 0) {
+                ALOGV("Making directory: %s\n", path);
+                if (mkdir(path, mode) == 0) {
+                    chown(path, uid, gid);
+                } else {
+                    ALOGW("Unable to make directory %s: %s\n", path, strerror(errno));
+                }
+            }
+            path[basepos] = '/';
+            basepos++;
+        }
+        basepos++;
+    }
+}
+
+int movefileordir(char* srcpath, char* dstpath, int dstbasepos,
+        int dstuid, int dstgid, struct stat* statbuf)
+{
+    DIR *d;
+    struct dirent *de;
+    int res;
+
+    int srcend = strlen(srcpath);
+    int dstend = strlen(dstpath);
+
+    if (lstat(srcpath, statbuf) < 0) {
+        ALOGW("Unable to stat %s: %s\n", srcpath, strerror(errno));
+        return 1;
+    }
+
+    if ((statbuf->st_mode&S_IFDIR) == 0) {
+        mkinnerdirs(dstpath, dstbasepos, S_IRWXU|S_IRWXG|S_IXOTH,
+                dstuid, dstgid, statbuf);
+        ALOGV("Renaming %s to %s (uid %d)\n", srcpath, dstpath, dstuid);
+        if (rename(srcpath, dstpath) >= 0) {
+            if (chown(dstpath, dstuid, dstgid) < 0) {
+                ALOGE("cannot chown %s: %s\n", dstpath, strerror(errno));
+                unlink(dstpath);
+                return 1;
+            }
+        } else {
+            ALOGW("Unable to rename %s to %s: %s\n",
+                srcpath, dstpath, strerror(errno));
+            return 1;
+        }
+        return 0;
+    }
+
+    d = opendir(srcpath);
+    if (d == NULL) {
+        ALOGW("Unable to opendir %s: %s\n", srcpath, strerror(errno));
+        return 1;
+    }
+
+    res = 0;
+
+    while ((de = readdir(d))) {
+        const char *name = de->d_name;
+            /* always skip "." and ".." */
+        if (name[0] == '.') {
+            if (name[1] == 0) continue;
+            if ((name[1] == '.') && (name[2] == 0)) continue;
+        }
+
+        if ((srcend+strlen(name)) >= (PKG_PATH_MAX-2)) {
+            ALOGW("Source path too long; skipping: %s/%s\n", srcpath, name);
+            continue;
+        }
+
+        if ((dstend+strlen(name)) >= (PKG_PATH_MAX-2)) {
+            ALOGW("Destination path too long; skipping: %s/%s\n", dstpath, name);
+            continue;
+        }
+
+        srcpath[srcend] = dstpath[dstend] = '/';
+        strcpy(srcpath+srcend+1, name);
+        strcpy(dstpath+dstend+1, name);
+
+        if (movefileordir(srcpath, dstpath, dstbasepos, dstuid, dstgid, statbuf) != 0) {
+            res = 1;
+        }
+
+        // Note: we will be leaving empty directories behind in srcpath,
+        // but that is okay, the package manager will be erasing all of the
+        // data associated with .apks that disappear.
+
+        srcpath[srcend] = dstpath[dstend] = 0;
+    }
+
+    closedir(d);
+    return res;
+}
+
+static int _delete_dir_contents(DIR *d)
+{
+	int result;
+	struct dirent *de;
+	int dfd;
+
+	dfd = dirfd(d);
+
+	while((de = readdir(d)))
+	{
+		const char *name = de->d_name;
+
+		if(de->d_type == DT_DIR)
+		{
+			int subfd;
+			DIR *subdir;
+
+			if(name[0] == '.')
+			{
+				if(name[1] == 0) continue;
+				if((name[1] == '.') && (name[2] == 0)) continue;
+			}
+
+			subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+			if(subfd < 0)
+			{
+				ALOGE("ERROR1 - %s", name);
+				result = -1;
+				continue;
+			}
+			subdir = fdopendir(subfd);
+			if(subdir == NULL)
+			{
+				ALOGE("ERROR2 - %s", name);
+				close(subfd);
+				result = -1;
+				continue;
+			}
+			if(_delete_dir_contents(subdir))
+			{
+				result = -1;
+			}
+			closedir(subdir);
+			if(unlinkat(dfd, name, AT_REMOVEDIR) < 0)
+			{
+				ALOGE("ERROR4 - %s", name);
+				result = -1;
+			}
+		}
+		else
+		{
+			if(unlinkat(dfd, name, 0) < 0)
+			{
+				ALOGE("ERROR5 - %s: %s", name, strerror(errno));
+				result = -1;
+			}
+		}
+	}
+
+	return result;
+}
+
+static void replace_oat(JNIEnv *env, jobject clazz, jstring jPath)
+{
+	const char *name = NULL;
+	name = jPath ? env->GetStringUTFChars(jPath, NULL) : NULL;
+
+	ALOGD("PATH = %s", name);
+
+
+	int dstuid = -1, dstgid = -1;
+	struct stat s;
+
+	/*
+	char buf[PKG_PATH_MAX+1];
+	int bufp, bufe, bufi, readlen;
+
+
+	char srcpkg[PKG_PATH_MAX];
+	char dstpkg[PKG_PATH_MAX];*/
+
+	char srcapk[PKG_PATH_MAX];
+	char srcoat[PKG_PATH_MAX];
+	char dstapk[PKG_PATH_MAX];
+	char dstoat[PKG_PATH_MAX];
+
+	/*strcpy(srcpkg, dex_path);
+	strcpy(dstpkg, "/data/app/com.android.dcslab.testapplication-1/base.apk");*/
+
+	//strcpy(srcapk, "/data/local/tmp/");
+	//strcpy(srcapk, "/system/app/Dummy/");
+	strcpy(srcapk, name);
+	//strcat(srcapk, name);
+	strcat(srcapk, ".apk");
+
+
+	//strcpy(srcoat, "/data/local/tmp/");
+	//strcpy(srcoat, "/system/app/Dummy/");
+	strcpy(srcoat, name);
+	//strcat(srcoat, name);
+	strcat(srcoat, ".odex");
+
+
+	strcpy(dstapk, "/system/app/Dummy/Dummy.apk");
+	strcpy(dstoat, "/system/app/Dummy/oat/arm64/Dummy.odex");
+
+	ALOGD("srcapk = %s\nsrcoat = %s", srcapk, srcoat);
+
+
+	// delete .apk and .odex
+	DIR *d1 = opendir("/system/app/Dummy");
+	int dfd = dirfd(d1);
+
+	if(unlinkat(dfd, dstapk, 0) < 0)
+	{
+		ALOGE("ERROR - %s: %s", dstapk, strerror(errno));
+	}
+
+	DIR *d2 = opendir("/system/app/Dummy/oat/arm64");
+	dfd = dirfd(d2);
+
+	if(unlinkat(dfd, dstoat, 0) < 0)
+	{
+		ALOGE("ERROR - %s: %s", dstoat, strerror(errno));
+	}
+
+
+
+
+	if (rename(srcapk, dstapk) < 0)
+	{
+		 ALOGW("Unable to rename %s to %s: %s\n",
+				 srcapk, dstapk, strerror(errno));
+	}
+
+	if (rename(srcoat, dstoat) < 0)
+	{
+		 ALOGW("Unable to rename %s to %s: %s\n",
+				 srcoat, dstoat, strerror(errno));
+	}
+
+
+
+	/*if(lstat(dstapk, &s) == 0)
+	{
+		dstuid = s.st_uid;
+		dstgid = s.st_gid;
+	}
+
+	//chown(srcpkg, dstuid, dstgid);
+	if (chown(srcapk, dstuid, dstgid) < 0) {
+		ALOGE("cannot chown %s: %s\n", srcapk, strerror(errno));
+		//unlink(dstpath);
+	}*/
+
+	lstat(srcapk, &s);
+	movefileordir(srcapk, dstapk, 0, dstuid, dstgid, &s);
+
+
+	/*if(lstat(dstoat, &s) == 0)
+	{
+		dstuid = s.st_uid;
+		dstgid = s.st_gid;
+	}
+
+	if (chown(srcoat, dstuid, dstgid) < 0) {
+		ALOGE("cannot chown %s: %s\n", srcoat, strerror(errno));
+		//unlink(dstpath);
+	}*/
+
+	lstat(srcoat, &s);
+	movefileordir(srcoat, dstoat, 0, dstuid, dstgid, &s);
+
+//	if(rename(dex_path, "/system/app/Dummy/oat/arm64/Dummy.odex") < 0)
+	/*if(rename(dex_path, "/data/local/tmp/Dummy2.odex") < 0)
+	{
+		ALOGE("Couldn't move %s: %s", dex_path, strerror(errno));
+	}*/
+
+
+	//delete_dir_contents(dex_path, 0, NULL);
+
+	//unlink(dex_path);
+}
+
+
+
+static JNINativeMethod gRemoteServiceMethods[] = {
+  //  { "sendRemoteEvent", "(II[FIJI)V", (void*)sendRemoteEvent },
+  //  { "setServerOn", "(Z)V", (void*)setServerOn }
+		{ "replaceOAT", "(Ljava/lang/String;)V", (void*)replace_oat }
+};
+
+/*
+static JNINativeMethod gReceiverMethods[] = {
+    { "sendRemoteEvent", "(II[FIJI)V", (void*)sendRemoteEvent }
+};
+*/
+
+
+
+#define FIND_CLASS(var, className) \
+        var = env->FindClass(className); \
+        LOG_FATAL_IF(! var, "Unable to find class " className); \
+        var = jclass(env->NewGlobalRef(var));
+
+#define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) \
+        var = env->GetMethodID(clazz, methodName, methodDescriptor); \
+        LOG_FATAL_IF(! var, "Unable to find method " methodName);
+
+int register_android_server_remote_RemoteService(JNIEnv *env)
+{
+	/*jniRegisterNativeMethods(env, "com/android/server/remote/RemoteService",
+			gRemoteServiceMethods, NELEM(gRemoteServiceMethods));*/
+/*
+	jniRegisterNativeMethods(env, "com/android/server/remote/Receiver",
+			gReceiverMethods, NELEM(gReceiverMethods));*/
+
+
+
+
+	/*FIND_CLASS(gBaseEventQueueClassInfo.clazz, "android/hardware/SystemSensorManager$BaseEventQueue");
+
+	GET_METHOD_ID(gBaseEventQueueClassInfo.dispatchSensorEvent,
+			gBaseEventQueueClassInfo.clazz,
+			"dispatchSensorEvent", "(I[FIJI)V");
+
+	GET_METHOD_ID(gBaseEventQueueClassInfo.dispatchFlushCompleteEvent,
+				  gBaseEventQueueClassInfo.clazz,
+				  "dispatchFlushCompleteEvent", "(I)V");*/
+
+	return 0;
+}
+};
diff -urN Android_6.0.1_r11/frameworks/base/services/core/jni/onload.cpp SAMD_6.0.1_r11_20170930/frameworks/base/services/core/jni/onload.cpp
--- Android_6.0.1_r11/frameworks/base/services/core/jni/onload.cpp	2017-09-27 02:07:57.555735999 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/core/jni/onload.cpp	2016-11-01 17:36:40.414408000 +0900
@@ -43,6 +43,7 @@
 int register_android_server_tv_TvInputHal(JNIEnv* env);
 int register_android_server_PersistentDataBlockService(JNIEnv* env);
 int register_android_server_Watchdog(JNIEnv* env);
+int register_android_server_remote_RemoteService(JNIEnv* env);
 };
 
 using namespace android;
@@ -81,6 +82,7 @@
     register_android_server_tv_TvInputHal(env);
     register_android_server_PersistentDataBlockService(env);
     register_android_server_Watchdog(env);
+    register_android_server_remote_RemoteService(env);
 
 
     return JNI_VERSION_1_4;
diff -urN Android_6.0.1_r11/frameworks/base/services/java/com/android/server/SystemServer.java SAMD_6.0.1_r11_20170930/frameworks/base/services/java/com/android/server/SystemServer.java
--- Android_6.0.1_r11/frameworks/base/services/java/com/android/server/SystemServer.java	2017-09-27 02:07:57.559735999 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/services/java/com/android/server/SystemServer.java	2017-09-15 13:05:48.784050000 +0900
@@ -56,8 +56,10 @@
 import com.android.server.camera.CameraService;
 import com.android.server.clipboard.ClipboardService;
 import com.android.server.content.ContentService;
+import com.android.server.devicemanagement.DeviceManagementService;
 import com.android.server.devicepolicy.DevicePolicyManagerService;
 import com.android.server.display.DisplayManagerService;
+import com.android.server.distribute.DistributedComputingService;
 import com.android.server.dreams.DreamManagerService;
 import com.android.server.fingerprint.FingerprintService;
 import com.android.server.hdmi.HdmiControlService;
@@ -79,6 +81,7 @@
 import com.android.server.power.PowerManagerService;
 import com.android.server.power.ShutdownThread;
 import com.android.server.restrictions.RestrictionsManagerService;
+import com.android.server.samd.SAMDService;
 import com.android.server.search.SearchManagerService;
 import com.android.server.statusbar.StatusBarManagerService;
 import com.android.server.storage.DeviceStorageMonitorService;
@@ -91,6 +94,9 @@
 import com.android.server.wallpaper.WallpaperManagerService;
 import com.android.server.webkit.WebViewUpdateService;
 import com.android.server.wm.WindowManagerService;
+import com.android.server.remote.RemoteService;
+import com.android.server.devicemanagement.DeviceManagementService;
+import com.android.server.distribute.DistributedComputingService;
 
 import dalvik.system.VMRuntime;
 
@@ -152,7 +158,9 @@
     private PackageManagerService mPackageManagerService;
     private PackageManager mPackageManager;
     private ContentResolver mContentResolver;
-
+    private RemoteService mRemoteService;
+    private SAMDService mSAMDService;
+    
     private boolean mOnlyCore;
     private boolean mFirstBoot;
 
@@ -360,6 +368,12 @@
             Slog.w(TAG, "Device encrypted - only parsing core apps");
             mOnlyCore = true;
         }
+        // ADDED FOR COLLABOROID
+        mRemoteService = new RemoteService(mSystemContext);
+        ServiceManager.addService(Context.REMOTE_SERVICE, mRemoteService);
+
+        mSAMDService = new SAMDService(mSystemContext);
+        ServiceManager.addService(Context.SAMD_SERVICE, mSAMDService);
 
         // Start the package manager.
         Slog.i(TAG, "Package Manager");
@@ -368,6 +382,8 @@
         mFirstBoot = mPackageManagerService.isFirstBoot();
         mPackageManager = mSystemContext.getPackageManager();
 
+
+
         Slog.i(TAG, "User Service");
         ServiceManager.addService(Context.USER_SERVICE, UserManagerService.getInstance());
 
@@ -380,6 +396,10 @@
         // The sensor service needs access to package manager service, app ops
         // service, and permissions service, therefore we start it after them.
         startSensorService();
+
+        //mSystemServiceManager.startService(RemoteService.class);
+        //mActivityManagerService.setSystemServiceManager(mSystemServiceManager);
+        //mRemoteService.setInstaller(installer);
     }
 
     /**
@@ -429,7 +449,12 @@
         MmsServiceBroker mmsService = null;
         EntropyMixer entropyMixer = null;
         CameraService cameraService = null;
-
+        
+        // ADDED FOR COLLABOROID
+        DeviceManagementService deviceService = null;
+        //RemoteService remoteService = null;
+        DistributedComputingService distributedComputingService = null;
+        
         boolean disableStorage = SystemProperties.getBoolean("config.disable_storage", false);
         boolean disableBluetooth = SystemProperties.getBoolean("config.disable_bluetooth", false);
         boolean disableLocation = SystemProperties.getBoolean("config.disable_location", false);
@@ -484,6 +509,24 @@
             Slog.i(TAG, "Consumer IR Service");
             consumerIr = new ConsumerIrService(context);
             ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr);
+            
+            // ADDED FOR COLLABOROID
+            Slog.i(TAG, "Device Management Service");
+            deviceService = new DeviceManagementService(context);
+            ServiceManager.addService(Context.DEVICE_MANAGEMENT_SERVICE, deviceService);
+            
+            /*Slog.i(TAG, "Remote Service");
+            remoteService = new RemoteService(context);
+            ServiceManager.addService(Context.REMOTE_SERVICE, remoteService);*/
+            //mSystemServiceManager.startService(RemoteService.class);
+            
+            /*Slog.i(TAG, "Consumer IR Service");
+            consumerIr = new ConsumerIrService(context);
+            ServiceManager.addService(Context.DISTRI_SERVICE, consumerIr);*/
+           
+            
+           
+            
 
             mSystemServiceManager.startService(AlarmManagerService.class);
             alarm = IAlarmManager.Stub.asInterface(
@@ -545,7 +588,7 @@
 
         // Bring up services needed for UI.
         if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
-            try {
+        	try {
                 Slog.i(TAG, "Input Method Service");
                 imm = new InputMethodManagerService(context, wm);
                 ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm);
@@ -605,7 +648,7 @@
 
         if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
             if (!disableNonCoreServices) {
-                try {
+            	try {
                     Slog.i(TAG,  "LockSettingsService");
                     lockSettings = new LockSettingsService(context);
                     ServiceManager.addService("lock_settings", lockSettings);
@@ -1066,7 +1109,7 @@
         } catch (Throwable e) {
             reportWtf("making Display Manager Service ready", e);
         }
-
+        
         // These are needed to propagate to the runnable below.
         final NetworkManagementService networkManagementF = networkManagement;
         final NetworkStatsService networkStatsF = networkStats;
@@ -1145,7 +1188,7 @@
                     reportWtf("Notifying AudioService running", e);
                 }
                 Watchdog.getInstance().start();
-
+                
                 // It is now okay to let the various system services start their
                 // third party code...
                 mSystemServiceManager.startBootPhase(
diff -urN Android_6.0.1_r11/frameworks/base/tests/HierarchyViewerTest/.gitignore SAMD_6.0.1_r11_20170930/frameworks/base/tests/HierarchyViewerTest/.gitignore
--- Android_6.0.1_r11/frameworks/base/tests/HierarchyViewerTest/.gitignore	2017-09-27 02:07:57.631735998 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tests/HierarchyViewerTest/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,6 +0,0 @@
-.gradle
-.idea
-*.iml
-gradle*
-build
-local.properties
diff -urN Android_6.0.1_r11/frameworks/base/tests/HwAccelerationTest/.gitignore SAMD_6.0.1_r11_20170930/frameworks/base/tests/HwAccelerationTest/.gitignore
--- Android_6.0.1_r11/frameworks/base/tests/HwAccelerationTest/.gitignore	2017-09-27 02:07:57.631735998 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tests/HwAccelerationTest/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,3 +0,0 @@
-bin
-gen
-local.properties
\ No newline at end of file
diff -urN Android_6.0.1_r11/frameworks/base/tools/aapt/Android.mk SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt/Android.mk
--- Android_6.0.1_r11/frameworks/base/tools/aapt/Android.mk	2017-09-27 02:07:57.719735997 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt/Android.mk	2017-07-11 02:09:31.535236000 +0900
@@ -82,7 +82,8 @@
 ifneq ($(strip $(USE_MINGW)),)
     aaptHostStaticLibs += libz
 else
-    aaptHostLdLibs += -lz
+    #reviseApp
+    aaptHostLdLibs += -lz -llog
 endif
 
 
@@ -133,5 +134,30 @@
 
 include $(BUILD_HOST_NATIVE_TEST)
 
+# ==========================================================
+# Build the device executable: aapt
+# ==========================================================
+ifneq ($(SDK_ONLY),true)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := aapt
+LOCAL_CFLAGS += $(aaptCFlags)
+LOCAL_SRC_FILES := $(aaptSources) $(aaptMain)
+LOCAL_C_INCLUDES += \
+    $(aaptCIncludes) \
+    bionic
+LOCAL_SHARED_LIBRARIES := \
+    libandroidfw \
+    libutils \
+    libcutils \
+    libpng \
+    liblog \
+    libz
+LOCAL_STATIC_LIBRARIES := \
+    libexpat_static
+
+include $(BUILD_EXECUTABLE)
+
+endif # Not SDK_ONLY
 
 endif # No TARGET_BUILD_APPS or TARGET_BUILD_PDK
diff -urN Android_6.0.1_r11/frameworks/base/tools/aapt/Command.cpp SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt/Command.cpp
--- Android_6.0.1_r11/frameworks/base/tools/aapt/Command.cpp	2017-09-27 02:07:57.719735997 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt/Command.cpp	2017-07-10 18:09:22.361728000 +0900
@@ -692,7 +692,6 @@
             delete asset;
             asset = NULL;
         }
-
     } else {
         asset = assets.openNonAsset(assetsCookie, "AndroidManifest.xml", Asset::ACCESS_BUFFER);
         if (asset == NULL) {
diff -urN Android_6.0.1_r11/frameworks/base/tools/aapt/ResourceTable.cpp SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt/ResourceTable.cpp
--- Android_6.0.1_r11/frameworks/base/tools/aapt/ResourceTable.cpp	2017-09-27 02:07:57.723735997 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt/ResourceTable.cpp	2017-07-12 02:48:38.326244000 +0900
@@ -17,9 +17,14 @@
 #include <utils/ByteOrder.h>
 #include <utils/TypeHelpers.h>
 #include <stdarg.h>
+// reviseApp
+#include <android/log.h>
 
 // SSIZE: mingw does not have signed size_t == ssize_t.
 // STATUST: mingw does seem to redefine UNKNOWN_ERROR from our enum value, so a cast is necessary.
+// reviseApp
+#define APPNAME "reviseApp"
+
 #if !defined(_WIN32)
 #  define SSIZE(x) x
 #  define STATUST(x) x
@@ -1864,6 +1869,15 @@
         .identifierForName(name.string(), name.size(),
                            type.string(), type.size(),
                            package.string(), package.size());
+    String8 s1(package);
+    String8 s2(type);
+    String8 s3(name);
+    String8 s4(value);
+    //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp package : %s" , s1.string());
+    //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp type : %s" , s2.string());
+    //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp name : %s" , s3.string());
+    //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp value : %s" , s4.string());
+
     if (rid != 0) {
         sourcePos.error("Resource entry %s/%s is already defined in package %s.",
                 String8(type).string(), String8(name).string(), String8(package).string());
@@ -3707,6 +3721,13 @@
         par.dataType = it.parsedValue.dataType;
         par.res0 = it.parsedValue.res0;
         par.data = htodl(it.parsedValue.data);
+
+
+        //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp item : %s" , String8(mName).string());
+        //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp par.data : 0x%x" , it.parsedValue.data);
+        //__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "reviseApp par.res0 : 0x%x" , par.res0);
+
+
         #if 0
         printf("Writing item (%s): type=%d, data=0x%x, res0=0x%x\n",
                String8(mName).string(), it.parsedValue.dataType,
diff -urN Android_6.0.1_r11/frameworks/base/tools/aapt2/SdkConstants.cpp SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt2/SdkConstants.cpp
--- Android_6.0.1_r11/frameworks/base/tools/aapt2/SdkConstants.cpp	2017-09-27 02:07:57.731735997 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tools/aapt2/SdkConstants.cpp	2017-01-30 01:02:12.925758000 +0900
@@ -530,6 +530,8 @@
     { u"windowSwipeToDismiss", 20 },
     { u"isGame", 20 },
     { u"allowEmbedded", 20 },
+    //collaboroid
+    { u"remoteable", 20 },
     { u"setupActivity", 20 },
     { u"fastScrollStyle", 21 },
     { u"windowContentTransitions", 21 },
diff -urN Android_6.0.1_r11/frameworks/base/tools/layoutlib/bridge/tests/res/testApp/MyApplication/.gitignore SAMD_6.0.1_r11_20170930/frameworks/base/tools/layoutlib/bridge/tests/res/testApp/MyApplication/.gitignore
--- Android_6.0.1_r11/frameworks/base/tools/layoutlib/bridge/tests/res/testApp/MyApplication/.gitignore	2017-09-27 02:07:57.919735995 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tools/layoutlib/bridge/tests/res/testApp/MyApplication/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,14 +0,0 @@
-.gradle
-local.properties
-.idea
-.DS_Store
-*.iml
-# We need the built .class files to load custom views and R class.
-# The only way to negate an exclusion is by including every single parent
-# and excluding all children of those parents.
-
-/build/*
-!/build/intermediates/
-
-/build/intermediates/*
-!/build/intermediates/classes/
diff -urN Android_6.0.1_r11/frameworks/base/tools/layoutlib/.gitignore SAMD_6.0.1_r11_20170930/frameworks/base/tools/layoutlib/.gitignore
--- Android_6.0.1_r11/frameworks/base/tools/layoutlib/.gitignore	2017-09-27 02:07:57.767735997 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/base/tools/layoutlib/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,3 +0,0 @@
-bin
-/.idea/workspace.xml
-/out
Binary files Android_6.0.1_r11/frameworks/compile/libbcc/.git/index and SAMD_6.0.1_r11_20170930/frameworks/compile/libbcc/.git/index differ
Binary files Android_6.0.1_r11/frameworks/compile/mclinker/.git/index and SAMD_6.0.1_r11_20170930/frameworks/compile/mclinker/.git/index differ
Binary files Android_6.0.1_r11/frameworks/compile/slang/.git/index and SAMD_6.0.1_r11_20170930/frameworks/compile/slang/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/data-binding/compiler/src/main/resources/api-versions.xml SAMD_6.0.1_r11_20170930/frameworks/data-binding/compiler/src/main/resources/api-versions.xml
--- Android_6.0.1_r11/frameworks/data-binding/compiler/src/main/resources/api-versions.xml	2017-09-27 02:07:58.915735982 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/compiler/src/main/resources/api-versions.xml	2017-01-30 01:04:39.116965000 +0900
@@ -295,6 +295,8 @@
 		<field name="allowBackup" since="4" />
 		<field name="allowClearUserData" />
 		<field name="allowEmbedded" since="20" />
+		<!-- collaboroid -->
+		<field name="remoteable" since="20" />
 		<field name="allowParallelSyncs" since="11" />
 		<field name="allowSingleTap" since="3" />
 		<field name="allowTaskReparenting" />
Binary files Android_6.0.1_r11/frameworks/data-binding/.git/index and SAMD_6.0.1_r11_20170930/frameworks/data-binding/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/data-binding/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/.gitignore	2017-09-27 02:07:58.899735982 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,5 +0,0 @@
-build
-local.properties
-.gradle
-maven-repo
-.caches
diff -urN "Android_6.0.1_r11/frameworks/data-binding/integration-tests/App With Spaces/app/.gitignore" "SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/App With Spaces/app/.gitignore"
--- "Android_6.0.1_r11/frameworks/data-binding/integration-tests/App With Spaces/app/.gitignore"	2017-09-27 02:07:58.923735982 +0900
+++ "SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/App With Spaces/app/.gitignore"	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-/build
diff -urN Android_6.0.1_r11/frameworks/data-binding/integration-tests/IndependentLibrary/app/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/IndependentLibrary/app/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/integration-tests/IndependentLibrary/app/.gitignore	2017-09-27 02:07:58.923735982 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/IndependentLibrary/app/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-/build
diff -urN Android_6.0.1_r11/frameworks/data-binding/integration-tests/MultiModuleTestApp/app/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/MultiModuleTestApp/app/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/integration-tests/MultiModuleTestApp/app/.gitignore	2017-09-27 02:07:58.923735982 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/MultiModuleTestApp/app/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-/build
diff -urN Android_6.0.1_r11/frameworks/data-binding/integration-tests/MultiModuleTestApp/testlibrary/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/MultiModuleTestApp/testlibrary/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/integration-tests/MultiModuleTestApp/testlibrary/.gitignore	2017-09-27 02:07:58.923735982 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/MultiModuleTestApp/testlibrary/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-/build
diff -urN Android_6.0.1_r11/frameworks/data-binding/integration-tests/TestApp/app/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/TestApp/app/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/integration-tests/TestApp/app/.gitignore	2017-09-27 02:07:58.923735982 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/TestApp/app/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-/build
diff -urN Android_6.0.1_r11/frameworks/data-binding/integration-tests/TestApp/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/TestApp/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/integration-tests/TestApp/.gitignore	2017-09-27 02:07:58.923735982 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/integration-tests/TestApp/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,6 +0,0 @@
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
-.DS_Store
-/build
diff -urN Android_6.0.1_r11/frameworks/data-binding/samples/BindingDemo/app/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/samples/BindingDemo/app/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/samples/BindingDemo/app/.gitignore	2017-09-27 02:07:59.007735981 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/samples/BindingDemo/app/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-/build
diff -urN Android_6.0.1_r11/frameworks/data-binding/samples/BindingDemo/.gitignore SAMD_6.0.1_r11_20170930/frameworks/data-binding/samples/BindingDemo/.gitignore
--- Android_6.0.1_r11/frameworks/data-binding/samples/BindingDemo/.gitignore	2017-09-27 02:07:59.007735981 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/data-binding/samples/BindingDemo/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,6 +0,0 @@
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
-.DS_Store
-/build
Binary files Android_6.0.1_r11/frameworks/ex/.git/index and SAMD_6.0.1_r11_20170930/frameworks/ex/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/ex/photoviewer/.gitignore SAMD_6.0.1_r11_20170930/frameworks/ex/photoviewer/.gitignore
--- Android_6.0.1_r11/frameworks/ex/photoviewer/.gitignore	2017-09-27 02:07:59.111735979 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/ex/photoviewer/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,8 +0,0 @@
-*~
-*.bak
-*.class
-bin/
-gen/
-*.properties
-.classpath
-.project
Binary files Android_6.0.1_r11/frameworks/mff/.git/index and SAMD_6.0.1_r11_20170930/frameworks/mff/.git/index differ
Binary files Android_6.0.1_r11/frameworks/minikin/.git/index and SAMD_6.0.1_r11_20170930/frameworks/minikin/.git/index differ
Binary files Android_6.0.1_r11/frameworks/ml/.git/index and SAMD_6.0.1_r11_20170930/frameworks/ml/.git/index differ
Binary files Android_6.0.1_r11/frameworks/multidex/.git/index and SAMD_6.0.1_r11_20170930/frameworks/multidex/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/multidex/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java SAMD_6.0.1_r11_20170930/frameworks/multidex/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java
--- Android_6.0.1_r11/frameworks/multidex/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java	2017-09-27 02:07:59.559735974 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/multidex/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java	2017-01-29 18:36:04.409813000 +0900
@@ -16,6 +16,7 @@
 
 package com.android.test.runner;
 
+
 import android.os.Bundle;
 import android.support.multidex.MultiDex;
 import android.test.InstrumentationTestRunner;
diff -urN Android_6.0.1_r11/frameworks/native/cmds/installd/commands.cpp SAMD_6.0.1_r11_20170930/frameworks/native/cmds/installd/commands.cpp
--- Android_6.0.1_r11/frameworks/native/cmds/installd/commands.cpp	2017-09-27 02:07:59.631735973 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/cmds/installd/commands.cpp	2017-08-07 14:11:01.498146000 +0900
@@ -29,6 +29,8 @@
 #include <sys/file.h>
 #include <unistd.h>
 
+#include <android/log.h>
+
 using android::base::StringPrintf;
 
 /* Directory records that are used in execution of commands. */
@@ -45,6 +47,7 @@
 
 int install(const char *uuid, const char *pkgname, uid_t uid, gid_t gid, const char *seinfo)
 {
+
     if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
         ALOGE("invalid uid/gid: %d %d\n", uid, gid);
         return -1;
@@ -467,6 +470,26 @@
     }
 }
 
+// ADDED FOR COLLABOROID
+int move_file(const char *src, const char *dst)
+{
+/*    char src_file[PKG_PATH_MAX];
+    char dst_file[PKG_PATH_MAX];
+
+    strcpy(src_file, src);
+    strcpy(dst_file, dst);
+
+    ALOGV("move %s -> %s\n", src_file, dst_file);
+
+    if (rename(src_file, dst_file) < 0) {
+        ALOGE("Couldn't move %s: %s\n", src_file, strerror(errno));
+        return -1;
+    } else {
+        return 0;
+    }*/
+	return move_dex(src, dst, "arm");
+}
+
 int rm_dex(const char *path, const char *instruction_set)
 {
     char dex_path[PKG_PATH_MAX];
@@ -969,6 +992,231 @@
     // Do not add after dex2oat_flags, they should override others for debugging.
     argv[i] = NULL;
 
+
+    execv(DEX2OAT_BIN, (char * const *)argv);
+    ALOGE("execv(%s) failed: %s\n", DEX2OAT_BIN, strerror(errno));
+}
+
+static void run_dex2oat2(const char *dex_path, int oat_fd, const char* input_file_name,
+    const char* output_file_name, int swap_fd, const char *pkgname, const char *instruction_set,
+    bool debuggable)
+{
+    static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
+
+    if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) {
+        ALOGE("Instruction set %s longer than max length of %d",
+              instruction_set, MAX_INSTRUCTION_SET_LEN);
+        return;
+    }
+
+    char prop_buf[PROPERTY_VALUE_MAX];
+    bool profiler = (property_get("dalvik.vm.profiler", prop_buf, "0") > 0) && (prop_buf[0] == '1');
+
+    char dex2oat_Xms_flag[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_Xms_flag = property_get("dalvik.vm.dex2oat-Xms", dex2oat_Xms_flag, NULL) > 0;
+
+    char dex2oat_Xmx_flag[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_Xmx_flag = property_get("dalvik.vm.dex2oat-Xmx", dex2oat_Xmx_flag, NULL) > 0;
+
+    char dex2oat_compiler_filter_flag[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_compiler_filter_flag = property_get("dalvik.vm.dex2oat-filter",
+                                                          dex2oat_compiler_filter_flag, NULL) > 0;
+
+    char dex2oat_threads_buf[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_threads_flag = false;
+    if (true) {
+        have_dex2oat_threads_flag = property_get("dalvik.vm.boot-dex2oat-threads",
+                                                 dex2oat_threads_buf,
+                                                 NULL) > 0;
+        // If there's no boot property, fall back to the image property.
+        if (!have_dex2oat_threads_flag) {
+            have_dex2oat_threads_flag = property_get("dalvik.vm.image-dex2oat-threads",
+                                                     dex2oat_threads_buf,
+                                                     NULL) > 0;
+        }
+        // If there's neither, fall back to the default property.
+    }
+    if (!have_dex2oat_threads_flag) {
+        have_dex2oat_threads_flag = property_get("dalvik.vm.dex2oat-threads",
+                                                 dex2oat_threads_buf,
+                                                 NULL) > 0;
+    }
+    char dex2oat_threads_arg[PROPERTY_VALUE_MAX + 2];
+    if (have_dex2oat_threads_flag) {
+        sprintf(dex2oat_threads_arg, "-j%s", dex2oat_threads_buf);
+    }
+
+    char dex2oat_isa_features_key[PROPERTY_KEY_MAX];
+    sprintf(dex2oat_isa_features_key, "dalvik.vm.isa.%s.features", instruction_set);
+    char dex2oat_isa_features[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_isa_features = property_get(dex2oat_isa_features_key,
+                                                  dex2oat_isa_features, NULL) > 0;
+
+    char dex2oat_isa_variant_key[PROPERTY_KEY_MAX];
+    sprintf(dex2oat_isa_variant_key, "dalvik.vm.isa.%s.variant", instruction_set);
+    char dex2oat_isa_variant[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_isa_variant = property_get(dex2oat_isa_variant_key,
+                                                 dex2oat_isa_variant, NULL) > 0;
+
+    const char *dex2oat_norelocation = "-Xnorelocate";
+    bool have_dex2oat_relocation_skip_flag = false;
+
+    char dex2oat_flags[PROPERTY_VALUE_MAX];
+    int dex2oat_flags_count = property_get("dalvik.vm.dex2oat-flags",
+                                 dex2oat_flags, NULL) <= 0 ? 0 : split_count(dex2oat_flags);
+    ALOGV("dalvik.vm.dex2oat-flags=%s\n", dex2oat_flags);
+
+    // If we booting without the real /data, don't spend time compiling.
+    char vold_decrypt[PROPERTY_VALUE_MAX];
+    bool have_vold_decrypt = property_get("vold.decrypt", vold_decrypt, "") > 0;
+    bool skip_compilation = (have_vold_decrypt &&
+                             (strcmp(vold_decrypt, "trigger_restart_min_framework") == 0 ||
+                             (strcmp(vold_decrypt, "1") == 0)));
+
+    bool use_jit = check_boolean_property("debug.usejit");
+    bool generate_debug_info = check_boolean_property("debug.generate-debug-info");
+
+    static const char* DEX2OAT_BIN = "/system/bin/dex2oat";
+
+    static const char* RUNTIME_ARG = "--runtime-arg";
+
+    static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
+
+    char dex_location_arg[strlen("--dex-file=") + PKG_PATH_MAX];
+    char oat_fd_arg[strlen("--oat-fd=") + MAX_INT_LEN];
+    char oat_location_arg[strlen("--oat-location=") + PKG_PATH_MAX];
+    char instruction_set_arg[strlen("--instruction-set=") + MAX_INSTRUCTION_SET_LEN];
+    char instruction_set_variant_arg[strlen("--instruction-set-variant=") + PROPERTY_VALUE_MAX];
+    char instruction_set_features_arg[strlen("--instruction-set-features=") + PROPERTY_VALUE_MAX];
+    char profile_file_arg[strlen("--profile-file=") + PKG_PATH_MAX];
+    char top_k_profile_threshold_arg[strlen("--top-k-profile-threshold=") + PROPERTY_VALUE_MAX];
+    char dex2oat_Xms_arg[strlen("-Xms") + PROPERTY_VALUE_MAX];
+    char dex2oat_Xmx_arg[strlen("-Xmx") + PROPERTY_VALUE_MAX];
+    char dex2oat_compiler_filter_arg[strlen("--compiler-filter=") + PROPERTY_VALUE_MAX];
+    bool have_dex2oat_swap_fd = false;
+    char dex2oat_swap_fd[strlen("--swap-fd=") + MAX_INT_LEN];
+
+    sprintf(dex_location_arg, "--dex-file=%s", dex_path);
+    sprintf(oat_fd_arg, "--oat-fd=%d", oat_fd);
+    sprintf(oat_location_arg, "--oat-location=%s", output_file_name);
+    sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
+    sprintf(instruction_set_variant_arg, "--instruction-set-variant=%s", dex2oat_isa_variant);
+    sprintf(instruction_set_features_arg, "--instruction-set-features=%s", dex2oat_isa_features);
+    if (swap_fd >= 0) {
+        have_dex2oat_swap_fd = true;
+        sprintf(dex2oat_swap_fd, "--swap-fd=%d", swap_fd);
+    }
+
+    bool have_profile_file = false;
+    bool have_top_k_profile_threshold = false;
+    if (profiler && (strcmp(pkgname, "*") != 0)) {
+        char profile_file[PKG_PATH_MAX];
+        snprintf(profile_file, sizeof(profile_file), "%s/%s",
+                 DALVIK_CACHE_PREFIX "profiles", pkgname);
+        struct stat st;
+        if ((stat(profile_file, &st) == 0) && (st.st_size > 0)) {
+            sprintf(profile_file_arg, "--profile-file=%s", profile_file);
+            have_profile_file = true;
+            if (property_get("dalvik.vm.profile.top-k-thr", prop_buf, NULL) > 0) {
+                snprintf(top_k_profile_threshold_arg, sizeof(top_k_profile_threshold_arg),
+                         "--top-k-profile-threshold=%s", prop_buf);
+                have_top_k_profile_threshold = true;
+            }
+        }
+    }
+
+    if (have_dex2oat_Xms_flag) {
+        sprintf(dex2oat_Xms_arg, "-Xms%s", dex2oat_Xms_flag);
+    }
+    if (have_dex2oat_Xmx_flag) {
+        sprintf(dex2oat_Xmx_arg, "-Xmx%s", dex2oat_Xmx_flag);
+    }
+    if (skip_compilation) {
+        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=verify-none");
+        have_dex2oat_compiler_filter_flag = true;
+        have_dex2oat_relocation_skip_flag = true;
+    } else if (use_jit) {
+        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=verify-at-runtime");
+        have_dex2oat_compiler_filter_flag = true;
+    } else if (have_dex2oat_compiler_filter_flag) {
+        sprintf(dex2oat_compiler_filter_arg, "--compiler-filter=%s", dex2oat_compiler_filter_flag);
+    }
+
+    // Check whether all apps should be compiled debuggable.
+    if (!debuggable) {
+        debuggable =
+                (property_get("dalvik.vm.always_debuggable", prop_buf, "0") > 0) &&
+                (prop_buf[0] == '1');
+    }
+
+    ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, input_file_name, output_file_name);
+
+    const char* argv[6  // program name, mandatory arguments and the final NULL
+                     + (have_dex2oat_isa_variant ? 1 : 0)
+                     + (have_dex2oat_isa_features ? 1 : 0)
+                     + (have_profile_file ? 1 : 0)
+                     + (have_top_k_profile_threshold ? 1 : 0)
+                     + (have_dex2oat_Xms_flag ? 2 : 0)
+                     + (have_dex2oat_Xmx_flag ? 2 : 0)
+                     + (have_dex2oat_compiler_filter_flag ? 1 : 0)
+                     + (have_dex2oat_threads_flag ? 1 : 0)
+                     + (have_dex2oat_swap_fd ? 1 : 0)
+                     + (have_dex2oat_relocation_skip_flag ? 2 : 0)
+                     + (generate_debug_info ? 1 : 0)
+                     + (debuggable ? 1 : 0)
+                     + dex2oat_flags_count];
+    int i = 0;
+    argv[i++] = DEX2OAT_BIN;
+    argv[i++] = dex_location_arg;
+    argv[i++] = oat_fd_arg;
+    argv[i++] = oat_location_arg;
+    argv[i++] = instruction_set_arg;
+    if (have_dex2oat_isa_variant) {
+        argv[i++] = instruction_set_variant_arg;
+    }
+    if (have_dex2oat_isa_features) {
+        argv[i++] = instruction_set_features_arg;
+    }
+    if (have_profile_file) {
+        argv[i++] = profile_file_arg;
+    }
+    if (have_top_k_profile_threshold) {
+        argv[i++] = top_k_profile_threshold_arg;
+    }
+    if (have_dex2oat_Xms_flag) {
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = dex2oat_Xms_arg;
+    }
+    if (have_dex2oat_Xmx_flag) {
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = dex2oat_Xmx_arg;
+    }
+    if (have_dex2oat_compiler_filter_flag) {
+        argv[i++] = dex2oat_compiler_filter_arg;
+    }
+    if (have_dex2oat_threads_flag) {
+        argv[i++] = dex2oat_threads_arg;
+    }
+    if (have_dex2oat_swap_fd) {
+        argv[i++] = dex2oat_swap_fd;
+    }
+    if (generate_debug_info) {
+        argv[i++] = "--generate-debug-info";
+    }
+    if (debuggable) {
+        argv[i++] = "--debuggable";
+    }
+    if (dex2oat_flags_count) {
+        i += split(dex2oat_flags, argv + i);
+    }
+    if (have_dex2oat_relocation_skip_flag) {
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = dex2oat_norelocation;
+    }
+    // Do not add after dex2oat_flags, they should override others for debugging.
+    argv[i] = NULL;
+
+
     execv(DEX2OAT_BIN, (char * const *)argv);
     ALOGE("execv(%s) failed: %s\n", DEX2OAT_BIN, strerror(errno));
 }
@@ -1735,6 +1983,503 @@
     return -1;
 }
 
+// ADDED FOR COLLABOROID
+int makeodex(const char *dex_path, const char *out_path, const char *pkgname)
+{
+	struct utimbuf ut;
+	struct stat dex_stat;
+	//char out_path[PKG_PATH_MAX];
+	char swap_file_name[PKG_PATH_MAX];
+	//const char *input_file;
+	int res, input_fd=-1, out_fd=-1, swap_fd=-1;
+
+	memset(&dex_stat, 0, sizeof(dex_stat));
+	stat(dex_path, &dex_stat);
+
+	input_fd = open(dex_path, O_RDONLY, 0);
+	if (input_fd < 0) {
+		ALOGE("installd cannot open '%s' for input during makeodex\n", dex_path);
+		return -1;
+	}
+
+	unlink(out_path);
+	out_fd = open(out_path, O_RDWR | O_CREAT | O_EXCL, 0644);
+	if (out_fd < 0) {
+		ALOGE("installd cannot open '%s' for output during makeodex\n", out_path);
+		goto fail;
+	}
+	if (fchmod(out_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) {
+		ALOGE("installd cannot chmod '%s' during makeodex\n", out_path);
+		goto fail;
+	}
+	if (fchown(out_fd, AID_SYSTEM, AID_SYSTEM) < 0) {
+		ALOGE("installd cannot chown '%s' during makeodex\n", out_path);
+		goto fail;
+	}
+
+
+	// Create a swap file if necessary.
+	if (ShouldUseSwapFileForDexopt()) {
+		// Make sure there really is enough space.
+		size_t out_len = strlen(out_path);
+		if (out_len + strlen(".swap") + 1 <= PKG_PATH_MAX) {
+			strcpy(swap_file_name, out_path);
+			strcpy(swap_file_name + strlen(out_path), ".swap");
+			unlink(swap_file_name);
+			swap_fd = open(swap_file_name, O_RDWR | O_CREAT | O_EXCL, 0600);
+			if (swap_fd < 0) {
+				// Could not create swap file. Optimistically go on and hope that we can compile
+				// without it.
+				ALOGE("installd could not create '%s' for swap during makeodex\n", swap_file_name);
+			} else {
+				// Immediately unlink. We don't really want to hit flash.
+				unlink(swap_file_name);
+			}
+		} else {
+			// Swap file path is too long. Try to run without.
+			ALOGE("installd could not create swap file for path %s during dexopt\n", out_path);
+		}
+	}
+
+	ALOGV("DexInv: --- BEGIN '%s' ---\n", dex_path);
+
+	pid_t pid;
+	pid = fork();
+	if (pid == 0) {
+		if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) {
+			ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno));
+			exit(67);
+		}
+
+		const char *input_file_name = strrchr(dex_path, '/');
+		if (input_file_name == NULL) {
+			input_file_name = dex_path;
+		} else {
+			input_file_name++;
+		}
+		run_dex2oat2(dex_path, out_fd, input_file_name, out_path, swap_fd, pkgname,
+					"arm64", false);
+
+		exit(68);   /* only get here on exec failure */
+	} else {
+		res = wait_child(pid);
+		if (res == 0) {
+			ALOGV("DexInv: --- END '%s' (success) ---\n", dex_path);
+		} else {
+			ALOGE("DexInv: --- END '%s' --- status=0x%04x, process failed\n", dex_path, res);
+			goto fail;
+		}
+	}
+
+	ut.actime = dex_stat.st_atime;
+	ut.modtime = dex_stat.st_mtime;
+	utime(out_path, &ut);
+
+	close(out_fd);
+	close(input_fd);
+	if (swap_fd != -1) {
+		close(swap_fd);
+	}
+	return 0;
+
+fail:
+	if (out_fd >= 0) {
+		close(out_fd);
+		unlink(out_path);
+	}
+	if (input_fd >= 0) {
+		close(input_fd);
+	}
+	return -1;
+
+}
+//ADDED FOR SAMD
+static void run_aapt_package_with_assets(const char *res_path, const char *assets_path, const char *manifest_path, const char *output_apk)
+{
+    static const char *AAPT_BIN = "/system/bin/aapt";
+    static const char *MANIFEST = manifest_path;
+    static const char *FRAMEWORK_RES = "/system/framework/framework-res.apk";
+
+    ALOGD("run_aapt(package) res_path=%s assets_path=%s manifest_path=%s output_apk=%s",
+                res_path, assets_path, manifest_path, output_apk);
+
+    execl(AAPT_BIN, AAPT_BIN, "package",
+					  "-M", MANIFEST,
+					  "-S", res_path,
+					  "-A", assets_path,
+					  "-I", FRAMEWORK_RES,
+					  "-F", output_apk,
+					  "-f",
+					  (char*)NULL);
+
+    ALOGE("run_aapt(package) execl(%s) failed: %s\n", AAPT_BIN, strerror(errno));
+
+    /*unlink(output_apk);
+	int apk_fd = open(output_apk, O_RDWR | O_CREAT | O_EXCL, 0660);
+	if (apk_fd < 0) {
+		ALOGE("aapt cannot open '%s' for output: %s\n", output_apk, strerror(errno));
+	}
+	if (fchown(apk_fd, AID_SYSTEM, AID_SYSTEM) < 0) {
+		ALOGE("aapt cannot chown '%s'\n", output_apk);
+	}
+	if (fchmod(apk_fd, 0755) < 0) {
+		ALOGE("aapt cannot fchmod '%s'\n", output_apk);
+	}
+
+	close(apk_fd);*/
+
+    execl("/system/bin/chmod", "/system/bin/chmod", "666", output_apk, (char*)NULL);
+
+    ALOGE("run_aapt(package) execl(%s) failed: %s\n", "/system/bin/chmod", strerror(errno));
+}
+
+static void run_aapt_package(const char *res_path, const char *manifest_path, const char *output_apk)
+{
+    static const char *AAPT_BIN = "/system/bin/aapt";
+    static const char *MANIFEST = manifest_path;
+    static const char *FRAMEWORK_RES = "/system/framework/framework-res.apk";
+
+    ALOGD("run_aapt(package) res_path=%s manifest_path=%s output_apk=%s",
+                res_path, manifest_path, output_apk);
+
+    execl(AAPT_BIN, AAPT_BIN, "package",
+					  "-M", MANIFEST,
+					  "-S", res_path,
+					  "-I", FRAMEWORK_RES,
+					  "-F", output_apk,
+					  "-f",
+					  (char*)NULL);
+
+    ALOGE("run_aapt(package) execl(%s) failed: %s\n", AAPT_BIN, strerror(errno));
+
+    /*unlink(output_apk);
+	int apk_fd = open(output_apk, O_RDWR | O_CREAT | O_EXCL, 0660);
+	if (apk_fd < 0) {
+		ALOGE("aapt cannot open '%s' for output: %s\n", output_apk, strerror(errno));
+	}
+	if (fchown(apk_fd, AID_SYSTEM, AID_SYSTEM) < 0) {
+		ALOGE("aapt cannot chown '%s'\n", output_apk);
+	}
+	if (fchmod(apk_fd, 0755) < 0) {
+		ALOGE("aapt cannot fchmod '%s'\n", output_apk);
+	}
+
+	close(apk_fd);*/
+
+    execl("/system/bin/chmod", "/system/bin/chmod", "666", output_apk, (char*)NULL);
+
+    ALOGE("run_aapt(package) execl(%s) failed: %s\n", "/system/bin/chmod", strerror(errno));
+}
+
+static void run_aapt_add(int type, const char *apk_path, const char *file_path) // 1:add 2:remove
+{
+    static const char *AAPT_BIN = "/system/bin/aapt";
+
+    ALOGD("run_aapt(add) type=%d apk_path=%s file_path=%s", type, apk_path, file_path);
+
+    if(type == 1)
+    {
+		execl(AAPT_BIN, AAPT_BIN, "add",
+							"-v", "-k",
+							apk_path,
+							file_path,
+							(char*)NULL);
+
+		ALOGE("run_aapt(add) execl(%s) add failed: %s\n", AAPT_BIN, strerror(errno));
+    }
+    else if(type == 2)
+    {
+        execl(AAPT_BIN, AAPT_BIN, "remove",
+        						"-v",
+            					apk_path,
+            					file_path,
+            					(char*)NULL);
+
+        ALOGE("run_aapt(add) execl(%s) remove failed: %s\n", AAPT_BIN, strerror(errno));
+    }else{
+        execl(AAPT_BIN, AAPT_BIN, "add",
+        							"-v",
+        							apk_path,
+        							file_path,
+        							(char*)NULL);
+
+        		ALOGE("run_aapt(add) execl(%s) add failed: %s\n", AAPT_BIN, strerror(errno));
+    }
+
+    /*unlink(output_apk);
+	int apk_fd = open(output_apk, O_RDWR | O_CREAT | O_EXCL, 0660);
+	if (apk_fd < 0) {
+		ALOGE("aapt cannot open '%s' for output: %s\n", output_apk, strerror(errno));
+	}
+	if (fchown(apk_fd, AID_SYSTEM, AID_SYSTEM) < 0) {
+		ALOGE("aapt cannot chown '%s'\n", output_apk);
+	}
+	if (fchmod(apk_fd, 0755) < 0) {
+		ALOGE("aapt cannot fchmod '%s'\n", output_apk);
+	}
+
+	close(apk_fd);*/
+
+    /*execl("/system/bin/chmod", "/system/bin/chmod", "666", output_apk, (char*)NULL);
+
+    ALOGE("3execl(%s) failed: %s\n", "/system/bin/chmod", strerror(errno));*/
+}
+//ADDED FOR SAMD
+int aapt_package_with_assets(const char *res_path, const char *assets_path, const char *manifest_path, const char *output_apk)
+{
+    ALOGD("aapt(package) res_path=%s assets_path=%s manifest_path=%s output_apk=%s",
+            res_path, assets_path, manifest_path, output_apk);
+
+    int apk_fd = -1;
+
+    static const int PARENT_READ_PIPE = 0;
+    static const int CHILD_WRITE_PIPE = 1;
+
+    // create pipes for redirecting STDERR to a buffer that can be displayed in logcat
+    int pipefd[2];
+    if (pipe(pipefd) != 0) {
+        pipefd[0] = pipefd[1] = -1;
+    }
+
+    pid_t pid = fork();
+
+    if (pid == 0) {
+
+    	run_aapt_package_with_assets(res_path, assets_path, manifest_path, output_apk);
+
+    	if (pipefd[CHILD_WRITE_PIPE] > 0) {
+            close(pipefd[CHILD_WRITE_PIPE]);
+        }
+        exit(1); /* only if exec call to idmap failed */
+    } else {
+        int status, i;
+        char buffer[1024];
+        ssize_t readlen;
+
+        if (pipefd[CHILD_WRITE_PIPE] > 0) {
+            close(pipefd[CHILD_WRITE_PIPE]); // close unused write end
+        }
+
+        if (pipefd[PARENT_READ_PIPE] > 0) {
+            while ((readlen = read(pipefd[PARENT_READ_PIPE], buffer, sizeof(buffer) - 1)) > 0) {
+                // in case buffer has more than one string in it, replace '\0' with '\n'
+                for (i = 0; i < readlen; i++) {
+                    if (buffer[i] == '\0') buffer[i] = '\n';
+                }
+                // null terminate buffer at readlen
+                buffer[readlen] = '\0';
+                ALOG(LOG_ERROR, "InstallTheme", "%s", buffer);
+            }
+            waitpid(pid, &status, 0);
+
+            if (pipefd[PARENT_READ_PIPE] > 0) {
+                close(pipefd[PARENT_READ_PIPE]);
+            }
+        } else {
+            status = wait_child(pid);
+        }
+
+        if (status != 0) {
+            ALOGE("aapt(package) failed, status=0x%04x\n", status);
+            goto fail;
+        }
+    }
+
+	apk_fd = open(output_apk, O_RDWR);
+	if (apk_fd < 0) {
+		ALOGE("aapt(package) cannot open '%s' for output: %s\n", output_apk, strerror(errno));
+		goto fail;
+	}
+	if (fchown(apk_fd, AID_SYSTEM, AID_SYSTEM) < 0) {
+		ALOGE("aapt(package) cannot chown '%s'\n", output_apk);
+		goto fail;
+	}
+	if (fchmod(apk_fd, 0666) < 0) {
+		ALOGE("aapt(package) cannot fchmod '%s'\n", output_apk);
+		goto fail;
+	}
+
+	close(apk_fd);
+
+    return 0;
+fail:
+	if (apk_fd >= 0) {
+        close(apk_fd);
+        unlink(output_apk);
+    }
+    return -1;
+}
+
+int aapt_package(const char *res_path, const char *manifest_path, const char *output_apk)
+{
+    ALOGD("aapt(package) res_path=%s manifest_path=%s output_apk=%s",
+            res_path, manifest_path, output_apk);
+
+    int apk_fd = -1;
+
+    static const int PARENT_READ_PIPE = 0;
+    static const int CHILD_WRITE_PIPE = 1;
+
+    // create pipes for redirecting STDERR to a buffer that can be displayed in logcat
+    int pipefd[2];
+    if (pipe(pipefd) != 0) {
+        pipefd[0] = pipefd[1] = -1;
+    }
+
+    pid_t pid = fork();
+
+    if (pid == 0) {
+
+    	run_aapt_package(res_path, manifest_path, output_apk);
+
+    	if (pipefd[CHILD_WRITE_PIPE] > 0) {
+            close(pipefd[CHILD_WRITE_PIPE]);
+        }
+        exit(1); /* only if exec call to idmap failed */
+    } else {
+        int status, i;
+        char buffer[1024];
+        ssize_t readlen;
+
+        if (pipefd[CHILD_WRITE_PIPE] > 0) {
+            close(pipefd[CHILD_WRITE_PIPE]); // close unused write end
+        }
+
+        if (pipefd[PARENT_READ_PIPE] > 0) {
+            while ((readlen = read(pipefd[PARENT_READ_PIPE], buffer, sizeof(buffer) - 1)) > 0) {
+                // in case buffer has more than one string in it, replace '\0' with '\n'
+                for (i = 0; i < readlen; i++) {
+                    if (buffer[i] == '\0') buffer[i] = '\n';
+                }
+                // null terminate buffer at readlen
+                buffer[readlen] = '\0';
+                ALOG(LOG_ERROR, "InstallTheme", "%s", buffer);
+            }
+            waitpid(pid, &status, 0);
+
+            if (pipefd[PARENT_READ_PIPE] > 0) {
+                close(pipefd[PARENT_READ_PIPE]);
+            }
+        } else {
+            status = wait_child(pid);
+        }
+
+        if (status != 0) {
+            ALOGE("aapt(package) failed, status=0x%04x\n", status);
+            goto fail;
+        }
+    }
+
+	apk_fd = open(output_apk, O_RDWR);
+	if (apk_fd < 0) {
+		ALOGE("aapt(package) cannot open '%s' for output: %s\n", output_apk, strerror(errno));
+		goto fail;
+	}
+	if (fchown(apk_fd, AID_SYSTEM, AID_SYSTEM) < 0) {
+		ALOGE("aapt(package) cannot chown '%s'\n", output_apk);
+		goto fail;
+	}
+	if (fchmod(apk_fd, 0666) < 0) {
+		ALOGE("aapt(package) cannot fchmod '%s'\n", output_apk);
+		goto fail;
+	}
+
+	close(apk_fd);
+
+    return 0;
+fail:
+	if (apk_fd >= 0) {
+        close(apk_fd);
+        unlink(output_apk);
+    }
+    return -1;
+}
+
+int aapt_add(int type, const char *apk_path, const char *file_path) // type - 1:add 2:remove
+{
+    ALOGD("aapt(add) apk_path=%s file_path=%s", apk_path, file_path);
+
+    int apk_fd = -1;
+
+    static const int PARENT_READ_PIPE = 0;
+    static const int CHILD_WRITE_PIPE = 1;
+
+    // create pipes for redirecting STDERR to a buffer that can be displayed in logcat
+    int pipefd[2];
+    if (pipe(pipefd) != 0) {
+        pipefd[0] = pipefd[1] = -1;
+    }
+
+    pid_t pid = fork();
+
+    if (pid == 0) {
+    	//unlink(apk_path);
+    	apk_fd = open(apk_path, O_RDWR);
+		if (apk_fd < 0) {
+			ALOGE("aapt(add) cannot open '%s' for output: %s\n", apk_path, strerror(errno));
+			goto fail;
+		}
+		if (fchown(apk_fd, AID_SYSTEM, AID_SYSTEM) < 0) {
+			ALOGE("aapt(add) cannot chown '%s'\n", apk_path);
+			goto fail;
+		}
+		if (fchmod(apk_fd, 0666) < 0) {
+			ALOGE("aapt(add) cannot fchmod '%s'\n", apk_path);
+			goto fail;
+		}
+
+    	run_aapt_add(type, apk_path, file_path);
+
+    	close(apk_fd);
+
+    	if (pipefd[CHILD_WRITE_PIPE] > 0) {
+            close(pipefd[CHILD_WRITE_PIPE]);
+        }
+        exit(1); /* only if exec call to idmap failed */
+    } else {
+        int status, i;
+        char buffer[1024];
+        ssize_t readlen;
+
+        if (pipefd[CHILD_WRITE_PIPE] > 0) {
+            close(pipefd[CHILD_WRITE_PIPE]); // close unused write end
+        }
+
+        if (pipefd[PARENT_READ_PIPE] > 0) {
+            while ((readlen = read(pipefd[PARENT_READ_PIPE], buffer, sizeof(buffer) - 1)) > 0) {
+                // in case buffer has more than one string in it, replace '\0' with '\n'
+                for (i = 0; i < readlen; i++) {
+                    if (buffer[i] == '\0') buffer[i] = '\n';
+                }
+                // null terminate buffer at readlen
+                buffer[readlen] = '\0';
+                ALOG(LOG_ERROR, "InstallTheme", "%s", buffer);
+            }
+            waitpid(pid, &status, 0);
+
+            if (pipefd[PARENT_READ_PIPE] > 0) {
+                close(pipefd[PARENT_READ_PIPE]);
+            }
+        } else {
+            status = wait_child(pid);
+        }
+
+        if (status != 0) {
+            ALOGE("aapt(add) failed, status=0x%04x\n", status);
+            goto fail;
+        }
+    }
+
+    return 0;
+fail:
+	if (apk_fd >= 0) {
+        close(apk_fd);
+        unlink(apk_path);
+    }
+    return -1;
+}
+// ADDED FOR COLLABOROID
+
 int restorecon_data(const char* uuid, const char* pkgName,
                     const char* seinfo, uid_t uid)
 {
diff -urN Android_6.0.1_r11/frameworks/native/cmds/installd/installd.cpp SAMD_6.0.1_r11_20170930/frameworks/native/cmds/installd/installd.cpp
--- Android_6.0.1_r11/frameworks/native/cmds/installd/installd.cpp	2017-09-27 02:07:59.631735973 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/cmds/installd/installd.cpp	2017-08-05 15:02:30.796988000 +0900
@@ -63,6 +63,12 @@
     return move_dex(arg[0], arg[1], arg[2]); /* src, dst, instruction_set */
 }
 
+// ADDED FOR COLLABOROID
+static int do_move_file(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return move_file(arg[0], arg[1]); /* src, dst */
+}
+
 static int do_rm_dex(char **arg, char reply[REPLY_MAX] __unused)
 {
     return rm_dex(arg[0], arg[1]); /* pkgname, instruction_set */
@@ -161,6 +167,27 @@
     return idmap(arg[0], arg[1], atoi(arg[2]));
 }
 
+static int do_make_odex(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return makeodex(arg[0], arg[1], arg[2]);
+}
+
+//AADED FOR SAMD
+static int do_aapt_package_with_assets(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return aapt_package_with_assets(arg[0], arg[1], arg[2], arg[3]);
+}
+
+static int do_aapt_package(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return aapt_package(arg[0], arg[1], arg[2]);
+}
+
+static int do_aapt_add(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return aapt_add(atoi(arg[0]), arg[1], arg[2]);
+}
+
 static int do_restorecon_data(char **arg, char reply[REPLY_MAX] __attribute__((unused)))
 {
     return restorecon_data(parse_null(arg[0]), arg[1], arg[2], atoi(arg[3]));
@@ -197,6 +224,7 @@
     { "dexopt",               10, do_dexopt },
     { "markbootcomplete",     1, do_mark_boot_complete },
     { "movedex",              3, do_move_dex },
+    { "movefile",             2, do_move_file },
     { "rmdex",                2, do_rm_dex },
     { "remove",               3, do_remove },
     { "rename",               2, do_rename },
@@ -213,6 +241,10 @@
     { "mkuserconfig",         1, do_mk_user_config },
     { "rmuser",               2, do_rm_user },
     { "idmap",                3, do_idmap },
+    { "makeodex",             3, do_make_odex },
+    { "aaptpackage",          3, do_aapt_package },
+    { "aaptadd",              3, do_aapt_add },
+    { "aaptpackagewithassets",4, do_aapt_package_with_assets },
     { "restorecondata",       4, do_restorecon_data },
     { "createoatdir",         2, do_create_oat_dir },
     { "rmpackagedir",         1, do_rm_package_dir },
diff -urN Android_6.0.1_r11/frameworks/native/cmds/installd/installd.h SAMD_6.0.1_r11_20170930/frameworks/native/cmds/installd/installd.h
--- Android_6.0.1_r11/frameworks/native/cmds/installd/installd.h	2017-09-27 02:07:59.631735973 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/cmds/installd/installd.h	2017-08-05 16:13:36.619993000 +0900
@@ -233,6 +233,7 @@
 int delete_cache(const char *uuid, const char *pkgname, userid_t userid);
 int delete_code_cache(const char *uuid, const char *pkgname, userid_t userid);
 int move_dex(const char *src, const char *dst, const char *instruction_set);
+int move_file(const char *src, const char *dst);
 int rm_dex(const char *path, const char *instruction_set);
 int protect(char *pkgname, gid_t gid);
 int get_size(const char *uuid, const char *pkgname, int userid,
@@ -248,6 +249,13 @@
 int movefiles();
 int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId);
 int idmap(const char *target_path, const char *overlay_path, uid_t uid);
+// ADDED FOR COLLABOROID
+int makeodex(const char *dex_path, const char *out_path, const char *pkgname);
+int aapt_package(const char* res_path, const char* manifest_path, const char* output_apk);
+int aapt_add(int type, const char* apk_path, const char* file_path);
+// ADDED FOR SAMD
+int aapt_package_with_assets(const char* res_path, const char* assets_path , const char* manifest_path, const char* output_apk);
+// ADDED FOR COLLABOROID
 int restorecon_data(const char *uuid, const char* pkgName, const char* seinfo, uid_t uid);
 int create_oat_dir(const char* oat_dir, const char *instruction_set);
 int rm_package_dir(const char* apk_path);
Binary files Android_6.0.1_r11/frameworks/native/.git/index and SAMD_6.0.1_r11_20170930/frameworks/native/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/native/opengl/libs/GLES_trace/.gitignore SAMD_6.0.1_r11_20170930/frameworks/native/opengl/libs/GLES_trace/.gitignore
--- Android_6.0.1_r11/frameworks/native/opengl/libs/GLES_trace/.gitignore	2017-09-27 02:07:59.667735972 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/libs/GLES_trace/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,4 +0,0 @@
-java
-*.pyc
-*.swp
-pyratemp.py
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tests/testPauseResume/src/com/android/test/TestActivity.java SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testPauseResume/src/com/android/test/TestActivity.java
--- Android_6.0.1_r11/frameworks/native/opengl/tests/testPauseResume/src/com/android/test/TestActivity.java	2017-09-27 02:07:59.683735972 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testPauseResume/src/com/android/test/TestActivity.java	1970-01-01 09:00:00.000000000 +0900
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * 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.android.test;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-
-public class TestActivity extends Activity {
-    private final static String TAG = "TestActivity";
-    TestView mView;
-    boolean mToggle;
-    int mCount;
-    final static int PAUSE_DELAY = 100;
-    Runnable mRunnable = new Runnable() {
-        public void run() {
-        if (mToggle) {
-            Log.w(TAG, "****** step " + mCount + " resume");
-            mCount++;
-            mView.onResume();
-        } else {
-            Log.w(TAG, "step " + mCount + " pause");
-            mView.onPause();
-        }
-        mToggle = ! mToggle;
-        mView.postDelayed(mRunnable, PAUSE_DELAY);
-        }
-    };
-
-    @Override
-    protected void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        mView = new TestView(getApplication());
-	    mView.setFocusableInTouchMode(true);
-	    setContentView(mView);
-        mView.postDelayed(mRunnable, PAUSE_DELAY);
-    }
-
-    @Override
-    protected void onPause() {
-        super.onPause();
-        mView.onPause();
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        mView.onResume();
-    }
-}
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tests/testPauseResume/src/sbj/android/test/TestActivity.java SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testPauseResume/src/sbj/android/test/TestActivity.java
--- Android_6.0.1_r11/frameworks/native/opengl/tests/testPauseResume/src/sbj/android/test/TestActivity.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testPauseResume/src/sbj/android/test/TestActivity.java	2017-01-29 02:51:15.625845000 +0900
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * 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.android.test.*
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+
+public class TestActivity extends Activity {
+    private final static String TAG = "TestActivity";
+    TestView mView;
+    boolean mToggle;
+    int mCount;
+    final static int PAUSE_DELAY = 100;
+    Runnable mRunnable = new Runnable() {
+        public void run() {
+        if (mToggle) {
+            Log.w(TAG, "****** step " + mCount + " resume");
+            mCount++;
+            mView.onResume();
+        } else {
+            Log.w(TAG, "step " + mCount + " pause");
+            mView.onPause();
+        }
+        mToggle = ! mToggle;
+        mView.postDelayed(mRunnable, PAUSE_DELAY);
+        }
+    };
+
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        mView = new TestView(getApplication());
+	    mView.setFocusableInTouchMode(true);
+	    setContentView(mView);
+        mView.postDelayed(mRunnable, PAUSE_DELAY);
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        mView.onPause();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mView.onResume();
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestActivity.java SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestActivity.java
--- Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestActivity.java	2017-09-27 02:07:59.683735972 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestActivity.java	1970-01-01 09:00:00.000000000 +0900
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * 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.android.test;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-
-public class TestActivity extends Activity {
-    private final static String TAG = "TestActivity";
-    TestView mView;
-
-    @Override
-    protected void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        mView = new TestView(getApplication());
-	    mView.setFocusableInTouchMode(true);
-	    setContentView(mView);
-    }
-
-    @Override
-    protected void onPause() {
-        super.onPause();
-        mView.onPause();
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        mView.onResume();
-    }
-}
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestView.java SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestView.java
--- Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestView.java	2017-09-27 02:07:59.683735972 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/com/android/test/TestView.java	1970-01-01 09:00:00.000000000 +0900
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * 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.android.test;
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.CharBuffer;
-import java.nio.FloatBuffer;
-
-import android.content.Context;
-import android.opengl.GLSurfaceView;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL;
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-/**
- * An implementation of SurfaceView that uses the dedicated surface for
- * displaying an OpenGL animation.  This allows the animation to run in a
- * separate thread, without requiring that it be driven by the update mechanism
- * of the view hierarchy.
- *
- * The application-specific rendering code is delegated to a GLView.Renderer
- * instance.
- */
-class TestView extends GLSurfaceView {
-    TestView(Context context) {
-        super(context);
-        init();
-    }
-
-    public TestView(Context context, AttributeSet attrs) {
-        super(context, attrs);
-        init();
-    }
-
-    private void init() {
-        setRenderer(new Renderer());
-        setRenderMode(RENDERMODE_WHEN_DIRTY);
-    }
-    
-        /** A grid is a topologically rectangular array of vertices.
-    *
-    * The vertex and index data are held in VBO objects because on most
-    * GPUs VBO objects are the fastest way of rendering static vertex
-    * and index data.
-    *
-    */
-
-   private static class Grid {
-       // Size of vertex data elements in bytes:
-       final static int FLOAT_SIZE = 4;
-       final static int CHAR_SIZE = 2;
-
-       // Vertex structure:
-       // float x, y, z;
-
-       final static int VERTEX_SIZE = 3 * FLOAT_SIZE;
-
-       private int mVertexBufferObjectId;
-       private int mElementBufferObjectId;
-
-       // These buffers are used to hold the vertex and index data while
-       // constructing the grid. Once createBufferObjects() is called
-       // the buffers are nulled out to save memory.
-
-       private ByteBuffer mVertexByteBuffer;
-       private FloatBuffer mVertexBuffer;
-       private CharBuffer mIndexBuffer;
-
-       private int mW;
-       private int mH;
-       private int mIndexCount;
-
-       public Grid(int w, int h) {
-           if (w < 0 || w >= 65536) {
-               throw new IllegalArgumentException("w");
-           }
-           if (h < 0 || h >= 65536) {
-               throw new IllegalArgumentException("h");
-           }
-           if (w * h >= 65536) {
-               throw new IllegalArgumentException("w * h >= 65536");
-           }
-
-           mW = w;
-           mH = h;
-           int size = w * h;
-
-           mVertexByteBuffer = ByteBuffer.allocateDirect(VERTEX_SIZE * size)
-               .order(ByteOrder.nativeOrder());
-           mVertexBuffer = mVertexByteBuffer.asFloatBuffer();
-
-           int quadW = mW - 1;
-           int quadH = mH - 1;
-           int quadCount = quadW * quadH;
-           int indexCount = quadCount * 6;
-           mIndexCount = indexCount;
-           mIndexBuffer = ByteBuffer.allocateDirect(CHAR_SIZE * indexCount)
-               .order(ByteOrder.nativeOrder()).asCharBuffer();
-
-           /*
-            * Initialize triangle list mesh.
-            *
-            *     [0]-----[  1] ...
-            *      |    /   |
-            *      |   /    |
-            *      |  /     |
-            *     [w]-----[w+1] ...
-            *      |       |
-            *
-            */
-
-           {
-               int i = 0;
-               for (int y = 0; y < quadH; y++) {
-                   for (int x = 0; x < quadW; x++) {
-                       char a = (char) (y * mW + x);
-                       char b = (char) (y * mW + x + 1);
-                       char c = (char) ((y + 1) * mW + x);
-                       char d = (char) ((y + 1) * mW + x + 1);
-
-                       mIndexBuffer.put(i++, a);
-                       mIndexBuffer.put(i++, c);
-                       mIndexBuffer.put(i++, b);
-
-                       mIndexBuffer.put(i++, b);
-                       mIndexBuffer.put(i++, c);
-                       mIndexBuffer.put(i++, d);
-                   }
-               }
-           }
-
-       }
-
-       public void set(int i, int j, float x, float y, float z) {
-           if (i < 0 || i >= mW) {
-               throw new IllegalArgumentException("i");
-           }
-           if (j < 0 || j >= mH) {
-               throw new IllegalArgumentException("j");
-           }
-
-           int index = mW * j + i;
-
-           mVertexBuffer.position(index * VERTEX_SIZE / FLOAT_SIZE);
-           mVertexBuffer.put(x);
-           mVertexBuffer.put(y);
-           mVertexBuffer.put(z);
-       }
-
-       public void createBufferObjects(GL gl) {
-           // Generate a the vertex and element buffer IDs
-           int[] vboIds = new int[2];
-           GL11 gl11 = (GL11) gl;
-           gl11.glGenBuffers(2, vboIds, 0);
-           mVertexBufferObjectId = vboIds[0];
-           mElementBufferObjectId = vboIds[1];
-
-           // Upload the vertex data
-           gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertexBufferObjectId);
-           mVertexByteBuffer.position(0);
-           gl11.glBufferData(GL11.GL_ARRAY_BUFFER, mVertexByteBuffer.capacity(), mVertexByteBuffer, GL11.GL_STATIC_DRAW);
-
-           gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mElementBufferObjectId);
-           mIndexBuffer.position(0);
-           gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer.capacity() * CHAR_SIZE, mIndexBuffer, GL11.GL_STATIC_DRAW);
-
-           // We don't need the in-memory data any more
-           mVertexBuffer = null;
-           mVertexByteBuffer = null;
-           mIndexBuffer = null;
-       }
-
-       public void draw(GL10 gl) {
-           GL11 gl11 = (GL11) gl;
-
-           gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
-
-           gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertexBufferObjectId);
-           gl11.glVertexPointer(3, GL10.GL_FLOAT, VERTEX_SIZE, 0);
-           
-           gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mElementBufferObjectId);
-           gl11.glDrawElements(GL10.GL_TRIANGLES, mIndexCount, GL10.GL_UNSIGNED_SHORT, 0);
-           gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
-           gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
-           gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
-       }
-   }
-
-
-    private class Renderer implements GLSurfaceView.Renderer {
-        private static final String TAG = "Renderer";
-        private Grid mGrid;
-        
-        public void onDrawFrame(GL10 gl) {
-			gl.glClearColor(0,0,1,1);
-			gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
-            mGrid.draw(gl);
-        }
-
-        public void onSurfaceChanged(GL10 gl, int width, int height) {
-            gl.glViewport(0, 0, width, height);
-			gl.glMatrixMode(GL11.GL_PROJECTION);
-			gl.glLoadIdentity();
-			gl.glOrthof(0, width, height, 0, -1, 1);
-			gl.glMatrixMode(GL11.GL_MODELVIEW);
-            createGrid(gl, width, height);
-        }
-
-        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
-        }
-        
-        private void createGrid(GL10 gl, float w, float h) {
-        mGrid = new Grid(2, 2);
-			for (int j = 0; j < 2; j++) {
-				for (int i = 0; i < 2; i++) {
-					float x = w * i;
-					float y = h * j;
-					float z = 0.0f;
-					mGrid.set(i,j, x, y, z);
-				}
-			}
-			mGrid.createBufferObjects(gl);
-		}
-    }
-}
-
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestActivity.java SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestActivity.java
--- Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestActivity.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestActivity.java	2017-01-29 02:51:15.613845000 +0900
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * 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.android.test.*
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class TestActivity extends Activity {
+    private final static String TAG = "TestActivity";
+    TestView mView;
+
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        mView = new TestView(getApplication());
+	    mView.setFocusableInTouchMode(true);
+	    setContentView(mView);
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        mView.onPause();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mView.onResume();
+    }
+}
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestView.java SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestView.java
--- Android_6.0.1_r11/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestView.java	1970-01-01 09:00:00.000000000 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tests/testViewport/src/sbj/android/test/TestView.java	2017-01-29 02:51:15.617845000 +0900
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * 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.android.test.*
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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.
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.FloatBuffer;
+
+import android.content.Context;
+import android.opengl.GLSurfaceView;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+import javax.microedition.khronos.egl.EGL10;
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL;
+import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL11;
+/**
+ * An implementation of SurfaceView that uses the dedicated surface for
+ * displaying an OpenGL animation.  This allows the animation to run in a
+ * separate thread, without requiring that it be driven by the update mechanism
+ * of the view hierarchy.
+ *
+ * The application-specific rendering code is delegated to a GLView.Renderer
+ * instance.
+ */
+class TestView extends GLSurfaceView {
+    TestView(Context context) {
+        super(context);
+        init();
+    }
+
+    public TestView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        init();
+    }
+
+    private void init() {
+        setRenderer(new Renderer());
+        setRenderMode(RENDERMODE_WHEN_DIRTY);
+    }
+    
+        /** A grid is a topologically rectangular array of vertices.
+    *
+    * The vertex and index data are held in VBO objects because on most
+    * GPUs VBO objects are the fastest way of rendering static vertex
+    * and index data.
+    *
+    */
+
+   private static class Grid {
+       // Size of vertex data elements in bytes:
+       final static int FLOAT_SIZE = 4;
+       final static int CHAR_SIZE = 2;
+
+       // Vertex structure:
+       // float x, y, z;
+
+       final static int VERTEX_SIZE = 3 * FLOAT_SIZE;
+
+       private int mVertexBufferObjectId;
+       private int mElementBufferObjectId;
+
+       // These buffers are used to hold the vertex and index data while
+       // constructing the grid. Once createBufferObjects() is called
+       // the buffers are nulled out to save memory.
+
+       private ByteBuffer mVertexByteBuffer;
+       private FloatBuffer mVertexBuffer;
+       private CharBuffer mIndexBuffer;
+
+       private int mW;
+       private int mH;
+       private int mIndexCount;
+
+       public Grid(int w, int h) {
+           if (w < 0 || w >= 65536) {
+               throw new IllegalArgumentException("w");
+           }
+           if (h < 0 || h >= 65536) {
+               throw new IllegalArgumentException("h");
+           }
+           if (w * h >= 65536) {
+               throw new IllegalArgumentException("w * h >= 65536");
+           }
+
+           mW = w;
+           mH = h;
+           int size = w * h;
+
+           mVertexByteBuffer = ByteBuffer.allocateDirect(VERTEX_SIZE * size)
+               .order(ByteOrder.nativeOrder());
+           mVertexBuffer = mVertexByteBuffer.asFloatBuffer();
+
+           int quadW = mW - 1;
+           int quadH = mH - 1;
+           int quadCount = quadW * quadH;
+           int indexCount = quadCount * 6;
+           mIndexCount = indexCount;
+           mIndexBuffer = ByteBuffer.allocateDirect(CHAR_SIZE * indexCount)
+               .order(ByteOrder.nativeOrder()).asCharBuffer();
+
+           /*
+            * Initialize triangle list mesh.
+            *
+            *     [0]-----[  1] ...
+            *      |    /   |
+            *      |   /    |
+            *      |  /     |
+            *     [w]-----[w+1] ...
+            *      |       |
+            *
+            */
+
+           {
+               int i = 0;
+               for (int y = 0; y < quadH; y++) {
+                   for (int x = 0; x < quadW; x++) {
+                       char a = (char) (y * mW + x);
+                       char b = (char) (y * mW + x + 1);
+                       char c = (char) ((y + 1) * mW + x);
+                       char d = (char) ((y + 1) * mW + x + 1);
+
+                       mIndexBuffer.put(i++, a);
+                       mIndexBuffer.put(i++, c);
+                       mIndexBuffer.put(i++, b);
+
+                       mIndexBuffer.put(i++, b);
+                       mIndexBuffer.put(i++, c);
+                       mIndexBuffer.put(i++, d);
+                   }
+               }
+           }
+
+       }
+
+       public void set(int i, int j, float x, float y, float z) {
+           if (i < 0 || i >= mW) {
+               throw new IllegalArgumentException("i");
+           }
+           if (j < 0 || j >= mH) {
+               throw new IllegalArgumentException("j");
+           }
+
+           int index = mW * j + i;
+
+           mVertexBuffer.position(index * VERTEX_SIZE / FLOAT_SIZE);
+           mVertexBuffer.put(x);
+           mVertexBuffer.put(y);
+           mVertexBuffer.put(z);
+       }
+
+       public void createBufferObjects(GL gl) {
+           // Generate a the vertex and element buffer IDs
+           int[] vboIds = new int[2];
+           GL11 gl11 = (GL11) gl;
+           gl11.glGenBuffers(2, vboIds, 0);
+           mVertexBufferObjectId = vboIds[0];
+           mElementBufferObjectId = vboIds[1];
+
+           // Upload the vertex data
+           gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertexBufferObjectId);
+           mVertexByteBuffer.position(0);
+           gl11.glBufferData(GL11.GL_ARRAY_BUFFER, mVertexByteBuffer.capacity(), mVertexByteBuffer, GL11.GL_STATIC_DRAW);
+
+           gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mElementBufferObjectId);
+           mIndexBuffer.position(0);
+           gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer.capacity() * CHAR_SIZE, mIndexBuffer, GL11.GL_STATIC_DRAW);
+
+           // We don't need the in-memory data any more
+           mVertexBuffer = null;
+           mVertexByteBuffer = null;
+           mIndexBuffer = null;
+       }
+
+       public void draw(GL10 gl) {
+           GL11 gl11 = (GL11) gl;
+
+           gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
+
+           gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertexBufferObjectId);
+           gl11.glVertexPointer(3, GL10.GL_FLOAT, VERTEX_SIZE, 0);
+           
+           gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mElementBufferObjectId);
+           gl11.glDrawElements(GL10.GL_TRIANGLES, mIndexCount, GL10.GL_UNSIGNED_SHORT, 0);
+           gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
+           gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
+           gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
+       }
+   }
+
+
+    private class Renderer implements GLSurfaceView.Renderer {
+        private static final String TAG = "Renderer";
+        private Grid mGrid;
+        
+        public void onDrawFrame(GL10 gl) {
+			gl.glClearColor(0,0,1,1);
+			gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+            mGrid.draw(gl);
+        }
+
+        public void onSurfaceChanged(GL10 gl, int width, int height) {
+            gl.glViewport(0, 0, width, height);
+			gl.glMatrixMode(GL11.GL_PROJECTION);
+			gl.glLoadIdentity();
+			gl.glOrthof(0, width, height, 0, -1, 1);
+			gl.glMatrixMode(GL11.GL_MODELVIEW);
+            createGrid(gl, width, height);
+        }
+
+        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
+        }
+        
+        private void createGrid(GL10 gl, float w, float h) {
+        mGrid = new Grid(2, 2);
+			for (int j = 0; j < 2; j++) {
+				for (int i = 0; i < 2; i++) {
+					float x = w * i;
+					float y = h * j;
+					float z = 0.0f;
+					mGrid.set(i,j, x, y, z);
+				}
+			}
+			mGrid.createBufferObjects(gl);
+		}
+    }
+}
+
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tools/glgen/.gitignore SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tools/glgen/.gitignore
--- Android_6.0.1_r11/frameworks/native/opengl/tools/glgen/.gitignore	2017-09-27 02:07:59.683735972 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tools/glgen/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-generated
-out
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tools/glgen/src/.gitignore SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tools/glgen/src/.gitignore
--- Android_6.0.1_r11/frameworks/native/opengl/tools/glgen/src/.gitignore	2017-09-27 02:07:59.683735972 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tools/glgen/src/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-*.class
diff -urN Android_6.0.1_r11/frameworks/native/opengl/tools/glgen2/.gitignore SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tools/glgen2/.gitignore
--- Android_6.0.1_r11/frameworks/native/opengl/tools/glgen2/.gitignore	2017-09-27 02:07:59.687735972 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/native/opengl/tools/glgen2/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-registry/reg.pyc
Binary files Android_6.0.1_r11/frameworks/opt/bitmap/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/bitmap/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/bluetooth/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/bluetooth/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/calendar/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/calendar/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/opt/calendar/.gitignore SAMD_6.0.1_r11_20170930/frameworks/opt/calendar/.gitignore
--- Android_6.0.1_r11/frameworks/opt/calendar/.gitignore	2017-09-27 02:07:59.931735969 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/opt/calendar/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-bin/
-gen/
Binary files Android_6.0.1_r11/frameworks/opt/carddav/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/carddav/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/chips/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/chips/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/colorpicker/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/colorpicker/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/opt/colorpicker/.gitignore SAMD_6.0.1_r11_20170930/frameworks/opt/colorpicker/.gitignore
--- Android_6.0.1_r11/frameworks/opt/colorpicker/.gitignore	2017-09-27 02:08:00.103735967 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/opt/colorpicker/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-bin/
-gen/
Binary files Android_6.0.1_r11/frameworks/opt/datetimepicker/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/datetimepicker/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/opt/datetimepicker/.gitignore SAMD_6.0.1_r11_20170930/frameworks/opt/datetimepicker/.gitignore
--- Android_6.0.1_r11/frameworks/opt/datetimepicker/.gitignore	2017-09-27 02:08:00.151735966 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/opt/datetimepicker/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-bin/
-gen/
Binary files Android_6.0.1_r11/frameworks/opt/emoji/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/emoji/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/inputconnectioncommon/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/inputconnectioncommon/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/inputmethodcommon/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/inputmethodcommon/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/net/ethernet/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/net/ethernet/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/net/ims/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/net/ims/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/net/voip/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/net/voip/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/net/wifi/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/net/wifi/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/photoviewer/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/photoviewer/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/opt/photoviewer/.gitignore SAMD_6.0.1_r11_20170930/frameworks/opt/photoviewer/.gitignore
--- Android_6.0.1_r11/frameworks/opt/photoviewer/.gitignore	2017-09-27 02:08:00.631735960 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/opt/photoviewer/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,7 +0,0 @@
-*~
-*.bak
-*.class
-bin/
-gen/
-.classpath
-.project
Binary files Android_6.0.1_r11/frameworks/opt/setupwizard/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/setupwizard/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/opt/setupwizard/.gitignore SAMD_6.0.1_r11_20170930/frameworks/opt/setupwizard/.gitignore
--- Android_6.0.1_r11/frameworks/opt/setupwizard/.gitignore	2017-09-27 02:08:00.759735958 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/opt/setupwizard/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,10 +0,0 @@
-*~
-*.bak
-*.class
-bin/
-local.properties
-*.project
-*.cproject
-*.settings
-*.pyc
-.gradle
Binary files Android_6.0.1_r11/frameworks/opt/telephony/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/telephony/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/timezonepicker/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/timezonepicker/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/opt/timezonepicker/.gitignore SAMD_6.0.1_r11_20170930/frameworks/opt/timezonepicker/.gitignore
--- Android_6.0.1_r11/frameworks/opt/timezonepicker/.gitignore	2017-09-27 02:08:01.023735955 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/opt/timezonepicker/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-bin/
-gen/
Binary files Android_6.0.1_r11/frameworks/opt/vcard/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/vcard/.git/index differ
Binary files Android_6.0.1_r11/frameworks/opt/widget/.git/index and SAMD_6.0.1_r11_20170930/frameworks/opt/widget/.git/index differ
Binary files Android_6.0.1_r11/frameworks/rs/.git/index and SAMD_6.0.1_r11_20170930/frameworks/rs/.git/index differ
Binary files Android_6.0.1_r11/frameworks/support/.git/index and SAMD_6.0.1_r11_20170930/frameworks/support/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/support/.gitignore SAMD_6.0.1_r11_20170930/frameworks/support/.gitignore
--- Android_6.0.1_r11/frameworks/support/.gitignore	2017-09-27 02:08:01.503735949 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/support/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,8 +0,0 @@
-.classpath
-.gradle
-.idea/
-.project
-.settings/
-project.properties
-**/bin
-**/gen
diff -urN Android_6.0.1_r11/frameworks/support/v17/leanback/.gitignore SAMD_6.0.1_r11_20170930/frameworks/support/v17/leanback/.gitignore
--- Android_6.0.1_r11/frameworks/support/v17/leanback/.gitignore	2017-09-27 02:08:01.547735948 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/support/v17/leanback/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,4 +0,0 @@
-.settings
-bin
-libs
-gen
diff -urN Android_6.0.1_r11/frameworks/support/v7/appcompat/.gitignore SAMD_6.0.1_r11_20170930/frameworks/support/v7/appcompat/.gitignore
--- Android_6.0.1_r11/frameworks/support/v7/appcompat/.gitignore	2017-09-27 02:08:01.623735947 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/support/v7/appcompat/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,4 +0,0 @@
-.settings
-bin
-libs
-gen
diff -urN Android_6.0.1_r11/frameworks/support/v7/gridlayout/.gitignore SAMD_6.0.1_r11_20170930/frameworks/support/v7/gridlayout/.gitignore
--- Android_6.0.1_r11/frameworks/support/v7/gridlayout/.gitignore	2017-09-27 02:08:01.735735946 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/support/v7/gridlayout/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,4 +0,0 @@
-.settings
-bin
-libs
-gen
diff -urN Android_6.0.1_r11/frameworks/support/v7/mediarouter/.gitignore SAMD_6.0.1_r11_20170930/frameworks/support/v7/mediarouter/.gitignore
--- Android_6.0.1_r11/frameworks/support/v7/mediarouter/.gitignore	2017-09-27 02:08:01.739735946 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/support/v7/mediarouter/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,4 +0,0 @@
-.settings
-bin
-libs
-gen
Binary files Android_6.0.1_r11/frameworks/volley/.git/index and SAMD_6.0.1_r11_20170930/frameworks/volley/.git/index differ
diff -urN Android_6.0.1_r11/frameworks/volley/.gitignore SAMD_6.0.1_r11_20170930/frameworks/volley/.gitignore
--- Android_6.0.1_r11/frameworks/volley/.gitignore	2017-09-27 02:08:01.927735943 +0900
+++ SAMD_6.0.1_r11_20170930/frameworks/volley/.gitignore	1970-01-01 09:00:00.000000000 +0900
@@ -1,9 +0,0 @@
-bin
-gen
-.gradle
-build
-.settings
-target
-*.iml
-.idea
-local.properties
Binary files Android_6.0.1_r11/frameworks/webview/.git/index and SAMD_6.0.1_r11_20170930/frameworks/webview/.git/index differ
Binary files Android_6.0.1_r11/frameworks/wilhelm/.git/index and SAMD_6.0.1_r11_20170930/frameworks/wilhelm/.git/index differ
