Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ffe1316 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android Build Coastguard Worker
Browse files

Removing unnecessary icon-tracker from Icon-provider

Bug: 444306832
Flag: EXEMPT BUGFIX
Test: Verified on device
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:c52d45d48d06e9d25a6e4e9fcb6561e73220cae1
Merged-In: I31f04e2b27dc974d20fda7bb22e210dc5441c0e4
Change-Id: I31f04e2b27dc974d20fda7bb22e210dc5441c0e4
parent bc85ca1d
Loading
Loading
Loading
Loading
+0 −73
Original line number Diff line number Diff line
@@ -16,18 +16,12 @@

package com.android.launcher3.icons;

import static android.content.Intent.ACTION_DATE_CHANGED;
import static android.content.Intent.ACTION_TIMEZONE_CHANGED;
import static android.content.Intent.ACTION_TIME_CHANGED;
import static android.content.res.Resources.ID_NULL;
import static android.graphics.drawable.AdaptiveIconDrawable.getExtraInsetFraction;

import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
import android.content.pm.PackageItemInfo;
@@ -40,10 +34,6 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;

@@ -53,7 +43,6 @@ import androidx.core.os.BuildCompat;

import com.android.launcher3.icons.cache.CachingLogic;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.SafeCloseable;

import java.util.Calendar;
import java.util.Objects;
@@ -296,13 +285,6 @@ public class IconProvider {
        return TextUtils.isEmpty(cn) ? null : ComponentName.unflattenFromString(cn);
    }

    /**
     * Registers a callback to listen for various system dependent icon changes.
     */
    public SafeCloseable registerIconChangeListener(IconChangeListener listener, Handler handler) {
        return new IconChangeReceiver(listener, handler);
    }

    /**
     * Notifies the provider when an icon is loaded from cache
     */
@@ -330,59 +312,4 @@ public class IconProvider {
            return fg;
        }
    }

    private class IconChangeReceiver extends BroadcastReceiver implements SafeCloseable {

        private final IconChangeListener mCallback;

        IconChangeReceiver(IconChangeListener callback, Handler handler) {
            mCallback = callback;
            if (mCalendar != null || mClock != null) {
                final IntentFilter filter = new IntentFilter(ACTION_TIMEZONE_CHANGED);
                if (mCalendar != null) {
                    filter.addAction(Intent.ACTION_TIME_CHANGED);
                    filter.addAction(ACTION_DATE_CHANGED);
                }
                mContext.registerReceiver(this, filter, null, handler);
            }
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            switch (intent.getAction()) {
                case ACTION_TIMEZONE_CHANGED:
                    if (mClock != null) {
                        mCallback.onAppIconChanged(mClock.getPackageName(), Process.myUserHandle());
                    }
                    // follow through
                case ACTION_DATE_CHANGED:
                case ACTION_TIME_CHANGED:
                    if (mCalendar != null) {
                        for (UserHandle user
                                : context.getSystemService(UserManager.class).getUserProfiles()) {
                            mCallback.onAppIconChanged(mCalendar.getPackageName(), user);
                        }
                    }
                    break;
            }
        }

        @Override
        public void close() {
            try {
                mContext.unregisterReceiver(this);
            } catch (Exception ignored) { }
        }
    }

    /**
     * Listener for receiving icon changes
     */
    public interface IconChangeListener {

        /**
         * Called when the icon for a particular app changes
         */
        void onAppIconChanged(String packageName, UserHandle user);
    }
}