Xamarin Android ForceDarkHelper What is it?

Viewed 1079

Periodically, the application begins to update itself. There is a constant call in the logs:

[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70
[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70
[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70
[ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4.MainActivity@a894c70

When this happens, if, for example, you open the menu , it closes itself, if something is filled in, it is cleared, the page is updated. There are no timers in the code. I'm testing the app on Xiaomi Redmi. I repeat sometimes it happens sometimes it doesn't. What is it?

I do not know what the problem is, but occasionally, it happens that the application throws the fingerprint to the page. It is intermittent. Sometimes everything works fine. That is, I go through the fingerprint, the next page opens, everything is normal and a second after 5 I am again thrown to the page where you need to enter the fingerprint. Code for the authorization page:

public authentification()
    {
        try
        {

        InitializeComponent();
        bool auth = CrossSettings.Current.GetValueOrDefault("authorized", false);
        if (auth == false) { CheckAuth(); }
        else
        {
            Application.Current.MainPage = new MasterLk();

        }

        }
        catch { }
    }
    async void CheckAuth()
    {
        try
        {


            var avail = await CrossFingerprint.Current.IsAvailableAsync();
            if (!avail)
            {
                CrossSettings.Current.GetValueOrDefault("authorized", true);
                Application.Current.MainPage = new MasterLk();
            }
            else
            {
                var request = new AuthenticationRequestConfiguration("NeedAuth", "-");
                var result = await CrossFingerprint.Current.AuthenticateAsync(request);
                if (result.Authenticated)
                {
                  CrossSettings.Current.GetValueOrDefault("authorized", true);
                  Application.Current.MainPage = new MasterLk();
                }
                else
                {
                    CheckAuth();
                  
                }
            }
        }
        catch { }

    }

On the page where it throws it there is a ListView with a binding:

public class OrdersViewModel : BaseViewModel
    {
        private Table oldLoan;
        private bool isRefreshing;
        private readonly string clientId;
 
 
        public bool IsRefreshing
        {
            get
            {
                return isRefreshing;
            }
            set
            {
                isRefreshing = value;
                OnPropertyChanged("IsRefreshing");
            }
        }
        public ICommand RefreshCommand { get; set; }
 
        public ObservableCollection<Table> Loans { get; set; }
 
        public void ShowOrHideLoan(Table loan)
        {
            if (oldLoan == loan)
            {
                loan.IsExpanded = !loan.IsExpanded;
                Reload(loan);
 
            }
            else
            {
                if (oldLoan != null)
                {
                    oldLoan.IsExpanded = false;
 
                    Reload(oldLoan);
                }
                loan.IsExpanded = true;
                Reload(loan);
 
            }
            oldLoan = loan;
        }
        private void Reload(Table loan)
        {
            var index = Loans.IndexOf(loan);
            Loans.Remove(loan);
            Loans.Insert(index, loan);
        }
        public async Task LoadDataAsync()
        {
            IsRefreshing = true;
            Loans.Clear();
            try
            {
                var loans = await ConnectAPI.GetOrdersAsync(clientId);
                await Task.Delay(1000);
                foreach (var item in loans)
                {
                    Loans.Add(item);
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            }
            finally
            {
                oldLoan = null;
                IsRefreshing = false;
            }
        }
        public OrdersViewModel(string clientId) 
        {
            IsRefreshing = false;
            this.clientId = clientId;
            Loans = new ObservableCollection<Table>();
            RefreshCommand = new Command(async () =>
            {
                await LoadDataAsync();
            });
            Task.Run(async () => await LoadDataAsync());
        }
    }

That is, whenever the [ForceDarkHelper] updateByCheckExcludeList: pkg: com.companyname.manimobile activity: crc64d14753dcc52b83b4 event appears.MainActivity@a894c70 Throws it to the print page... and if you stay on this page, it is updated after a while.

1 Answers

MIUI 12 has made an intelligent dark theme. The system itself repaints the applications if they do not support the dark theme. Apparently this service is ForceDarkHelper. And ExcludeList is in the settings a list of applications that cannot be repainted

Related