Add wakelock to UserCallActivity

Add a wakelock to make sure that the phone doesn't go to sleep in the
middle of trying to initiate an outgoing call through Bluetooth (or
something else that doesn't require the screen being on).

Change-Id: Ide945fabbb474cb8ce60fbf704698e566e9f9b01
Fixes: 38328207
Test: manual
This commit is contained in:
Hall Liu 2017-05-31 14:47:08 -07:00
parent 0f1b7b1dcb
commit 9a7302fadf
2 changed files with 9 additions and 0 deletions

View File

@ -41,6 +41,7 @@
<uses-permission android:name="android.permission.STOP_APP_SWITCHES" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_BLOCKED_NUMBERS" />
<uses-permission android:name="android.permission.WRITE_BLOCKED_NUMBERS" />
<uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />

View File

@ -23,6 +23,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.telecom.Log;
@ -52,6 +53,11 @@ public class UserCallActivity extends Activity implements TelecomSystem.Componen
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
PowerManager.WakeLock wakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"UserCallActivity");
wakelock.acquire();
Log.startSession("UCA.oC");
try {
// TODO: Figure out if there is something to restore from bundle.
@ -71,7 +77,9 @@ public class UserCallActivity extends Activity implements TelecomSystem.Componen
getCallingPackage(), true /* hasCallAppOp*/);
} finally {
Log.endSession();
wakelock.release();
}
Log.i(this, "onCreate done");
finish();
}