Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
KDE Connect Android
Commits
96e86103
Commit
96e86103
authored
Jan 05, 2015
by
Mihail Ivchenko
Committed by
Albert Vaca Cintora
Jan 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented functionality to mute an incoming call.
REVIEW: 121855
parent
820b32d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
7 deletions
+39
-7
src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
...e/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
+39
-7
No files found.
src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
View file @
96e86103
...
...
@@ -27,6 +27,7 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.graphics.drawable.Drawable
;
import
android.media.AudioManager
;
import
android.os.Bundle
;
import
android.telephony.SmsMessage
;
import
android.telephony.TelephonyManager
;
...
...
@@ -37,8 +38,15 @@ import org.kde.kdeconnect.NetworkPackage;
import
org.kde.kdeconnect.Plugins.Plugin
;
import
org.kde.kdeconnect_tp.R
;
import
java.util.Timer
;
import
java.util.TimerTask
;
public
class
TelephonyPlugin
extends
Plugin
{
private
int
lastState
=
TelephonyManager
.
CALL_STATE_IDLE
;
private
NetworkPackage
lastPackage
=
null
;
boolean
isMuted
=
false
;
@Override
public
String
getPluginName
()
{
return
"plugin_telephony"
;
...
...
@@ -105,15 +113,9 @@ public class TelephonyPlugin extends Plugin {
callBroadcastReceived
(
finalIntState
,
finalNumber
);
}
}
};
private
int
lastState
=
TelephonyManager
.
CALL_STATE_IDLE
;
private
NetworkPackage
lastPackage
=
null
;
public
void
callBroadcastReceived
(
int
state
,
String
phoneNumber
)
{
//Log.e("TelephonyPlugin", "callBroadcastReceived");
...
...
@@ -126,6 +128,11 @@ public class TelephonyPlugin extends Plugin {
switch
(
state
)
{
case
TelephonyManager
.
CALL_STATE_RINGING
:
if
(
isMuted
)
{
AudioManager
am
=
(
AudioManager
)
context
.
getSystemService
(
Context
.
AUDIO_SERVICE
);
am
.
setStreamMute
(
AudioManager
.
STREAM_RING
,
false
);
isMuted
=
false
;
}
np
.
set
(
"event"
,
"ringing"
);
device
.
sendPackage
(
np
);
break
;
...
...
@@ -143,6 +150,20 @@ public class TelephonyPlugin extends Plugin {
lastPackage
.
set
(
"isCancel"
,
"true"
);
device
.
sendPackage
(
lastPackage
);
if
(
isMuted
)
{
Timer
timer
=
new
Timer
();
timer
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
if
(
isMuted
)
{
AudioManager
am
=
(
AudioManager
)
context
.
getSystemService
(
Context
.
AUDIO_SERVICE
);
am
.
setStreamMute
(
AudioManager
.
STREAM_RING
,
false
);
isMuted
=
false
;
}
}
},
500
);
}
//Emit a missed call notification if needed
if
(
lastState
==
TelephonyManager
.
CALL_STATE_RINGING
)
{
np
.
set
(
"event"
,
"missedCall"
);
...
...
@@ -198,8 +219,19 @@ public class TelephonyPlugin extends Plugin {
@Override
public
boolean
onPackageReceived
(
NetworkPackage
np
)
{
if
(!
np
.
getType
().
equals
(
NetworkPackage
.
PACKAGE_TYPE_TELEPHONY
))
{
return
false
;
}
if
(
np
.
getString
(
"action"
).
equals
(
"mute"
))
{
if
(!
isMuted
)
{
AudioManager
am
=
(
AudioManager
)
context
.
getSystemService
(
Context
.
AUDIO_SERVICE
);
am
.
setStreamMute
(
AudioManager
.
STREAM_RING
,
true
);
isMuted
=
true
;
}
//Log.e("TelephonyPlugin", "mute");
}
//Do nothing
return
fals
e
;
return
tru
e
;
}
@Override
...
...
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