Mass merge from gingerbread - do not merge

Change-Id: I45dc3596bf4211d8f91c64f2d1d00588878df629
This commit is contained in:
The Android Open Source Project
2011-01-30 12:40:32 -08:00
81 changed files with 3930 additions and 1257 deletions

View File

@ -50,6 +50,6 @@ public class ChooserActivity extends ResolverActivity {
initialIntents[i] = (Intent)pa[i];
}
}
super.onCreate(savedInstanceState, target, title, initialIntents, false);
super.onCreate(savedInstanceState, target, title, initialIntents, null, false);
}
}

View File

@ -63,11 +63,12 @@ public class ResolverActivity extends AlertActivity implements
protected void onCreate(Bundle savedInstanceState) {
onCreate(savedInstanceState, new Intent(getIntent()),
getResources().getText(com.android.internal.R.string.whichApplication),
null, true);
null, null, true);
}
protected void onCreate(Bundle savedInstanceState, Intent intent,
CharSequence title, Intent[] initialIntents, boolean alwaysUseOption) {
CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList,
boolean alwaysUseOption) {
super.onCreate(savedInstanceState);
mPm = getPackageManager();
intent.setComponent(null);
@ -88,7 +89,7 @@ public class ResolverActivity extends AlertActivity implements
com.android.internal.R.id.clearDefaultHint);
mClearDefaultHint.setVisibility(View.GONE);
}
mAdapter = new ResolveListAdapter(this, intent, initialIntents);
mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList);
if (mAdapter.getCount() > 1) {
ap.mAdapter = mAdapter;
} else if (mAdapter.getCount() == 1) {
@ -215,14 +216,16 @@ public class ResolverActivity extends AlertActivity implements
private List<DisplayResolveInfo> mList;
public ResolveListAdapter(Context context, Intent intent,
Intent[] initialIntents) {
Intent[] initialIntents, List<ResolveInfo> rList) {
mIntent = new Intent(intent);
mIntent.setComponent(null);
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
List<ResolveInfo> rList = mPm.queryIntentActivities(
intent, PackageManager.MATCH_DEFAULT_ONLY
| (mAlwaysCheck != null ? PackageManager.GET_RESOLVED_FILTER : 0));
if (rList == null) {
rList = mPm.queryIntentActivities(
intent, PackageManager.MATCH_DEFAULT_ONLY
| (mAlwaysCheck != null ? PackageManager.GET_RESOLVED_FILTER : 0));
}
int N;
if ((rList != null) && ((N = rList.size()) > 0)) {
// Only display the first matches that are either of equal

View File

@ -193,7 +193,7 @@ public class LlcpSocket {
throw new IOException();
}
} catch (RemoteException e) {
Log.e(TAG, "RemoteException in send(): ", e);
Log.e(TAG, "RemoteException in receive(): ", e);
}
return receivedLength;

View File

@ -4087,7 +4087,7 @@ public final class BatteryStatsImpl extends BatteryStats {
// we have gone through a significant charge (from a very low
// level to a now very high level).
if (oldStatus == BatteryManager.BATTERY_STATUS_FULL
|| level >= 95
|| level >= 90
|| (mDischargeCurrentLevel < 20 && level >= 80)) {
doWrite = true;
resetAllStatsLocked();

View File

@ -34,6 +34,7 @@ import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.lang.ref.WeakReference;
import java.text.DateFormatSymbols;
import java.util.Calendar;
@ -54,26 +55,45 @@ public class DigitalClock extends RelativeLayout {
private TextView mTimeDisplayForeground;
private AmPm mAmPm;
private ContentObserver mFormatChangeObserver;
private boolean mLive = true;
private boolean mAttached;
private int mAttached = 0; // for debugging - tells us whether attach/detach is unbalanced
/* called by system on minute ticks */
private final Handler mHandler = new Handler();
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (mLive && intent.getAction().equals(
Intent.ACTION_TIMEZONE_CHANGED)) {
mCalendar = Calendar.getInstance();
}
// Post a runnable to avoid blocking the broadcast.
mHandler.post(new Runnable() {
public void run() {
updateTime();
private BroadcastReceiver mIntentReceiver;
private static class TimeChangedReceiver extends BroadcastReceiver {
private WeakReference<DigitalClock> mClock;
private Context mContext;
public TimeChangedReceiver(DigitalClock clock) {
mClock = new WeakReference<DigitalClock>(clock);
mContext = clock.getContext();
}
@Override
public void onReceive(Context context, Intent intent) {
// Post a runnable to avoid blocking the broadcast.
final boolean timezoneChanged =
intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED);
final DigitalClock clock = mClock.get();
if (clock != null) {
clock.mHandler.post(new Runnable() {
public void run() {
if (timezoneChanged) {
clock.mCalendar = Calendar.getInstance();
}
clock.updateTime();
}
});
} else {
try {
mContext.unregisterReceiver(this);
} catch (RuntimeException e) {
// Shouldn't happen
}
}
};
}
};
static class AmPm {
private TextView mAmPm;
@ -99,14 +119,27 @@ public class DigitalClock extends RelativeLayout {
}
}
private class FormatChangeObserver extends ContentObserver {
public FormatChangeObserver() {
private static class FormatChangeObserver extends ContentObserver {
private WeakReference<DigitalClock> mClock;
private Context mContext;
public FormatChangeObserver(DigitalClock clock) {
super(new Handler());
mClock = new WeakReference<DigitalClock>(clock);
mContext = clock.getContext();
}
@Override
public void onChange(boolean selfChange) {
setDateFormat();
updateTime();
DigitalClock digitalClock = mClock.get();
if (digitalClock != null) {
digitalClock.setDateFormat();
digitalClock.updateTime();
} else {
try {
mContext.getContentResolver().unregisterContentObserver(this);
} catch (RuntimeException e) {
// Shouldn't happen
}
}
}
}
@ -139,11 +172,11 @@ public class DigitalClock extends RelativeLayout {
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (mAttached) return;
mAttached = true;
mAttached++;
if (mLive) {
/* monitor time ticks, time changed, timezone */
/* monitor time ticks, time changed, timezone */
if (mIntentReceiver == null) {
mIntentReceiver = new TimeChangedReceiver(this);
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);
@ -152,9 +185,11 @@ public class DigitalClock extends RelativeLayout {
}
/* monitor 12/24-hour display preference */
mFormatChangeObserver = new FormatChangeObserver();
mContext.getContentResolver().registerContentObserver(
Settings.System.CONTENT_URI, true, mFormatChangeObserver);
if (mFormatChangeObserver == null) {
mFormatChangeObserver = new FormatChangeObserver(this);
mContext.getContentResolver().registerContentObserver(
Settings.System.CONTENT_URI, true, mFormatChangeObserver);
}
updateTime();
}
@ -163,16 +198,19 @@ public class DigitalClock extends RelativeLayout {
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (!mAttached) return;
mAttached = false;
mAttached--;
if (mLive) {
if (mIntentReceiver != null) {
mContext.unregisterReceiver(mIntentReceiver);
}
mContext.getContentResolver().unregisterContentObserver(
mFormatChangeObserver);
}
if (mFormatChangeObserver != null) {
mContext.getContentResolver().unregisterContentObserver(
mFormatChangeObserver);
}
mFormatChangeObserver = null;
mIntentReceiver = null;
}
void updateTime(Calendar c) {
mCalendar = c;
@ -180,9 +218,7 @@ public class DigitalClock extends RelativeLayout {
}
private void updateTime() {
if (mLive) {
mCalendar.setTimeInMillis(System.currentTimeMillis());
}
mCalendar.setTimeInMillis(System.currentTimeMillis());
CharSequence newTime = DateFormat.format(mFormat, mCalendar);
mTimeDisplayBackground.setText(newTime);
@ -195,8 +231,4 @@ public class DigitalClock extends RelativeLayout {
? M24 : M12;
mAmPm.setShowAmPm(mFormat.equals(M12));
}
void setLive(boolean live) {
mLive = live;
}
}