Skip to content

Commit

Permalink
Merge pull request #29 from exotel/VST-882
Browse files Browse the repository at this point in the history
Handled the microphone permission according to the Android 14 Guide Lines
  • Loading branch information
vijaykumar-exotel authored Nov 25, 2024
2 parents 44d051d + dfaab17 commit 416bf90
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 247 deletions.
Binary file modified Exotel Voice Client Android SDK Integration Guide.pdf
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions jetixApp/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [1.0.63] 25-11-2024
### Added
* [VST-859](https://exotel.atlassian.net/browse/VST-882): Updating the Foreground Service for Microphone Permission at the Runtime According to Android 14 Guidelines


## [1.0.62] 16-10-2024
### Added
* [VST-859](https://exotel.atlassian.net/browse/VST-859): In the stop function, the onDestroyMediaSession is handled, and stop can only be initiated in the Idle state.
Expand Down
7 changes: 4 additions & 3 deletions jetixApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
}

android {
buildFeatures.buildConfig true

packagingOptions {
pickFirst("META-INF/okio.kotlin_module")
Expand All @@ -30,12 +31,12 @@ android {
keyPassword 'exotel321'
}
}
compileSdkVersion 34
compileSdk 35
defaultConfig {
applicationId "com.exotel.voicesample"
minSdkVersion 26
targetSdkVersion 34
versionCode 16
targetSdk 35
versionCode 17
versionName "1.0.50"
archivesBaseName = "ExotelVoice-" + versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ void createNotificationChannel() {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel serviceChannel = new NotificationChannel(CHANNEL_ID,
"Exotel Voip Sample", NotificationManager.IMPORTANCE_DEFAULT);
"Exotel Voip Sample", NotificationManager.IMPORTANCE_HIGH);
serviceChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
NotificationManager manager = context.getSystemService(NotificationManager.class);

manager.createNotificationChannel(serviceChannel);
}
}
Expand Down Expand Up @@ -225,6 +227,8 @@ Notification createNotification(CallState state, String destination, String call
.setContentTitle("Exotel Voice Application")
.setContentText(text)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setOnlyAlertOnce(true)
.setSmallIcon(R.drawable.ic_call_24dp)
.build();
Expand Down
362 changes: 149 additions & 213 deletions jetixApp/app/src/main/java/com/exotel/voicesample/HomeActivity.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void makeServiceForeground(Notification notification) {
startForeground(NOTIFICATION_ID, notification);
} else {
// startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST);
ServiceCompat.startForeground(this,NOTIFICATION_ID,notification,ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST);
ServiceCompat.startForeground(this, NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL);
}


Expand Down Expand Up @@ -473,22 +473,6 @@ public void unmute() {
}
}

public void answer() throws Exception {
VoiceAppLogger.debug(TAG, "Answering call");
if (null == mCall) {
String message = "Call object is NULL";
throw new Exception(message);
}
try {
tonePlayback.stopTone();
mCall.answer();
} catch (Exception e) {
throw new Exception(e.getMessage());
}

VoiceAppLogger.debug(TAG, "After Answering call");

}

public int getCallDuration() {

Expand Down Expand Up @@ -517,7 +501,7 @@ public CallStatistics getStatistics() {

public VoiceAppStatus getCurrentStatus() {
if (exotelVoiceClient == null) {
VoiceAppLogger.debug(TAG,"VoIP Client not initialized");
VoiceAppLogger.debug(TAG, "VoIP Client not initialized");
voiceAppStatus.setState(VoiceAppState.STATUS_NOT_INITIALIZED);
voiceAppStatus.setMessage("In Progress");
} else if (initializationInProgress) {
Expand Down Expand Up @@ -711,6 +695,7 @@ public void onCallInitiated(Call call) {
callEvents.onCallInitiated(call);
}
mCall = call;
updateForegroundServiceType(call,CallState.OUTGOING_INITIATED);
VoiceAppLogger.debug(TAG, "End: onCallInitiated");
}

Expand Down Expand Up @@ -741,6 +726,38 @@ public void run() {
VoiceAppLogger.debug(TAG, "End: onCallRinging");
}

public void answer() throws Exception {
VoiceAppLogger.debug(TAG, "Answering call");
if (null == mCall) {
String message = "Call object is NULL";
throw new Exception(message);
}
try {
updateForegroundServiceType(mCall, CallState.ANSWERING);
tonePlayback.stopTone();
mCall.answer();
} catch (Exception e) {
throw new Exception(e.getMessage());
}
VoiceAppLogger.debug(TAG, "After Answering call");
}

private void updateForegroundServiceType(Call call, CallState outgoingInitiated) {
handler.post(new Runnable() {
@Override
public void run() {
Notification notification = utils.createNotification(outgoingInitiated, call.getCallDetails().getRemoteId(), call.getCallDetails().getCallId(), call.getCallDetails().getCallDirection());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
startForeground(NOTIFICATION_ID, notification);
} else {
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST);
// ServiceCompat.startForeground(VoiceAppService.this, NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL);
}
}
});
}


@Override
public void onCallEstablished(Call call) {
VoiceAppLogger.debug(TAG, "Call Estabslished");
Expand Down
14 changes: 7 additions & 7 deletions jetixApp/app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/logout"
android:title="@string/Logout"></item>
android:title="@string/Logout" />

<item
android:id="@+id/uploadLogs"
android:title="@string/upload_logs"></item>
android:title="@string/upload_logs" />

<item
android:id="@+id/about"
android:title="@string/About"></item>
android:title="@string/About" />

<item
android:id="@+id/postFeedback"
android:title="@string/lastCallFeedback"></item>
android:title="@string/lastCallFeedback" />

<item
android:id="@+id/accountDetails"
android:title="@string/accountDetails"></item>
android:title="@string/accountDetails" />

<!--Removing debug dialing mode-->
<!-- <item android:id="@+id/enableDebugDialling"
Expand All @@ -32,10 +32,10 @@

<item
android:id="@+id/enableMulticall"
android:title="@string/enableMulticall"></item>
android:title="@string/enableMulticall" />

<item
android:id="@+id/disableMulticall"
android:title="@string/disableMulticall"></item>
android:title="@string/disableMulticall" />

</menu>
6 changes: 2 additions & 4 deletions jetixApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ buildscript {
repositories {
google()
mavenCentral()
jcenter()
flatDir {
dirs 'libs'
}

}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.5.2'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'


// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -30,7 +29,6 @@ allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
Expand Down
2 changes: 1 addition & 1 deletion jetixApp/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Mar 22 18:54:05 IST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 416bf90

Please # to comment.