Commit 72299da0 authored by Harshith Goka's avatar Harshith Goka

Debug crash, add more functionalities

parent a928799d
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.INJECT_EVENTS"/>
<application <application
android:name=".GlobalClass" android:name=".GlobalClass"
android:allowBackup="true" android:allowBackup="true"
......
...@@ -17,5 +17,9 @@ public class Constants { ...@@ -17,5 +17,9 @@ public class Constants {
public static String OK_GOOGLE = "Ok Google"; public static String OK_GOOGLE = "Ok Google";
public static String OPEN_CAMERA = "Camera"; public static String OPEN_CAMERA = "Camera";
public static String GOOGLE_NOW = "GoogleApp"; public static String GOOGLE_NOW = "GoogleApp";
public static String CAMERA_CLICK = "CameraClick";
public static String VOLUME_UP="VolumeUp";
public static String VOLUME_DOWN="VolumeDown";
public static String END_CALL="EndCall";
} }
...@@ -22,9 +22,15 @@ public class Frame{ ...@@ -22,9 +22,15 @@ public class Frame{
} }
if(index == 8){ if(index == 8){
if(isMpu) {
upperBound = lrBound; upperBound = lrBound;
lowerBound = upBound; lowerBound = upBound;
} }
else{
upperBound = upBound;
lowerBound = lrBound;
}
}
} }
......
...@@ -98,6 +98,7 @@ public class ReceiveDataThread extends Thread { ...@@ -98,6 +98,7 @@ public class ReceiveDataThread extends Thread {
while(true) { while(true) {
bytes = inputStream.read(buffer); bytes = inputStream.read(buffer);
readStatus = Constants.READ_STATUS_OK;
String readMessage = new String(buffer,0,bytes); String readMessage = new String(buffer,0,bytes);
stringBuilder.append(readMessage); stringBuilder.append(readMessage);
int endOfLineIndex = stringBuilder.indexOf("~"); int endOfLineIndex = stringBuilder.indexOf("~");
...@@ -134,22 +135,42 @@ public class ReceiveDataThread extends Thread { ...@@ -134,22 +135,42 @@ public class ReceiveDataThread extends Thread {
Log.d("Gesture","Gesture " + gestActive + " is activated"); Log.d("Gesture","Gesture " + gestActive + " is activated");
if(gestActive == 0){ if(gestActive == 0){
Looper.prepare(); Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,Constants.OPEN_CAMERA).sendToTarget(); handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.OPEN_CAMERA).sendToTarget();
Looper.loop(); Looper.loop();
} }
else if(gestActive == 1){ else if(gestActive == 1){
Looper.prepare(); Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,Constants.OK_GOOGLE).sendToTarget(); handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.OK_GOOGLE).sendToTarget();
Looper.loop(); Looper.loop();
} }
else if(gestActive == 2){ else if(gestActive == 2){
Looper.prepare(); Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,Constants.GOOGLE_NOW).sendToTarget(); handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.GOOGLE_NOW).sendToTarget();
Looper.loop(); Looper.loop();
} }
else if(gestActive == 3){ else if(gestActive == 3){
Looper.prepare(); Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,Constants.PLAY_PAUSE).sendToTarget(); handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.PLAY_PAUSE).sendToTarget();
Looper.loop();
}
else if(gestActive == 4){
Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.CAMERA_CLICK).sendToTarget();
Looper.loop();
}
else if(gestActive == 5){
Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.VOLUME_UP).sendToTarget();
Looper.loop();
}
else if(gestActive == 6){
Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.VOLUME_DOWN).sendToTarget();
Looper.loop();
}
else if(gestActive == 7){
Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,readStatus,0,Constants.END_CALL).sendToTarget();
Looper.loop(); Looper.loop();
} }
...@@ -181,6 +202,9 @@ public class ReceiveDataThread extends Thread { ...@@ -181,6 +202,9 @@ public class ReceiveDataThread extends Thread {
} }
catch (IOException e){ catch (IOException e){
readStatus = Constants.READ_STATUS_NOT_OK; readStatus = Constants.READ_STATUS_NOT_OK;
Looper.prepare();
handler.obtainMessage(Constants.READ_STATUS,readStatus,0,null);
Looper.loop();
} }
} }
......
package com.example.harshith.ddc; package com.example.harshith.ddc;
import android.Manifest; import android.Manifest;
import android.app.Instrumentation;
import android.app.Service; import android.app.Service;
import android.bluetooth.BluetoothSocket; import android.bluetooth.BluetoothSocket;
import android.content.ComponentName; import android.content.ComponentName;
...@@ -50,27 +51,41 @@ public class ReceiveService extends Service { ...@@ -50,27 +51,41 @@ public class ReceiveService extends Service {
receiveDataThread = new ReceiveDataThread((BluetoothSocket) message.obj,handler,globalClass); receiveDataThread = new ReceiveDataThread((BluetoothSocket) message.obj,handler,globalClass);
receiveDataThread.start(); receiveDataThread.start();
} }
else if((int) message.obj == Constants.CONNECTION_STATUS_NOT_CONNECTED){ else if(message.arg1 == Constants.CONNECTION_STATUS_NOT_CONNECTED){
Toast.makeText(getApplicationContext(),"Couldn't Connect to Dextera Domini, Check whether it is switched on",Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(),"Couldn't Connect to Dextera Domini, Check whether it is switched on",Toast.LENGTH_SHORT).show();
} }
} }
else if (message.what == Constants.READ_STATUS) { else if (message.what == Constants.READ_STATUS) {
if(((String)message.obj).equals(Constants.OPEN_CAMERA)){ if (message.arg1 == Constants.READ_STATUS_OK) {
if (((String) message.obj).equals(Constants.OPEN_CAMERA)) {
openCamera(); openCamera();
resumeReading(); resumeReading();
} } else if (message.obj.equals(Constants.OK_GOOGLE)) {
else if(message.obj.equals(Constants.OK_GOOGLE)){
okGoogle(); okGoogle();
L.s(getBaseContext(),"Ok Google"); L.s(getBaseContext(), "Ok Google");
resumeReading(); resumeReading();
} } else if (message.obj.equals(Constants.GOOGLE_NOW)) {
else if (message.obj.equals(Constants.GOOGLE_NOW)){
googleNow(); googleNow();
resumeReading(); resumeReading();
} } else if (message.obj.equals(Constants.PLAY_PAUSE)) {
else if(message.obj.equals(Constants.PLAY_PAUSE)){
audioPlayPause(); audioPlayPause();
resumeReading(); resumeReading();
} else if (message.obj.equals(Constants.CAMERA_CLICK)) {
CameraClick();
resumeReading();
} else if (message.obj.equals(Constants.VOLUME_UP)) {
VolumeUp();
resumeReading();
} else if (message.obj.equals(Constants.VOLUME_DOWN)) {
VolumeDown();
resumeReading();
} else if (message.obj.equals(Constants.END_CALL)) {
EndCall();
resumeReading();
}
else if(message.arg1 == Constants.READ_STATUS_NOT_OK){
L.s(getBaseContext(),"Domini Disconnected");
}
} }
} }
} }
...@@ -148,5 +163,66 @@ public class ReceiveService extends Service { ...@@ -148,5 +163,66 @@ public class ReceiveService extends Service {
KeyEvent upEvent = new KeyEvent(KeyEvent.ACTION_UP,KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE); KeyEvent upEvent = new KeyEvent(KeyEvent.ACTION_UP,KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
audioManager.dispatchMediaKeyEvent(upEvent); audioManager.dispatchMediaKeyEvent(upEvent);
} }
public void CameraClick(){
Thread t= new Thread(new Runnable() {
@Override
public void run() {
try {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_CAMERA);
}
catch (Exception e){
}
}
});
t.start();
}
public void VolumeUp(){
Thread t= new Thread(new Runnable() {
@Override
public void run() {
try {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_UP);
}
catch (Exception e){
}
}
});
t.start();
}
public void VolumeDown(){
Thread t= new Thread(new Runnable() {
@Override
public void run() {
try {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_DOWN);
}
catch (Exception e){
}
}
});
t.start();
}
public void EndCall(){
Thread t= new Thread(new Runnable() {
@Override
public void run() {
try {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_ENDCALL);
}
catch (Exception e){
}
}
});
t.start();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment