Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android]: backToForeground doesn't wake up a phone if it was locked #779

Open
1 of 3 tasks
DanteWitcher opened this issue May 16, 2024 · 1 comment
Open
1 of 3 tasks

Comments

@DanteWitcher
Copy link

DanteWitcher commented May 16, 2024

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 #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

  1. lock the phone
  2. 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

- 
@ramaatamai
Copy link

@DanteWitcher are you found any solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants