am 00ed85a3: Merge "Listen for ACTION_CONFIGURATION_CHANGED for an mcc change to reload AllApps" into ics-mr0
* commit '00ed85a3d613b02e3abf9f37c298661b92f3200e': Listen for ACTION_CONFIGURATION_CHANGED for an mcc change to reload AllApps
This commit is contained in:
@@ -58,6 +58,7 @@ public class LauncherApplication extends Application {
|
|||||||
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
|
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
|
||||||
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
|
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
|
||||||
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
|
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
||||||
registerReceiver(mModel, filter);
|
registerReceiver(mModel, filter);
|
||||||
filter = new IntentFilter();
|
filter = new IntentFilter();
|
||||||
filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
|
filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.content.Intent.ShortcutIconResource;
|
|||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@@ -120,6 +121,8 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
private static int mCellCountX;
|
private static int mCellCountX;
|
||||||
private static int mCellCountY;
|
private static int mCellCountY;
|
||||||
|
|
||||||
|
protected Configuration mPreviousConfig;
|
||||||
|
|
||||||
public interface Callbacks {
|
public interface Callbacks {
|
||||||
public boolean setLoadOnResume();
|
public boolean setLoadOnResume();
|
||||||
public int getCurrentWorkspaceScreen();
|
public int getCurrentWorkspaceScreen();
|
||||||
@@ -146,9 +149,10 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
mDefaultIcon = Utilities.createIconBitmap(
|
mDefaultIcon = Utilities.createIconBitmap(
|
||||||
mIconCache.getFullResDefaultActivityIcon(), app);
|
mIconCache.getFullResDefaultActivityIcon(), app);
|
||||||
|
|
||||||
mAllAppsLoadDelay = app.getResources().getInteger(R.integer.config_allAppsBatchLoadDelay);
|
final Resources res = app.getResources();
|
||||||
|
mAllAppsLoadDelay = res.getInteger(R.integer.config_allAppsBatchLoadDelay);
|
||||||
mBatchSize = app.getResources().getInteger(R.integer.config_allAppsBatchSize);
|
mBatchSize = res.getInteger(R.integer.config_allAppsBatchSize);
|
||||||
|
mPreviousConfig = res.getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap getFallbackIcon() {
|
public Bitmap getFallbackIcon() {
|
||||||
@@ -612,14 +616,20 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
enqueuePackageUpdated(new PackageUpdatedTask(
|
enqueuePackageUpdated(new PackageUpdatedTask(
|
||||||
PackageUpdatedTask.OP_UNAVAILABLE, packages));
|
PackageUpdatedTask.OP_UNAVAILABLE, packages));
|
||||||
} else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
|
} else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
|
||||||
// If we have changed locale we need to clear out the labels in all apps.
|
// If we have changed locale we need to clear out the labels in all apps/workspace.
|
||||||
// Do this here because if the launcher activity is running it will be restarted.
|
forceReload();
|
||||||
// If it's not running startLoaderFromBackground will merely tell it that it needs
|
} else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
|
||||||
// to reload. Either way, mAllAppsLoaded will be cleared so it re-reads everything
|
// Check if configuration change was an mcc/mnc change which would affect app resources
|
||||||
// next time.
|
// and we would need to clear out the labels in all apps/workspace. Same handling as
|
||||||
mAllAppsLoaded = false;
|
// above for ACTION_LOCALE_CHANGED
|
||||||
mWorkspaceLoaded = false;
|
Configuration currentConfig = context.getResources().getConfiguration();
|
||||||
startLoaderFromBackground();
|
if((mPreviousConfig.diff(currentConfig) & ActivityInfo.CONFIG_MCC) != 0){
|
||||||
|
Log.d(TAG, "Reload apps on config change. curr_mcc:"
|
||||||
|
+ currentConfig.mcc + " prevmcc:" + mPreviousConfig.mcc);
|
||||||
|
forceReload();
|
||||||
|
}
|
||||||
|
// Update previousConfig
|
||||||
|
mPreviousConfig = currentConfig;
|
||||||
} else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action) ||
|
} else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action) ||
|
||||||
SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED.equals(action)) {
|
SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED.equals(action)) {
|
||||||
if (mCallbacks != null) {
|
if (mCallbacks != null) {
|
||||||
@@ -631,6 +641,20 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void forceReload() {
|
||||||
|
synchronized (mLock) {
|
||||||
|
// Stop any existing loaders first, so they don't set mAllAppsLoaded or
|
||||||
|
// mWorkspaceLoaded to true later
|
||||||
|
stopLoaderLocked();
|
||||||
|
mAllAppsLoaded = false;
|
||||||
|
mWorkspaceLoaded = false;
|
||||||
|
}
|
||||||
|
// Do this here because if the launcher activity is running it will be restarted.
|
||||||
|
// If it's not running startLoaderFromBackground will merely tell it that it needs
|
||||||
|
// to reload.
|
||||||
|
startLoaderFromBackground();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the launcher is in the background, it's possible for it to miss paired
|
* When the launcher is in the background, it's possible for it to miss paired
|
||||||
* configuration changes. So whenever we trigger the loader from the background
|
* configuration changes. So whenever we trigger the loader from the background
|
||||||
@@ -653,6 +677,20 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is already a loader task running, tell it to stop.
|
||||||
|
// returns true if isLaunching() was true on the old task
|
||||||
|
private boolean stopLoaderLocked() {
|
||||||
|
boolean isLaunching = false;
|
||||||
|
LoaderTask oldTask = mLoaderTask;
|
||||||
|
if (oldTask != null) {
|
||||||
|
if (oldTask.isLaunching()) {
|
||||||
|
isLaunching = true;
|
||||||
|
}
|
||||||
|
oldTask.stopLocked();
|
||||||
|
}
|
||||||
|
return isLaunching;
|
||||||
|
}
|
||||||
|
|
||||||
public void startLoader(Context context, boolean isLaunching) {
|
public void startLoader(Context context, boolean isLaunching) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (DEBUG_LOADERS) {
|
if (DEBUG_LOADERS) {
|
||||||
@@ -662,14 +700,8 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
// Don't bother to start the thread if we know it's not going to do anything
|
// Don't bother to start the thread if we know it's not going to do anything
|
||||||
if (mCallbacks != null && mCallbacks.get() != null) {
|
if (mCallbacks != null && mCallbacks.get() != null) {
|
||||||
// If there is already one running, tell it to stop.
|
// If there is already one running, tell it to stop.
|
||||||
LoaderTask oldTask = mLoaderTask;
|
// also, don't downgrade isLaunching if we're already running
|
||||||
if (oldTask != null) {
|
isLaunching = isLaunching || stopLoaderLocked();
|
||||||
if (oldTask.isLaunching()) {
|
|
||||||
// don't downgrade isLaunching if we're already running
|
|
||||||
isLaunching = true;
|
|
||||||
}
|
|
||||||
oldTask.stopLocked();
|
|
||||||
}
|
|
||||||
mLoaderTask = new LoaderTask(context, isLaunching);
|
mLoaderTask = new LoaderTask(context, isLaunching);
|
||||||
sWorkerThread.setPriority(Thread.NORM_PRIORITY);
|
sWorkerThread.setPriority(Thread.NORM_PRIORITY);
|
||||||
sWorker.post(mLoaderTask);
|
sWorker.post(mLoaderTask);
|
||||||
@@ -721,10 +753,12 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
|
|
||||||
if (!mWorkspaceLoaded) {
|
if (!mWorkspaceLoaded) {
|
||||||
loadWorkspace();
|
loadWorkspace();
|
||||||
if (mStopped) {
|
synchronized (LoaderTask.this) {
|
||||||
return;
|
if (mStopped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mWorkspaceLoaded = true;
|
||||||
}
|
}
|
||||||
mWorkspaceLoaded = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind the workspace
|
// Bind the workspace
|
||||||
@@ -1289,10 +1323,12 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
if (!mAllAppsLoaded) {
|
if (!mAllAppsLoaded) {
|
||||||
loadAllAppsByBatch();
|
loadAllAppsByBatch();
|
||||||
if (mStopped) {
|
synchronized (LoaderTask.this) {
|
||||||
return;
|
if (mStopped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mAllAppsLoaded = true;
|
||||||
}
|
}
|
||||||
mAllAppsLoaded = true;
|
|
||||||
} else {
|
} else {
|
||||||
onlyBindAllApps();
|
onlyBindAllApps();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user