Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DDC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GOKA HARSHITH
DDC
Commits
72299da0
Commit
72299da0
authored
Jun 23, 2016
by
Harshith Goka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug crash, add more functionalities
parent
a928799d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
24 deletions
+135
-24
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
app/src/main/java/com/example/harshith/ddc/Constants.java
app/src/main/java/com/example/harshith/ddc/Constants.java
+4
-0
app/src/main/java/com/example/harshith/ddc/Frame.java
app/src/main/java/com/example/harshith/ddc/Frame.java
+8
-2
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
...main/java/com/example/harshith/ddc/ReceiveDataThread.java
+29
-5
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
...rc/main/java/com/example/harshith/ddc/ReceiveService.java
+93
-17
No files found.
app/src/main/AndroidManifest.xml
View file @
72299da0
...
@@ -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"
...
...
app/src/main/java/com/example/harshith/ddc/Constants.java
View file @
72299da0
...
@@ -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"
;
}
}
app/src/main/java/com/example/harshith/ddc/Frame.java
View file @
72299da0
...
@@ -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
;
}
}
}
}
...
...
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
View file @
72299da0
...
@@ -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
();
}
}
}
}
...
...
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
View file @
72299da0
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
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment