Enable special permissions by default on Xiaomi phones

Viewed 142

I have checked previous questions on this topic but none of them answers the question completely.

In Xiaomi devices, 'Show over lockscreen' and 'Show popup dialogs' permissions are considered special perms. Now in previous question there are some methods to ask user to manually allow them BUT there is no default way to enable them.

When you install Skype or similar apps from Google Playstore, by default these permissions are turned on for those devices. I need Show over Lockscreen permission to show my app when I am getting a VOIP call.

I have tried the following code but it doesn't work for Xiaomi devices.

   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
      {
          setShowWhenLocked(true);
          setTurnScreenOn(true);
          KeyguardManager keyguardManager = (KeyguardManager) getSystemService(getApplicationContext().KEYGUARD_SERVICE);
          if(keyguardManager!=null)
              keyguardManager.requestDismissKeyguard(this, null);
      }
      else
      {
          getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                  WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                  WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
      }

I have allowed showOverLockedScreen in manifest.xml file and also setShowWhenLocked(true); but none of them enables those special permissions.

0 Answers
Related