@@ -55,34 +55,37 @@ public void onCreate() {
55
55
56
56
@ Override
57
57
public int onStartCommand (Intent intent , int flags , int startId ) {
58
+ Log .d (Constants .TAG , "RecordService onStartCommand" );
58
59
if (intent != null ) {
59
60
int commandType = intent .getIntExtra ("commandType" , 0 );
60
61
if (commandType != 0 ) {
61
- Log .d (Constants .TAG , "RecordService onStartCommand" );
62
62
if (commandType == Constants .RECORDING_ENABLED ) {
63
63
Log .d (Constants .TAG , "RecordService RECORDING_ENABLED" );
64
- silentMode = false ;
65
- if (onCall && phoneNumber != null && !recording )
66
- commandType = Constants .STATE_CALL_START ;
64
+ silentMode = intent .getBooleanExtra ("silentMode" , true );
65
+ if (!silentMode && phoneNumber != null && onCall
66
+ && !recording )
67
+ commandType = Constants .STATE_START_RECORDING ;
68
+
67
69
} else if (commandType == Constants .RECORDING_DISABLED ) {
68
70
Log .d (Constants .TAG , "RecordService RECORDING_DISABLED" );
69
- silentMode = true ;
70
- if (onCall && phoneNumber != null )
71
+ silentMode = intent . getBooleanExtra ( "silentMode" , true ) ;
72
+ if (onCall && phoneNumber != null && recording )
71
73
commandType = Constants .STATE_STOP_RECORDING ;
72
74
}
73
-
75
+
74
76
if (commandType == Constants .STATE_INCOMING_NUMBER ) {
75
- startService ();
76
77
Log .d (Constants .TAG , "RecordService STATE_INCOMING_NUMBER" );
78
+ startService ();
77
79
if (phoneNumber == null )
78
80
phoneNumber = intent .getStringExtra ("phoneNumber" );
79
-
81
+
80
82
silentMode = intent .getBooleanExtra ("silentMode" , true );
81
83
} else if (commandType == Constants .STATE_CALL_START ) {
82
84
Log .d (Constants .TAG , "RecordService STATE_CALL_START" );
83
85
onCall = true ;
84
-
85
- if (!silentMode && phoneNumber != null ) {
86
+
87
+ if (!silentMode && phoneNumber != null && onCall
88
+ && !recording ) {
86
89
startService ();
87
90
startRecording (intent );
88
91
}
@@ -93,6 +96,12 @@ public int onStartCommand(Intent intent, int flags, int startId) {
93
96
stopAndReleaseRecorder ();
94
97
recording = false ;
95
98
stopService ();
99
+ } else if (commandType == Constants .STATE_START_RECORDING ) {
100
+ Log .d (Constants .TAG , "RecordService STATE_START_RECORDING" );
101
+ if (!silentMode && phoneNumber != null && onCall ) {
102
+ startService ();
103
+ startRecording (intent );
104
+ }
96
105
} else if (commandType == Constants .STATE_STOP_RECORDING ) {
97
106
Log .d (Constants .TAG , "RecordService STATE_STOP_RECORDING" );
98
107
stopAndReleaseRecorder ();
0 commit comments