Skip to content

Commit 8019962

Browse files
committed
Remove layout flags to allow phone to lock again after the call
1 parent 27fa712 commit 8019962

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

android/src/main/java/com/ngs/react/RNTwilioVideo/TwilioVideoModule.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ private void internalGoOffline(VideoCallInvite invite, Integer notificationId) {
178178
@ReactMethod
179179
public void disconnect() {
180180
activeCall = null;
181+
// Remove layout flags to allow phone to re-lock
182+
if (getReactApplicationContext().getCurrentActivity() != null) {
183+
Window window = getReactApplicationContext().getCurrentActivity().getWindow();
184+
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
185+
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
186+
);
187+
}
181188
}
182189

183190
@ReactMethod

android/src/main/java/com/ngs/react/RNTwilioVoice/TwilioVoiceModule.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,17 @@ public void disconnect() {
647647
activeCall = null;
648648
}
649649
activeCallInvite = null;
650+
// Remove layout flags to allow phone to re-lock
651+
if (getReactApplicationContext().getCurrentActivity() != null) {
652+
Window window = getReactApplicationContext().getCurrentActivity().getWindow();
653+
getReactApplicationContext().getCurrentActivity().runOnUiThread(new Runnable() {
654+
@Override
655+
public void run() {
656+
window.clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
657+
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
658+
};
659+
});
660+
}
650661
}
651662

652663
@ReactMethod

0 commit comments

Comments
 (0)