Skip to content

Commit

Permalink
Now using API level 28.
Browse files Browse the repository at this point in the history
  • Loading branch information
André Marçais committed Feb 18, 2021
1 parent d7092fa commit e6f18ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
compileSdkVersion 28

defaultConfig {
applicationId "com.termux.api"
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/com/termux/api/SmsSendAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionInfo;

import com.termux.api.util.ResultReturner;
import com.termux.api.util.TermuxApiLogger;
Expand Down Expand Up @@ -50,13 +51,13 @@ static SmsManager getSmsManager(Context context, final Intent intent) {
TermuxApiLogger.error("SubscriptionManager not supported");
return null;
}
int[] subs = sm.getSubscriptionIds(slot);
if(subs != null && subs.length > 0) {
return SmsManager.getSmsManagerForSubscriptionId(subs[0]);
} else {
TermuxApiLogger.error("Invalid slot index "+slot);
return null;
for(SubscriptionInfo si: sm.getActiveSubscriptionInfoList()) {
if(si.getSimSlotIndex() == slot) {
return SmsManager.getSmsManagerForSubscriptionId(si.getSubscriptionId());
}
}
TermuxApiLogger.error("Sim slot "+slot+" not found");
return null;
}
}

Expand Down

0 comments on commit e6f18ad

Please sign in to comment.