Make running services initial update async.
Also fix the value show for an app's awake time. Change-Id: I801681d3a1d47a6bb1f3fb8cc5b0ef009201146f
This commit is contained in:
@@ -38,4 +38,23 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/loading_container"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ProgressBar style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
<TextView android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:text="@string/settings_safetylegal_activity_loading"
|
||||||
|
android:paddingTop="4dip"
|
||||||
|
android:singleLine="true" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@@ -33,6 +33,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
@@ -92,6 +93,8 @@ public class ManageApplications extends TabActivity implements
|
|||||||
|
|
||||||
private String mCurrentPkgName;
|
private String mCurrentPkgName;
|
||||||
|
|
||||||
|
private View mLoadingContainer;
|
||||||
|
|
||||||
private View mListContainer;
|
private View mListContainer;
|
||||||
|
|
||||||
// ListView used to display list
|
// ListView used to display list
|
||||||
@@ -107,6 +110,12 @@ public class ManageApplications extends TabActivity implements
|
|||||||
private boolean mActivityResumed;
|
private boolean mActivityResumed;
|
||||||
private Object mNonConfigInstance;
|
private Object mNonConfigInstance;
|
||||||
|
|
||||||
|
final Runnable mRunningProcessesAvail = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
handleRunningProcessesAvail();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// View Holder used when displaying views
|
// View Holder used when displaying views
|
||||||
static class AppViewHolder {
|
static class AppViewHolder {
|
||||||
ApplicationsState.AppEntry entry;
|
ApplicationsState.AppEntry entry;
|
||||||
@@ -405,6 +414,7 @@ public class ManageApplications extends TabActivity implements
|
|||||||
// initialize the inflater
|
// initialize the inflater
|
||||||
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mRootView = mInflater.inflate(R.layout.manage_applications, null);
|
mRootView = mInflater.inflate(R.layout.manage_applications, null);
|
||||||
|
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
||||||
mListContainer = mRootView.findViewById(R.id.list_container);
|
mListContainer = mRootView.findViewById(R.id.list_container);
|
||||||
// Create adapter and list view here
|
// Create adapter and list view here
|
||||||
ListView lv = (ListView) mListContainer.findViewById(android.R.id.list);
|
ListView lv = (ListView) mListContainer.findViewById(android.R.id.list);
|
||||||
@@ -561,19 +571,35 @@ public class ManageApplications extends TabActivity implements
|
|||||||
mRunningProcessesView.doCreate(null, mNonConfigInstance);
|
mRunningProcessesView.doCreate(null, mNonConfigInstance);
|
||||||
mCreatedRunning = true;
|
mCreatedRunning = true;
|
||||||
}
|
}
|
||||||
|
boolean haveData = true;
|
||||||
if (mActivityResumed && !mResumedRunning) {
|
if (mActivityResumed && !mResumedRunning) {
|
||||||
mRunningProcessesView.doResume();
|
haveData = mRunningProcessesView.doResume(mRunningProcessesAvail);
|
||||||
mResumedRunning = true;
|
mResumedRunning = true;
|
||||||
}
|
}
|
||||||
mApplicationsAdapter.pause();
|
mApplicationsAdapter.pause();
|
||||||
if (mCurView != which) {
|
if (mCurView != which) {
|
||||||
mRunningProcessesView.setVisibility(View.VISIBLE);
|
if (haveData) {
|
||||||
|
mRunningProcessesView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mLoadingContainer.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
mListContainer.setVisibility(View.GONE);
|
mListContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mCurView = which;
|
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() {
|
public void showCurrentTab() {
|
||||||
String tabId = getTabHost().getCurrentTabTag();
|
String tabId = getTabHost().getCurrentTabTag();
|
||||||
int newOption;
|
int newOption;
|
||||||
|
@@ -64,6 +64,8 @@ public class RunningProcessesView extends FrameLayout
|
|||||||
|
|
||||||
RunningState mState;
|
RunningState mState;
|
||||||
|
|
||||||
|
Runnable mDataAvail;
|
||||||
|
|
||||||
StringBuilder mBuilder = new StringBuilder(128);
|
StringBuilder mBuilder = new StringBuilder(128);
|
||||||
|
|
||||||
RunningState.BaseItem mCurSelected;
|
RunningState.BaseItem mCurSelected;
|
||||||
@@ -390,6 +392,11 @@ public class RunningProcessesView extends FrameLayout
|
|||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mDataAvail != null) {
|
||||||
|
mDataAvail.run();
|
||||||
|
mDataAvail = null;
|
||||||
|
}
|
||||||
|
|
||||||
// This is the amount of available memory until we start killing
|
// This is the amount of available memory until we start killing
|
||||||
// background services.
|
// background services.
|
||||||
long availMem = readAvailMem() - SECONDARY_SERVER_MEM;
|
long availMem = readAvailMem() - SECONDARY_SERVER_MEM;
|
||||||
@@ -475,15 +482,19 @@ public class RunningProcessesView extends FrameLayout
|
|||||||
|
|
||||||
public void doPause() {
|
public void doPause() {
|
||||||
mState.pause();
|
mState.pause();
|
||||||
|
mDataAvail = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doResume() {
|
public boolean doResume(Runnable dataAvail) {
|
||||||
mState.resume(this);
|
mState.resume(this);
|
||||||
if (mState.hasData()) {
|
if (mState.hasData()) {
|
||||||
// If the state already has its data, then let's populate our
|
// If the state already has its data, then let's populate our
|
||||||
// list right now to avoid flicker.
|
// list right now to avoid flicker.
|
||||||
refreshUi(true);
|
refreshUi(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
mDataAvail = dataAvail;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object doRetainNonConfigurationInstance() {
|
public Object doRetainNonConfigurationInstance() {
|
||||||
|
@@ -392,16 +392,12 @@ public class PowerUsageSummary extends PreferenceActivity implements Runnable {
|
|||||||
for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> wakelockEntry
|
for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> wakelockEntry
|
||||||
: wakelockStats.entrySet()) {
|
: wakelockStats.entrySet()) {
|
||||||
Uid.Wakelock wakelock = wakelockEntry.getValue();
|
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) {
|
if (timer != null) {
|
||||||
wakelockTime += timer.getTotalTimeLocked(uSecTime, which);
|
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
|
wakelockTime /= 1000; // convert to millis
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user