Skip to content

Commit e2b315b

Browse files
committed
Refer to reactContext.getCurrentActivity instead of getCurrentActivity in RNCallKeepModule
1 parent 99b7bb9 commit e2b315b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ public void endAllCalls() {
405405

406406
@ReactMethod
407407
public void checkPhoneAccountPermission(ReadableArray optionalPermissions, Promise promise) {
408-
Activity currentActivity = this.getCurrentActivity();
408+
Activity currentActivity = this.getCurrentReactActivity();
409409

410410
if (!isConnectionServiceAvailable()) {
411411
String error = "ConnectionService not available for this version of Android.";
@@ -870,7 +870,7 @@ public void backToForeground() {
870870
}
871871
String packageName = context.getApplicationContext().getPackageName();
872872
Intent focusIntent = context.getPackageManager().getLaunchIntentForPackage(packageName).cloneFilter();
873-
Activity activity = getCurrentActivity();
873+
Activity activity = getCurrentReactActivity();
874874
boolean isOpened = activity != null;
875875
Log.d(TAG, "[RNCallKeepModule] backToForeground, app isOpened ?" + (isOpened ? "true" : "false"));
876876

@@ -900,6 +900,10 @@ public static void onRequestPermissionsResult(int requestCode, String[] grantedP
900900
hasPhoneAccountPromise.resolve(true);
901901
}
902902

903+
public Activity getCurrentReactActivity() {
904+
return this.reactContext.getCurrentActivity();
905+
}
906+
903907
private void registerPhoneAccount(Context appContext) {
904908
if (!isConnectionServiceAvailable()) {
905909
Log.w(TAG, "[RNCallKeepModule] registerPhoneAccount ignored due to no ConnectionService");
@@ -961,7 +965,7 @@ private String getApplicationName(Context appContext) {
961965
}
962966

963967
private Boolean hasPermissions() {
964-
Activity currentActivity = this.getCurrentActivity();
968+
Activity currentActivity = this.getCurrentReactActivity();
965969

966970
if (currentActivity == null) {
967971
return false;
@@ -1002,9 +1006,6 @@ private void registerReceiver() {
10021006
intentFilter.addAction(ACTION_ON_CREATE_CONNECTION_FAILED);
10031007
intentFilter.addAction(ACTION_DID_CHANGE_AUDIO_ROUTE);
10041008

1005-
Log.w(TAG, "[RNCallKeepModule][registerReceiver] reactContext:" + (this.reactContext == null ? "NOPE" : "OK"));
1006-
1007-
10081009
if (this.reactContext != null) {
10091010
LocalBroadcastManager.getInstance(this.reactContext).registerReceiver(voiceBroadcastReceiver, intentFilter);
10101011
isReceiverRegistered = true;

0 commit comments

Comments
 (0)