title: Foreground Service and WakeLocks are not working on Huawei Devices
body: <p>I developed an Android app called Multi Countdown Timer In which we can start multiple timers at once. The App runs on the background using <strong>Foreground Service</strong> in order to run continuously and override's The Android <strong>Doze Mode</strong>.</p>
  
  <p>I have tested my App on Samsung s6, A7, Nokia 3.1, LG Nexus 5x and some emulators. The Apps runs perfectly and Wake Up's when the timer finished.
  But on the other hand, whenever I run my App on <strong>Huawei Devices</strong> (EMUI 8 Android Oreo 8.0.0) the result is not satisfactory at all. The problem I'm facing is that the App didn't wake up the screen when the Timer is Finished and when the timer is finished when I open my device it rings then but didn't auto Wake Up the screen as it is working on the other devices.</p>
  
  <p>I have replicated this App <a href="https://play.google.com/store/apps/details?id=com.jee.timer&amp;hl=en" rel="nofollow noreferrer">Multi Timer StopWatch</a> and this App is working fine even on Huawei Devices.</p>
  
  <p>This is my Activity in Manifest.xml.</p>
  
  <pre><code>           android:name=".view.alarm.AlarmActivity"
             android:process="alarm.process"
             android:screenOrientation="portrait"
             android:showOnLockScreen="true"
             android:showWhenLocked="true"
             android:turnScreenOn="true"
             android:theme="@style/splashScreenTheme" /&gt;
  </code></pre>
  
  <p>This is how I called my Alarm Activity.</p>
  
  <pre><code>val alarmIntent = Intent(this@CountDownTimerForegroundService, AlarmActivity::class.java)
      alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
      alarmIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {
      alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
      }
      alarmIntent.putExtra(ALARM_PASSING_ID, timerObj.id)
      startActivity(alarmIntent)
  </code></pre>
  
  <p>And this is my Alarm Activity onCreate</p>
  
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          window.addFlags(
              WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                      or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                      or WindowManager.LayoutParams.FLAG_FULLSCREEN
                      or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                      or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                      or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                      or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
          )
  
          setContentView(R.layout.activity_alarm)
  </code></pre>
  
  <p>Any Help will be highly appreciated. Thanks in Advance.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>1) On Huawei device, I have tested after Whitelisting my app in PowerManager and also enabled Battery Optimization But it also didn't help out.</p>
  
  <p>2) I have tested with some Wake Locks in my Foreground Service but still getting the same behavior.</p>
  
  <p>3) Used Android <strong>AlarmManager</strong> with setExactAndAllowWhileIdle still didn't wake up the device.</p>
  
  <p>4) Used <a href="https://dontkillmyapp.com/huawei" rel="nofollow noreferrer">Don'tKillMyApp</a> Solution to use <strong>LocationManagerService</strong> Tag in Wake Lock also didn't help out.</p>