am 3003fb82: Merge change 3939 into donut
Merge commit '3003fb8214e512ee7b8eb62b10b7446177e0682c' * commit '3003fb8214e512ee7b8eb62b10b7446177e0682c': Tweak thread priorities in Home to make first boot experience a little better.
This commit is contained in:
commit
d16cd03e41
|
@ -116,7 +116,7 @@ public class LauncherModel {
|
||||||
|
|
||||||
if (localeChanged) {
|
if (localeChanged) {
|
||||||
dropApplicationCache();
|
dropApplicationCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mApplicationsAdapter == null || isLaunching || localeChanged) {
|
if (mApplicationsAdapter == null || isLaunching || localeChanged) {
|
||||||
mApplications = new ArrayList<ApplicationInfo>(DEFAULT_APPLICATIONS_NUMBER);
|
mApplications = new ArrayList<ApplicationInfo>(DEFAULT_APPLICATIONS_NUMBER);
|
||||||
|
@ -126,7 +126,7 @@ public class LauncherModel {
|
||||||
mApplicationsLoaded = false;
|
mApplicationsLoaded = false;
|
||||||
|
|
||||||
if (!isLaunching) {
|
if (!isLaunching) {
|
||||||
startApplicationsLoader(launcher);
|
startApplicationsLoader(launcher, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,19 +148,19 @@ public class LauncherModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void startApplicationsLoader(Launcher launcher) {
|
private synchronized void startApplicationsLoader(Launcher launcher, boolean isLaunching) {
|
||||||
if (DEBUG_LOADERS) d(LOG_TAG, " --> starting applications loader");
|
if (DEBUG_LOADERS) d(LOG_TAG, " --> starting applications loader");
|
||||||
|
|
||||||
stopAndWaitForApplicationsLoader();
|
stopAndWaitForApplicationsLoader();
|
||||||
|
|
||||||
mApplicationsLoader = new ApplicationsLoader(launcher);
|
mApplicationsLoader = new ApplicationsLoader(launcher, isLaunching);
|
||||||
mApplicationsLoaderThread = new Thread(mApplicationsLoader, "Applications Loader");
|
mApplicationsLoaderThread = new Thread(mApplicationsLoader, "Applications Loader");
|
||||||
mApplicationsLoaderThread.start();
|
mApplicationsLoaderThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void addPackage(Launcher launcher, String packageName) {
|
synchronized void addPackage(Launcher launcher, String packageName) {
|
||||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||||
startApplicationsLoader(launcher);
|
startApplicationsLoader(launcher, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ public class LauncherModel {
|
||||||
synchronized void removePackage(Launcher launcher, String packageName) {
|
synchronized void removePackage(Launcher launcher, String packageName) {
|
||||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||||
dropApplicationCache(); // TODO: this could be optimized
|
dropApplicationCache(); // TODO: this could be optimized
|
||||||
startApplicationsLoader(launcher);
|
startApplicationsLoader(launcher, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ public class LauncherModel {
|
||||||
|
|
||||||
synchronized void updatePackage(Launcher launcher, String packageName) {
|
synchronized void updatePackage(Launcher launcher, String packageName) {
|
||||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||||
startApplicationsLoader(launcher);
|
startApplicationsLoader(launcher, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ public class LauncherModel {
|
||||||
|
|
||||||
synchronized void syncPackage(Launcher launcher, String packageName) {
|
synchronized void syncPackage(Launcher launcher, String packageName) {
|
||||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||||
startApplicationsLoader(launcher);
|
startApplicationsLoader(launcher, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,8 +461,10 @@ public class LauncherModel {
|
||||||
|
|
||||||
private volatile boolean mStopped;
|
private volatile boolean mStopped;
|
||||||
private volatile boolean mRunning;
|
private volatile boolean mRunning;
|
||||||
|
private final boolean mIsLaunching;
|
||||||
|
|
||||||
ApplicationsLoader(Launcher launcher) {
|
ApplicationsLoader(Launcher launcher, boolean isLaunching) {
|
||||||
|
mIsLaunching = isLaunching;
|
||||||
mLauncher = new WeakReference<Launcher>(launcher);
|
mLauncher = new WeakReference<Launcher>(launcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +479,10 @@ public class LauncherModel {
|
||||||
public void run() {
|
public void run() {
|
||||||
mRunning = true;
|
mRunning = true;
|
||||||
|
|
||||||
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
// Elevate priority when Home launches for the first time to avoid
|
||||||
|
// starving at boot time. Staring at a blank home is not cool.
|
||||||
|
android.os.Process.setThreadPriority(mIsLaunching ? Process.THREAD_PRIORITY_DEFAULT :
|
||||||
|
Process.THREAD_PRIORITY_BACKGROUND);
|
||||||
|
|
||||||
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
|
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||||
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
|
@ -580,7 +585,7 @@ public class LauncherModel {
|
||||||
|
|
||||||
if (isLaunching && isDesktopLoaded()) {
|
if (isLaunching && isDesktopLoaded()) {
|
||||||
if (DEBUG_LOADERS) d(LOG_TAG, " --> items loaded, return");
|
if (DEBUG_LOADERS) d(LOG_TAG, " --> items loaded, return");
|
||||||
if (loadApplications) startApplicationsLoader(launcher);
|
if (loadApplications) startApplicationsLoader(launcher, true);
|
||||||
// We have already loaded our data from the DB
|
// We have already loaded our data from the DB
|
||||||
launcher.onDesktopItemsLoaded();
|
launcher.onDesktopItemsLoaded();
|
||||||
return;
|
return;
|
||||||
|
@ -607,7 +612,8 @@ public class LauncherModel {
|
||||||
|
|
||||||
if (DEBUG_LOADERS) d(LOG_TAG, " --> starting workspace loader");
|
if (DEBUG_LOADERS) d(LOG_TAG, " --> starting workspace loader");
|
||||||
mDesktopItemsLoaded = false;
|
mDesktopItemsLoaded = false;
|
||||||
mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged, loadApplications);
|
mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged, loadApplications,
|
||||||
|
isLaunching);
|
||||||
mDesktopLoaderThread = new Thread(mDesktopItemsLoader, "Desktop Items Loader");
|
mDesktopLoaderThread = new Thread(mDesktopItemsLoader, "Desktop Items Loader");
|
||||||
mDesktopLoaderThread.start();
|
mDesktopLoaderThread.start();
|
||||||
}
|
}
|
||||||
|
@ -688,9 +694,12 @@ public class LauncherModel {
|
||||||
private final WeakReference<Launcher> mLauncher;
|
private final WeakReference<Launcher> mLauncher;
|
||||||
private final boolean mLocaleChanged;
|
private final boolean mLocaleChanged;
|
||||||
private final boolean mLoadApplications;
|
private final boolean mLoadApplications;
|
||||||
|
private final boolean mIsLaunching;
|
||||||
|
|
||||||
DesktopItemsLoader(Launcher launcher, boolean localeChanged, boolean loadApplications) {
|
DesktopItemsLoader(Launcher launcher, boolean localeChanged, boolean loadApplications,
|
||||||
|
boolean isLaunching) {
|
||||||
mLoadApplications = loadApplications;
|
mLoadApplications = loadApplications;
|
||||||
|
mIsLaunching = isLaunching;
|
||||||
mLauncher = new WeakReference<Launcher>(launcher);
|
mLauncher = new WeakReference<Launcher>(launcher);
|
||||||
mLocaleChanged = localeChanged;
|
mLocaleChanged = localeChanged;
|
||||||
}
|
}
|
||||||
|
@ -706,6 +715,8 @@ public class LauncherModel {
|
||||||
public void run() {
|
public void run() {
|
||||||
mRunning = true;
|
mRunning = true;
|
||||||
|
|
||||||
|
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
|
||||||
|
|
||||||
final Launcher launcher = mLauncher.get();
|
final Launcher launcher = mLauncher.get();
|
||||||
final ContentResolver contentResolver = launcher.getContentResolver();
|
final ContentResolver contentResolver = launcher.getContentResolver();
|
||||||
final PackageManager manager = launcher.getPackageManager();
|
final PackageManager manager = launcher.getPackageManager();
|
||||||
|
@ -912,7 +923,7 @@ public class LauncherModel {
|
||||||
launcher.onDesktopItemsLoaded();
|
launcher.onDesktopItemsLoaded();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (mLoadApplications) startApplicationsLoader(launcher);
|
if (mLoadApplications) startApplicationsLoader(launcher, mIsLaunching);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mStopped) {
|
if (!mStopped) {
|
||||||
|
@ -1076,7 +1087,7 @@ public class LauncherModel {
|
||||||
ArrayList<ItemInfo> getDesktopItems() {
|
ArrayList<ItemInfo> getDesktopItems() {
|
||||||
return mDesktopItems;
|
return mDesktopItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The current list of desktop items
|
* @return The current list of desktop items
|
||||||
*/
|
*/
|
||||||
|
@ -1092,7 +1103,7 @@ public class LauncherModel {
|
||||||
// TODO: write to DB; also check that folder has been added to folders list
|
// TODO: write to DB; also check that folder has been added to folders list
|
||||||
mDesktopItems.add(info);
|
mDesktopItems.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an item from the desktop
|
* Remove an item from the desktop
|
||||||
* @param info
|
* @param info
|
||||||
|
@ -1108,7 +1119,7 @@ public class LauncherModel {
|
||||||
void addDesktopAppWidget(LauncherAppWidgetInfo info) {
|
void addDesktopAppWidget(LauncherAppWidgetInfo info) {
|
||||||
mDesktopAppWidgets.add(info);
|
mDesktopAppWidgets.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a widget from the desktop
|
* Remove a widget from the desktop
|
||||||
*/
|
*/
|
||||||
|
@ -1126,7 +1137,7 @@ public class LauncherModel {
|
||||||
if (resolveInfo == null) {
|
if (resolveInfo == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ApplicationInfo info = new ApplicationInfo();
|
final ApplicationInfo info = new ApplicationInfo();
|
||||||
final ActivityInfo activityInfo = resolveInfo.activityInfo;
|
final ActivityInfo activityInfo = resolveInfo.activityInfo;
|
||||||
info.icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
|
info.icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
|
||||||
|
@ -1139,7 +1150,7 @@ public class LauncherModel {
|
||||||
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an ApplicationInfo object for a sortcut
|
* Make an ApplicationInfo object for a sortcut
|
||||||
*/
|
*/
|
||||||
|
@ -1195,7 +1206,7 @@ public class LauncherModel {
|
||||||
//noinspection SuspiciousMethodCalls
|
//noinspection SuspiciousMethodCalls
|
||||||
folder.contents.remove(info);
|
folder.contents.remove(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a UserFolder from the in-memory list of folders. Does not change the DB.
|
* Removes a UserFolder from the in-memory list of folders. Does not change the DB.
|
||||||
* @param userFolderInfo
|
* @param userFolderInfo
|
||||||
|
@ -1203,7 +1214,7 @@ public class LauncherModel {
|
||||||
void removeUserFolder(UserFolderInfo userFolderInfo) {
|
void removeUserFolder(UserFolderInfo userFolderInfo) {
|
||||||
mFolders.remove(userFolderInfo.id);
|
mFolders.remove(userFolderInfo.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an item to the DB if it was not created previously, or move it to a new
|
* Adds an item to the DB if it was not created previously, or move it to a new
|
||||||
* <container, screen, cellX, cellY>
|
* <container, screen, cellX, cellY>
|
||||||
|
@ -1218,7 +1229,7 @@ public class LauncherModel {
|
||||||
moveItemInDatabase(context, item, container, screen, cellX, cellY);
|
moveItemInDatabase(context, item, container, screen, cellX, cellY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move an item in the DB to a new <container, screen, cellX, cellY>
|
* Move an item in the DB to a new <container, screen, cellX, cellY>
|
||||||
*/
|
*/
|
||||||
|
@ -1228,7 +1239,7 @@ public class LauncherModel {
|
||||||
item.screen = screen;
|
item.screen = screen;
|
||||||
item.cellX = cellX;
|
item.cellX = cellX;
|
||||||
item.cellY = cellY;
|
item.cellY = cellY;
|
||||||
|
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
final ContentResolver cr = context.getContentResolver();
|
final ContentResolver cr = context.getContentResolver();
|
||||||
|
|
||||||
|
@ -1311,12 +1322,12 @@ public class LauncherModel {
|
||||||
item.screen = screen;
|
item.screen = screen;
|
||||||
item.cellX = cellX;
|
item.cellX = cellX;
|
||||||
item.cellY = cellY;
|
item.cellY = cellY;
|
||||||
|
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
final ContentResolver cr = context.getContentResolver();
|
final ContentResolver cr = context.getContentResolver();
|
||||||
|
|
||||||
item.onAddToDatabase(values);
|
item.onAddToDatabase(values);
|
||||||
|
|
||||||
Uri result = cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :
|
Uri result = cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :
|
||||||
LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);
|
LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);
|
||||||
|
|
||||||
|
@ -1356,7 +1367,7 @@ public class LauncherModel {
|
||||||
|
|
||||||
cr.update(LauncherSettings.Favorites.getContentUri(item.id, false), values, null, null);
|
cr.update(LauncherSettings.Favorites.getContentUri(item.id, false), values, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified item from the database
|
* Removes the specified item from the database
|
||||||
* @param context
|
* @param context
|
||||||
|
|
Loading…
Reference in New Issue