react-native-webrtc / react-native-webrtc/react-native-callkeep
[Android]: backToForeground doesn't wake up a phone if it was locked
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 511
- Avg merge
- 9h 12m
- Merged PRs (30d)
- 2
Description
Bug report
-
I've checked the example to reproduce the issue.
-
Reproduced on:
-
Android
-
iOS
Description
For some devices backToForeground method doesn't wake up the phone, when it's locked, I'm getting a push notification and then I'm trying to call the backToForeground and displayIncominCall method, but nothing happens, this problem is mostly observed on the Samsung devices with the latest version.
Unfortunately I don't have the device to reproduce it (but I've tested on device with Android v9 - Redme Note 6, Galaxy J7 and it works perfectly; In additional the strange thing is if plug in the phone to the charge - it starts working I was thinking about Doze mode (https://developer.android.com/training/monitoring-device-state/doze-standby), and I gave user to accept ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, but it doesn't help. I was thinking about this issue https://github.com/react-native-webrtc/react-native-callkeep/issues/667, and tried the same solution, but it doesn't help as well, I'm not familiar with Android, and probably I did something in the wrong way:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent();
String packageName = getPackageName();
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(true);
setTurnScreenOn(true);
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
keyguardManager.requestDismissKeyguard(this, null);
} getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
If you have some thought what can help or need more details, please let me know. Want to understand a root cause, thanks;
By the way, I don't use self mode, and there is manifest
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.audio.output" />
<uses-feature android:name="android.hardware.microphone" />
<!-- CallKit -->
<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- Push Notification -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<!-- Push Notification -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:screenOrientation="portrait"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_logo"
android:roundIcon="@mipmap/ic_logo_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="false"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@color/colorPrimary"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.wazo.callkeep.VoiceConnectionService"
android:exported="true"
android:label="Wazo"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
android:foregroundServiceType="camera|microphone"
>
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>
<service android:name="io.wazo.callkeep.RNCallKeepBackgroundMessagingService" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:showOnLockScreen="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Steps to Reproduce
- lock the phone
- and execute backToBackground method
Versions
- Callkeep: 4.3.12
- React Native: 0.70.12
- iOS: -
- Android: OS Version 14, SDK Version Android 3.2.0
- Phone model: Galaxy Z Fold3 5G, Galaxy S20 FE 5G
Logs
-
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MainActivity.onCreate code and the manifest activity settings shown in the report, then trace the backToForeground and displayIncominCall entry points. Reproduce the locked-screen case on the listed Samsung devices or Android versions and collect logs; done means the phone wakes and the incoming call is displayed while locked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100