summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-08-15 17:28:36 -0700
committerDianne Hackborn <hackbod@google.com>2010-08-15 17:29:07 -0700
commitff3673c7f477b1d78e64a8bc28754552dcdc8826 (patch)
tree89465df36b08fb800f7097902ab68efecad203f1 /src/com/android
parentbe5994d20152c7194aac79eb8152240655fd3373 (diff)
downloadpackages_apps_settings-ff3673c7f477b1d78e64a8bc28754552dcdc8826.zip
packages_apps_settings-ff3673c7f477b1d78e64a8bc28754552dcdc8826.tar.gz
packages_apps_settings-ff3673c7f477b1d78e64a8bc28754552dcdc8826.tar.bz2
Make running services initial update async.
Also fix the value show for an app's awake time. Change-Id: I801681d3a1d47a6bb1f3fb8cc5b0ef009201146f
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/settings/applications/ManageApplications.java30
-rw-r--r--src/com/android/settings/applications/RunningProcessesView.java13
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageSummary.java10
3 files changed, 43 insertions, 10 deletions
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index fd689c5..772e48d 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -33,6 +33,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
+import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
@@ -92,6 +93,8 @@ public class ManageApplications extends TabActivity implements
private String mCurrentPkgName;
+ private View mLoadingContainer;
+
private View mListContainer;
// ListView used to display list
@@ -107,6 +110,12 @@ public class ManageApplications extends TabActivity implements
private boolean mActivityResumed;
private Object mNonConfigInstance;
+ final Runnable mRunningProcessesAvail = new Runnable() {
+ public void run() {
+ handleRunningProcessesAvail();
+ }
+ };
+
// View Holder used when displaying views
static class AppViewHolder {
ApplicationsState.AppEntry entry;
@@ -405,6 +414,7 @@ public class ManageApplications extends TabActivity implements
// initialize the inflater
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mRootView = mInflater.inflate(R.layout.manage_applications, null);
+ mLoadingContainer = mRootView.findViewById(R.id.loading_container);
mListContainer = mRootView.findViewById(R.id.list_container);
// Create adapter and list view here
ListView lv = (ListView) mListContainer.findViewById(android.R.id.list);
@@ -561,19 +571,35 @@ public class ManageApplications extends TabActivity implements
mRunningProcessesView.doCreate(null, mNonConfigInstance);
mCreatedRunning = true;
}
+ boolean haveData = true;
if (mActivityResumed && !mResumedRunning) {
- mRunningProcessesView.doResume();
+ haveData = mRunningProcessesView.doResume(mRunningProcessesAvail);
mResumedRunning = true;
}
mApplicationsAdapter.pause();
if (mCurView != which) {
- mRunningProcessesView.setVisibility(View.VISIBLE);
+ if (haveData) {
+ mRunningProcessesView.setVisibility(View.VISIBLE);
+ } else {
+ mLoadingContainer.setVisibility(View.VISIBLE);
+ }
mListContainer.setVisibility(View.GONE);
}
}
mCurView = which;
}
+ void handleRunningProcessesAvail() {
+ if (mCurView == VIEW_RUNNING) {
+ mLoadingContainer.startAnimation(AnimationUtils.loadAnimation(
+ this, android.R.anim.fade_out));
+ mRunningProcessesView.startAnimation(AnimationUtils.loadAnimation(
+ this, android.R.anim.fade_in));
+ mRunningProcessesView.setVisibility(View.VISIBLE);
+ mLoadingContainer.setVisibility(View.GONE);
+ }
+ }
+
public void showCurrentTab() {
String tabId = getTabHost().getCurrentTabTag();
int newOption;
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index f2d8e9e..1de67f7 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -64,6 +64,8 @@ public class RunningProcessesView extends FrameLayout
RunningState mState;
+ Runnable mDataAvail;
+
StringBuilder mBuilder = new StringBuilder(128);
RunningState.BaseItem mCurSelected;
@@ -390,6 +392,11 @@ public class RunningProcessesView extends FrameLayout
adapter.notifyDataSetChanged();
}
+ if (mDataAvail != null) {
+ mDataAvail.run();
+ mDataAvail = null;
+ }
+
// This is the amount of available memory until we start killing
// background services.
long availMem = readAvailMem() - SECONDARY_SERVER_MEM;
@@ -475,15 +482,19 @@ public class RunningProcessesView extends FrameLayout
public void doPause() {
mState.pause();
+ mDataAvail = null;
}
- public void doResume() {
+ public boolean doResume(Runnable dataAvail) {
mState.resume(this);
if (mState.hasData()) {
// If the state already has its data, then let's populate our
// list right now to avoid flicker.
refreshUi(true);
+ return true;
}
+ mDataAvail = dataAvail;
+ return false;
}
public Object doRetainNonConfigurationInstance() {
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 3ff7080..5d4c1b9 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -392,16 +392,12 @@ public class PowerUsageSummary extends PreferenceActivity implements Runnable {
for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> wakelockEntry
: wakelockStats.entrySet()) {
Uid.Wakelock wakelock = wakelockEntry.getValue();
- BatteryStats.Timer timer = wakelock.getWakeTime(BatteryStats.WAKE_TYPE_FULL);
+ // Only care about partial wake locks since full wake locks
+ // are canceled when the user turns the screen off.
+ BatteryStats.Timer timer = wakelock.getWakeTime(BatteryStats.WAKE_TYPE_PARTIAL);
if (timer != null) {
wakelockTime += timer.getTotalTimeLocked(uSecTime, which);
}
- timer = wakelock.getWakeTime(BatteryStats.WAKE_TYPE_PARTIAL);
- if (timer != null) {
- wakelockTime += timer.getTotalTimeLocked(uSecTime, which);
- }
- // Note: not considering window, since that is just the system
- // keeping the screen on while the app is running.
}
wakelockTime /= 1000; // convert to millis