Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of Neo Launcher
* Copyright (c) 2022 Neo Launcher Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.neoapps.neolauncher.util

import android.content.pm.LauncherActivityInfo
import com.android.launcher3.dagger.LauncherAppSingleton
import com.android.launcher3.icons.cache.LauncherActivityCachingLogic
import com.android.launcher3.util.ComponentKey
import com.android.launcher3.util.SafeCloseable
import com.neoapps.neolauncher.preferences.NeoPrefs

@LauncherAppSingleton
class CustomActivityCachingLogic : LauncherActivityCachingLogic() {
private val prefs = NeoPrefs.getInstance()

override fun getLabel(info: LauncherActivityInfo): CharSequence? {
val key = ComponentKey(info.componentName, info.user)
val customLabel = prefs.customAppName[key]
if (!customLabel.isNullOrEmpty()) {
return customLabel
}
return super.getLabel(info)
}
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ android {
javaCompileOptions.annotationProcessorOptions.arguments["dagger.hilt.disableModulesHaveInstallInCheck"] =
"true"
versionName = "1.0.1"
versionCode = 1006
versionCode = 1007
buildConfigField("String", "BUILD_DATE", "\"${getBuildDate()}\"")
buildConfigField("boolean", "ENABLE_AUTO_INSTALLS_LAYOUT", "false")
buildConfigField("boolean", "IS_DEBUG_DEVICE", "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import com.android.launcher3.icons.BaseIconFactory.IconOptions
import com.android.launcher3.icons.BitmapInfo
import com.android.launcher3.icons.IconProvider

object LauncherActivityCachingLogic : CachingLogic<LauncherActivityInfo> {
const val TAG = "LauncherActivityCachingLogic"
open class LauncherActivityCachingLogic : CachingLogic<LauncherActivityInfo> {

Comment on lines +30 to 31
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactor changes LauncherActivityCachingLogic from a Kotlin object to a class, which removes the singleton value that existing call sites rely on (e.g., Java .INSTANCE and Kotlin usages that pass LauncherActivityCachingLogic as a CachingLogic). To avoid widespread breakage, consider keeping a singleton object LauncherActivityCachingLogic for the default behavior and introducing a separate open base class for extension (or update all call sites/tests to instantiate/pass a shared instance explicitly).

Copilot uses AI. Check for mistakes.
override fun getComponent(info: LauncherActivityInfo): ComponentName = info.componentName

Expand Down Expand Up @@ -73,4 +72,8 @@ object LauncherActivityCachingLogic : CachingLogic<LauncherActivityInfo> {
item: LauncherActivityInfo,
provider: IconProvider,
): String? = provider.getStateForApp(getApplicationInfo(item))

companion object{
const val TAG = "LauncherActivityCachingLogic"
}
}
15 changes: 8 additions & 7 deletions src/com/android/launcher3/icons/IconCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import com.android.launcher3.widget.WidgetSections;
import com.android.launcher3.widget.WidgetSections.WidgetSection;
import com.neoapps.neolauncher.icons.CustomIconProvider;
import com.neoapps.neolauncher.util.CustomActivityCachingLogic;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -168,7 +169,7 @@ public synchronized void updateIconsForPkg(@NonNull final String packageName,
removeIconsForPkg(packageName, user);
long userSerial = mUserManager.getSerialNumberForUser(user);
for (LauncherActivityInfo app : apps) {
addIconToDBAndMemCache(app, LauncherActivityCachingLogic.INSTANCE, userSerial);
addIconToDBAndMemCache(app, new CustomActivityCachingLogic(), userSerial);
}
Comment on lines 171 to 173
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All usages of LauncherActivityCachingLogic were replaced, so import com.android.launcher3.icons.cache.LauncherActivityCachingLogic; is now unused in this Java file and will fail compilation. Remove the unused import (or keep using the base logic where appropriate).

Copilot uses AI. Check for mistakes.
Comment on lines 169 to 173
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IconCache is in the main source set, but it now depends on com.neoapps.neolauncher.util.CustomActivityCachingLogic which is only present in the omega flavor (Omega/src). This will fail to compile for the aosp variant. Please keep main flavor-agnostic (use the base caching logic there) and apply the Neo-specific logic via omega-only sources or an injected/factory-provided CachingLogic implementation.

Copilot uses AI. Check for mistakes.
}

Expand Down Expand Up @@ -239,7 +240,7 @@ private void onIconRequestEnd() {
*/
public synchronized void updateTitleAndIcon(AppInfo application) {
CacheEntry entry = cacheLocked(application.componentName,
application.user, () -> null, LauncherActivityCachingLogic.INSTANCE,
application.user, () -> null, new CustomActivityCachingLogic(),
application.getMatchingLookupFlag());
if (entry.bitmap != null || !isDefaultIcon(entry.bitmap, application.user)) {
applyCacheEntry(entry, application);
Expand Down Expand Up @@ -389,7 +390,7 @@ public synchronized void getTitleAndIcon(
@NonNull Supplier<LauncherActivityInfo> activityInfoProvider,
@NonNull CacheLookupFlag lookupFlag) {
CacheEntry entry = cacheLocked(infoInOut.getTargetComponent(), infoInOut.user,
activityInfoProvider, LauncherActivityCachingLogic.INSTANCE, lookupFlag);
activityInfoProvider, new CustomActivityCachingLogic(), lookupFlag);
applyCacheEntry(entry, infoInOut);
}

Expand Down Expand Up @@ -490,7 +491,7 @@ private <T extends ItemInfoWithIcon> void loadIconSubsection(
cn,
/* user = */ sectionKey.first,
() -> duplicateIconRequests.get(0).launcherActivityInfo,
LauncherActivityCachingLogic.INSTANCE,
new CustomActivityCachingLogic(),
sectionKey.second,
c);

Expand Down Expand Up @@ -539,7 +540,7 @@ private <T extends ItemInfoWithIcon> void loadIconSubsection(
loadFallbackIcon(
lai,
entry,
LauncherActivityCachingLogic.INSTANCE,
new CustomActivityCachingLogic(),
DEFAULT_LOOKUP_FLAG.withUsePackageIcon(false),
/* usePackageTitle= */ loadFallbackTitle,
cn,
Expand All @@ -549,7 +550,7 @@ private <T extends ItemInfoWithIcon> void loadIconSubsection(
loadFallbackTitle(
lai,
entry,
LauncherActivityCachingLogic.INSTANCE,
new CustomActivityCachingLogic(),
sectionKey.first);
}

Expand Down Expand Up @@ -643,7 +644,7 @@ public void updateSessionCache(PackageUserKey key, PackageInstaller.SessionInfo
@VisibleForTesting
synchronized boolean isItemInDb(ComponentKey cacheKey) {
return getEntryFromDBLocked(cacheKey, new CacheEntry(), DEFAULT_LOOKUP_FLAG,
LauncherActivityCachingLogic.INSTANCE);
new CustomActivityCachingLogic());
}

/**
Expand Down
27 changes: 16 additions & 11 deletions src/com/android/launcher3/model/LoaderTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
import com.android.launcher3.util.UserIconInfo;
import com.android.launcher3.widget.WidgetInflater;
import com.android.launcher3.widget.util.WidgetSizeHandler;
import com.neoapps.neolauncher.util.CustomActivityCachingLogic;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -254,20 +255,24 @@ private void sendFirstScreenActiveInstallsBroadcast() {
.collect(Collectors.toList());
boolean shouldAttachArchivingExtras = mIsRestoreFromBackup
&& !mSettingsCache.getValue(DISABLE_INSTALLED_APPS_BROADCAST);
if (Utilities.ATLEAST_V) {
List<FirstScreenBroadcastModel> broadcastModels =
mFirstScreenBroadcastHelper.createModelsForFirstScreenBroadcast(
firstScreenItems,
mInstallingPkgsCached,
mBgDataModel.itemsIdMap.stream().filter(WIDGET_FILTER).collect(Collectors.toList()),
shouldAttachArchivingExtras
);
logASplit("Sending first screen broadcast with shouldAttachArchivingExtras="
+ shouldAttachArchivingExtras);
if (shouldAttachArchivingExtras) {
List<FirstScreenBroadcastModel> broadcastModels =
mFirstScreenBroadcastHelper.createModelsForFirstScreenBroadcast(
firstScreenItems,
mInstallingPkgsCached,
mBgDataModel.itemsIdMap.stream().filter(WIDGET_FILTER).collect(Collectors.toList()),
shouldAttachArchivingExtras
);
logASplit("Sending first screen broadcast with shouldAttachArchivingExtras="
+ shouldAttachArchivingExtras);
broadcastModels.forEach(bm -> bm.sentBroadcast(mContext));
} else {
logASplit("Sending first screen broadcast");
//mFirstScreenBroadcastHelper.sendBroadcasts(mContext, firstScreenItems);
}
Comment on lines +258 to 272
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else-branch no longer sends any first-screen broadcast (the call is commented out), so pending installs won’t be reported unless shouldAttachArchivingExtras is true. Previously the broadcast was still sent with shouldAttachArchivingExtras=false to report pending items only. Consider always creating/sending the FirstScreenBroadcastModels and using shouldAttachArchivingExtras only to control which extras are attached, and remove the dead commented-out call.

Suggested change
if (shouldAttachArchivingExtras) {
List<FirstScreenBroadcastModel> broadcastModels =
mFirstScreenBroadcastHelper.createModelsForFirstScreenBroadcast(
firstScreenItems,
mInstallingPkgsCached,
mBgDataModel.itemsIdMap.stream().filter(WIDGET_FILTER).collect(Collectors.toList()),
shouldAttachArchivingExtras
);
logASplit("Sending first screen broadcast with shouldAttachArchivingExtras="
+ shouldAttachArchivingExtras);
broadcastModels.forEach(bm -> bm.sentBroadcast(mContext));
} else {
logASplit("Sending first screen broadcast");
//mFirstScreenBroadcastHelper.sendBroadcasts(mContext, firstScreenItems);
}
List<FirstScreenBroadcastModel> broadcastModels =
mFirstScreenBroadcastHelper.createModelsForFirstScreenBroadcast(
firstScreenItems,
mInstallingPkgsCached,
mBgDataModel.itemsIdMap.stream()
.filter(WIDGET_FILTER)
.collect(Collectors.toList()),
shouldAttachArchivingExtras
);
if (shouldAttachArchivingExtras) {
logASplit("Sending first screen broadcast with shouldAttachArchivingExtras=true");
} else {
logASplit("Sending first screen broadcast with shouldAttachArchivingExtras=false");
}
broadcastModels.forEach(bm -> bm.sentBroadcast(mContext));

Copilot uses AI. Check for mistakes.
}


private void loadAllSurfacesOrdered(
LoaderMemoryLogger memoryLogger, LauncherRestoreEventLogger restoreEventLogger) {

Expand Down Expand Up @@ -330,7 +335,7 @@ private void loadAllSurfacesOrdered(
IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
setIgnorePackages(updateHandler);
updateHandler.updateIcons(allActivityList,
LauncherActivityCachingLogic.INSTANCE,
new CustomActivityCachingLogic(),
mModel::onPackageIconsUpdated);
Comment on lines 337 to 339
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After switching to CustomActivityCachingLogic, this file no longer references LauncherActivityCachingLogic, so the existing import com.android.launcher3.icons.cache.LauncherActivityCachingLogic; becomes unused and will fail Java compilation. Please remove the unused import (or reintroduce a reference if still needed).

Copilot uses AI. Check for mistakes.
Comment on lines 337 to 339
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CustomActivityCachingLogic lives under the omega flavor source set (Omega/src), but LoaderTask.java is in the main source set. This import/usage will break compilation for the aosp variant. Either move the caching-logic implementation into main, or keep main using the base LauncherActivityCachingLogic and override the behavior from the omega source set (e.g., via a flavor-specific subclass/factory/DI binding).

Copilot uses AI. Check for mistakes.
logASplit("update AllApps icon cache finished");

Expand Down