Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ public InCallManagerModule(ReactApplicationContext reactContext) {

private void manualTurnScreenOff() {
Log.d(TAG, "manualTurnScreenOff()");
Activity mCurrentActivity = getCurrentActivity();

if (mCurrentActivity == null) {
Log.d(TAG, "ReactContext doesn't have any Activity attached.");
return;
}

UiThreadUtil.runOnUiThread(new Runnable() {
public void run() {
Activity mCurrentActivity = getCurrentActivity();
if (mCurrentActivity == null) {
Log.d(TAG, "ReactContext doesn't hava any Activity attached.");
return;
}
Window window = mCurrentActivity.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
lastLayoutParams = params; // --- store last param
Expand All @@ -221,13 +223,15 @@ public void run() {

private void manualTurnScreenOn() {
Log.d(TAG, "manualTurnScreenOn()");
Activity mCurrentActivity = getCurrentActivity();

if (mCurrentActivity == null) {
Log.d(TAG, "ReactContext doesn't have any Activity attached.");
return;
}

UiThreadUtil.runOnUiThread(new Runnable() {
public void run() {
Activity mCurrentActivity = getCurrentActivity();
if (mCurrentActivity == null) {
Log.d(TAG, "ReactContext doesn't hava any Activity attached.");
return;
}
Window window = mCurrentActivity.getWindow();
if (lastLayoutParams != null) {
window.setAttributes(lastLayoutParams);
Expand Down Expand Up @@ -848,14 +852,18 @@ public void turnScreenOff() {
@ReactMethod
public void setKeepScreenOn(final boolean enable) {
Log.d(TAG, "setKeepScreenOn() " + enable);

Activity mCurrentActivity = getCurrentActivity();

if (mCurrentActivity == null) {
Log.d(TAG, "ReactContext doesn't have any Activity attached.");
return;
}

UiThreadUtil.runOnUiThread(new Runnable() {
public void run() {
Activity mCurrentActivity = getCurrentActivity();
if (mCurrentActivity == null) {
Log.d(TAG, "ReactContext doesn't hava any Activity attached.");
return;
}
Window window = mCurrentActivity.getWindow();

if (enable) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
Expand Down