Data usage performance, bugfixes.

Optimize launch times by removing unneeded extra work, including
reloading data and tightening chart invalidation.  Fix invalidation
storm when sweeps overlap.  Move chart history into loader instead of
blocking main thread.

Disable "Split 4G" mode until telephony support is ready, and combine
any existing split policies.

Async loading of application details.  Remove alpha transitions to
speed up on some hardware.  Hide menus in detail mode.  Delay kicking
off force-poll.  Fix inset padding on large devices.

Bug: 5284321, 5273918, 5263056
Change-Id: I746d79c05e2a6ea97bbdbdc5d807e208328d1373
This commit is contained in:
Jeff Sharkey
2011-09-11 17:29:49 -07:00
parent a3fb4572dd
commit b98c55bd09
16 changed files with 663 additions and 262 deletions

View File

@@ -0,0 +1,110 @@
/*
* 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.net;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.net.TrafficStats;
import android.text.TextUtils;
import android.util.SparseArray;
import com.android.settings.R;
public class UidDetailProvider {
private final Context mContext;
private final SparseArray<UidDetail> mUidDetailCache;
public UidDetailProvider(Context context) {
mContext = context.getApplicationContext();
mUidDetailCache = new SparseArray<UidDetail>();
}
public void clearCache() {
mUidDetailCache.clear();
}
/**
* Resolve best descriptive label for the given UID.
*/
public UidDetail getUidDetail(int uid, boolean blocking) {
final UidDetail cached = mUidDetailCache.get(uid);
if (cached != null) {
return cached;
} else if (!blocking) {
return null;
}
final Resources res = mContext.getResources();
final PackageManager pm = mContext.getPackageManager();
final UidDetail detail = new UidDetail();
detail.label = pm.getNameForUid(uid);
detail.icon = pm.getDefaultActivityIcon();
// handle special case labels
switch (uid) {
case android.os.Process.SYSTEM_UID:
detail.label = res.getString(R.string.process_kernel_label);
detail.icon = pm.getDefaultActivityIcon();
mUidDetailCache.put(uid, detail);
return detail;
case TrafficStats.UID_REMOVED:
detail.label = res.getString(R.string.data_usage_uninstalled_apps);
detail.icon = pm.getDefaultActivityIcon();
mUidDetailCache.put(uid, detail);
return detail;
}
// otherwise fall back to using packagemanager labels
final String[] packageNames = pm.getPackagesForUid(uid);
final int length = packageNames != null ? packageNames.length : 0;
try {
if (length == 1) {
final ApplicationInfo info = pm.getApplicationInfo(packageNames[0], 0);
detail.label = info.loadLabel(pm).toString();
detail.icon = info.loadIcon(pm);
} else if (length > 1) {
detail.detailLabels = new CharSequence[length];
for (int i = 0; i < length; i++) {
final String packageName = packageNames[i];
final PackageInfo packageInfo = pm.getPackageInfo(packageName, 0);
final ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0);
detail.detailLabels[i] = appInfo.loadLabel(pm).toString();
if (packageInfo.sharedUserLabel != 0) {
detail.label = pm.getText(packageName, packageInfo.sharedUserLabel,
packageInfo.applicationInfo).toString();
detail.icon = appInfo.loadIcon(pm);
}
}
}
} catch (NameNotFoundException e) {
}
if (TextUtils.isEmpty(detail.label)) {
detail.label = Integer.toString(uid);
}
mUidDetailCache.put(uid, detail);
return detail;
}
}