Fix issue #3405731: Manage applications app names don't update with locale
Change-Id: Ia7dcf7973bde6785afb5978ee2a7858bc6740582
This commit is contained in:
@@ -5,11 +5,14 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageStatsObserver;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageStats;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
@@ -200,6 +203,7 @@ public class ApplicationsState {
|
||||
|
||||
// Information about all applications. Synchronize on mAppEntries
|
||||
// to protect access to these.
|
||||
final InterestingConfigChanges mInterestingConfigChanges = new InterestingConfigChanges();
|
||||
final HashMap<String, AppEntry> mEntriesMap = new HashMap<String, AppEntry>();
|
||||
final ArrayList<AppEntry> mAppEntries = new ArrayList<AppEntry>();
|
||||
List<ApplicationInfo> mApplications = new ArrayList<ApplicationInfo>();
|
||||
@@ -376,9 +380,18 @@ public class ApplicationsState {
|
||||
if (mApplications == null) {
|
||||
mApplications = new ArrayList<ApplicationInfo>();
|
||||
}
|
||||
|
||||
if (mInterestingConfigChanges.applyNewConfig(mContext.getResources())) {
|
||||
// If an interesting part of the configuration has changed, we
|
||||
// should completely reload the app entries.
|
||||
mEntriesMap.clear();
|
||||
mAppEntries.clear();
|
||||
} else {
|
||||
for (int i=0; i<mAppEntries.size(); i++) {
|
||||
mAppEntries.get(i).sizeStale = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<mApplications.size(); i++) {
|
||||
final ApplicationInfo info = mApplications.get(i);
|
||||
final AppEntry entry = mEntriesMap.get(info.packageName);
|
||||
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
|
||||
class InterestingConfigChanges {
|
||||
final Configuration mLastConfiguration = new Configuration();
|
||||
int mLastDensity;
|
||||
|
||||
boolean applyNewConfig(Resources res) {
|
||||
int configChanges = mLastConfiguration.updateFrom(res.getConfiguration());
|
||||
boolean densityChanged = mLastDensity != res.getDisplayMetrics().densityDpi;
|
||||
if (densityChanged || (configChanges&(ActivityInfo.CONFIG_LOCALE
|
||||
|ActivityInfo.CONFIG_UI_MODE|ActivityInfo.CONFIG_SCREEN_LAYOUT)) != 0) {
|
||||
mLastDensity = res.getDisplayMetrics().densityDpi;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -34,7 +34,6 @@ import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
@@ -54,9 +53,10 @@ public class RunningState {
|
||||
static Object sGlobalLock = new Object();
|
||||
static RunningState sInstance;
|
||||
|
||||
static final int MSG_UPDATE_CONTENTS = 1;
|
||||
static final int MSG_REFRESH_UI = 2;
|
||||
static final int MSG_UPDATE_TIME = 3;
|
||||
static final int MSG_RESET_CONTENTS = 1;
|
||||
static final int MSG_UPDATE_CONTENTS = 2;
|
||||
static final int MSG_REFRESH_UI = 3;
|
||||
static final int MSG_UPDATE_TIME = 4;
|
||||
|
||||
static final long TIME_UPDATE_DELAY = 1000;
|
||||
static final long CONTENTS_UPDATE_DELAY = 2000;
|
||||
@@ -69,6 +69,8 @@ public class RunningState {
|
||||
|
||||
OnRefreshUiListener mRefreshUiListener;
|
||||
|
||||
final InterestingConfigChanges mInterestingConfigChanges = new InterestingConfigChanges();
|
||||
|
||||
// Processes that are hosting a service we are interested in, organized
|
||||
// by uid and name. Note that this mapping does not change even across
|
||||
// service restarts, and during a restart there will still be a process
|
||||
@@ -133,6 +135,9 @@ public class RunningState {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_RESET_CONTENTS:
|
||||
reset();
|
||||
break;
|
||||
case MSG_UPDATE_CONTENTS:
|
||||
synchronized (mLock) {
|
||||
if (!mResumed) {
|
||||
@@ -561,6 +566,12 @@ public class RunningState {
|
||||
synchronized (mLock) {
|
||||
mResumed = true;
|
||||
mRefreshUiListener = listener;
|
||||
if (mInterestingConfigChanges.applyNewConfig(mApplicationContext.getResources())) {
|
||||
mHaveData = false;
|
||||
mBackgroundHandler.removeMessages(MSG_RESET_CONTENTS);
|
||||
mBackgroundHandler.removeMessages(MSG_UPDATE_CONTENTS);
|
||||
mBackgroundHandler.sendEmptyMessage(MSG_RESET_CONTENTS);
|
||||
}
|
||||
if (!mBackgroundHandler.hasMessages(MSG_UPDATE_CONTENTS)) {
|
||||
mBackgroundHandler.sendEmptyMessage(MSG_UPDATE_CONTENTS);
|
||||
}
|
||||
@@ -613,6 +624,15 @@ public class RunningState {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
mServiceProcessesByName.clear();
|
||||
mServiceProcessesByPid.clear();
|
||||
mInterestingProcesses.clear();
|
||||
mRunningProcesses.clear();
|
||||
mProcessItems.clear();
|
||||
mAllProcessItems.clear();
|
||||
}
|
||||
|
||||
private boolean update(Context context, ActivityManager am) {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
|
||||
@@ -975,7 +995,7 @@ public class RunningState {
|
||||
}
|
||||
|
||||
if (newBackgroundItems == null) {
|
||||
// One or more at the bottom may no longer exit.
|
||||
// One or more at the bottom may no longer exist.
|
||||
if (mBackgroundItems.size() > numBackgroundProcesses) {
|
||||
newBackgroundItems = new ArrayList<MergedItem>(numBackgroundProcesses);
|
||||
for (int bgi=0; bgi<numBackgroundProcesses; bgi++) {
|
||||
|
Reference in New Issue
Block a user