Merge change 3939 into donut
* changes: Tweak thread priorities in Home to make first boot experience a little better.
This commit is contained in:
commit
3003fb8214
|
@ -126,7 +126,7 @@ public class LauncherModel {
|
|||
mApplicationsLoaded = false;
|
||||
|
||||
if (!isLaunching) {
|
||||
startApplicationsLoader(launcher);
|
||||
startApplicationsLoader(launcher, 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");
|
||||
|
||||
stopAndWaitForApplicationsLoader();
|
||||
|
||||
mApplicationsLoader = new ApplicationsLoader(launcher);
|
||||
mApplicationsLoader = new ApplicationsLoader(launcher, isLaunching);
|
||||
mApplicationsLoaderThread = new Thread(mApplicationsLoader, "Applications Loader");
|
||||
mApplicationsLoaderThread.start();
|
||||
}
|
||||
|
||||
synchronized void addPackage(Launcher launcher, String packageName) {
|
||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||
startApplicationsLoader(launcher);
|
||||
startApplicationsLoader(launcher, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class LauncherModel {
|
|||
synchronized void removePackage(Launcher launcher, String packageName) {
|
||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||
dropApplicationCache(); // TODO: this could be optimized
|
||||
startApplicationsLoader(launcher);
|
||||
startApplicationsLoader(launcher, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class LauncherModel {
|
|||
|
||||
synchronized void updatePackage(Launcher launcher, String packageName) {
|
||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||
startApplicationsLoader(launcher);
|
||||
startApplicationsLoader(launcher, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ public class LauncherModel {
|
|||
|
||||
synchronized void syncPackage(Launcher launcher, String packageName) {
|
||||
if (mApplicationsLoader != null && mApplicationsLoader.isRunning()) {
|
||||
startApplicationsLoader(launcher);
|
||||
startApplicationsLoader(launcher, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -461,8 +461,10 @@ public class LauncherModel {
|
|||
|
||||
private volatile boolean mStopped;
|
||||
private volatile boolean mRunning;
|
||||
private final boolean mIsLaunching;
|
||||
|
||||
ApplicationsLoader(Launcher launcher) {
|
||||
ApplicationsLoader(Launcher launcher, boolean isLaunching) {
|
||||
mIsLaunching = isLaunching;
|
||||
mLauncher = new WeakReference<Launcher>(launcher);
|
||||
}
|
||||
|
||||
|
@ -477,7 +479,10 @@ public class LauncherModel {
|
|||
public void run() {
|
||||
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);
|
||||
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
|
@ -580,7 +585,7 @@ public class LauncherModel {
|
|||
|
||||
if (isLaunching && isDesktopLoaded()) {
|
||||
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
|
||||
launcher.onDesktopItemsLoaded();
|
||||
return;
|
||||
|
@ -607,7 +612,8 @@ public class LauncherModel {
|
|||
|
||||
if (DEBUG_LOADERS) d(LOG_TAG, " --> starting workspace loader");
|
||||
mDesktopItemsLoaded = false;
|
||||
mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged, loadApplications);
|
||||
mDesktopItemsLoader = new DesktopItemsLoader(launcher, localeChanged, loadApplications,
|
||||
isLaunching);
|
||||
mDesktopLoaderThread = new Thread(mDesktopItemsLoader, "Desktop Items Loader");
|
||||
mDesktopLoaderThread.start();
|
||||
}
|
||||
|
@ -688,9 +694,12 @@ public class LauncherModel {
|
|||
private final WeakReference<Launcher> mLauncher;
|
||||
private final boolean mLocaleChanged;
|
||||
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;
|
||||
mIsLaunching = isLaunching;
|
||||
mLauncher = new WeakReference<Launcher>(launcher);
|
||||
mLocaleChanged = localeChanged;
|
||||
}
|
||||
|
@ -706,6 +715,8 @@ public class LauncherModel {
|
|||
public void run() {
|
||||
mRunning = true;
|
||||
|
||||
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
|
||||
|
||||
final Launcher launcher = mLauncher.get();
|
||||
final ContentResolver contentResolver = launcher.getContentResolver();
|
||||
final PackageManager manager = launcher.getPackageManager();
|
||||
|
@ -912,7 +923,7 @@ public class LauncherModel {
|
|||
launcher.onDesktopItemsLoaded();
|
||||
}
|
||||
});
|
||||
if (mLoadApplications) startApplicationsLoader(launcher);
|
||||
if (mLoadApplications) startApplicationsLoader(launcher, mIsLaunching);
|
||||
}
|
||||
|
||||
if (!mStopped) {
|
||||
|
|
Loading…
Reference in New Issue