am 571180c4: Merge "Attempt to fix the SDK build" into gingerbread
Merge commit '571180c4c72e0bb4f930f8971edf000a652f10f6' into gingerbread-plus-aosp
* commit '571180c4c72e0bb4f930f8971edf000a652f10f6':
Attempt to fix the SDK build
diff --git a/api/current.xml b/api/current.xml
index f1a383f..aee9e23 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -22877,6 +22877,18 @@
<parameter name="context" type="android.content.Context">
</parameter>
</constructor>
+<constructor name="AlertDialog.Builder"
+ type="android.app.AlertDialog.Builder"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="theme" type="int">
+</parameter>
+</constructor>
<method name="create"
return="android.app.AlertDialog"
abstract="false"
@@ -205008,6 +205020,32 @@
<parameter name="object" type="T">
</parameter>
</method>
+<method name="addAll"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="collection" type="java.util.Collection<? extends T>">
+</parameter>
+</method>
+<method name="addAll"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="items" type="T...">
+</parameter>
+</method>
<method name="clear"
return="void"
abstract="false"
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java
index 2714de5..61a8fc3 100644
--- a/core/java/android/app/AlertDialog.java
+++ b/core/java/android/app/AlertDialog.java
@@ -265,12 +265,22 @@
public static class Builder {
private final AlertController.AlertParams P;
+ private int mTheme;
/**
* Constructor using a context for this builder and the {@link AlertDialog} it creates.
*/
public Builder(Context context) {
+ this(context, com.android.internal.R.style.Theme_Dialog_Alert);
+ }
+
+ /**
+ * Constructor using a context and theme for this builder and
+ * the {@link AlertDialog} it creates.
+ */
+ public Builder(Context context, int theme) {
P = new AlertController.AlertParams(context);
+ mTheme = theme;
}
/**
@@ -783,7 +793,7 @@
* to do and want this to be created and displayed.
*/
public AlertDialog create() {
- final AlertDialog dialog = new AlertDialog(P.mContext);
+ final AlertDialog dialog = new AlertDialog(P.mContext, mTheme);
P.apply(dialog.mAlert);
dialog.setCancelable(P.mCancelable);
dialog.setOnCancelListener(P.mOnCancelListener);
diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java
index 30815c3..ddc2b1f 100644
--- a/core/java/android/app/ApplicationErrorReport.java
+++ b/core/java/android/app/ApplicationErrorReport.java
@@ -190,7 +190,7 @@
/**
* Return activity in receiverPackage that handles ACTION_APP_ERROR.
*
- * @param pm PackageManager isntance
+ * @param pm PackageManager instance
* @param errorPackage package which caused the error
* @param receiverPackage candidate package to receive the error
* @return activity component within receiverPackage which handles
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index e99d4b4..3bfc7e7 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -53,7 +53,6 @@
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
-import android.content.pm.PackageParser.Package;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
@@ -86,11 +85,9 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.StatFs;
import android.os.Vibrator;
import android.os.FileUtils.FileStatus;
import android.os.storage.StorageManager;
-import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.ClipboardManager;
import android.util.AndroidRuntimeException;
@@ -210,7 +207,7 @@
private File mCacheDir;
private File mExternalFilesDir;
private File mExternalCacheDir;
-
+
private static long sInstanceCount = 0;
private static final String[] EMPTY_FILE_LIST = {};
@@ -262,18 +259,18 @@
public Looper getMainLooper() {
return mMainThread.getLooper();
}
-
+
@Override
public Context getApplicationContext() {
return (mPackageInfo != null) ?
mPackageInfo.getApplication() : mMainThread.getApplication();
}
-
+
@Override
public void setTheme(int resid) {
mThemeResource = resid;
}
-
+
@Override
public Resources.Theme getTheme() {
if (mTheme == null) {
@@ -323,7 +320,7 @@
}
throw new RuntimeException("Not supported in system context");
}
-
+
private static File makeBackupFile(File prefsFile) {
return new File(prefsFile.getPath() + ".bak");
}
@@ -343,7 +340,7 @@
return sp;
}
}
-
+
FileInputStream str = null;
File backup = makeBackupFile(f);
if (backup.exists()) {
@@ -355,7 +352,7 @@
if (f.exists() && !f.canRead()) {
Log.w(TAG, "Attempt to read preferences file " + f + " without permission");
}
-
+
Map map = null;
if (f.exists() && f.canRead()) {
try {
@@ -439,7 +436,7 @@
}
if (!mFilesDir.exists()) {
if(!mFilesDir.mkdirs()) {
- Log.w(TAG, "Unable to create files directory");
+ Log.w(TAG, "Unable to create files directory " + mFilesDir.getPath());
return null;
}
FileUtils.setPermissions(
@@ -450,7 +447,7 @@
return mFilesDir;
}
}
-
+
@Override
public File getExternalFilesDir(String type) {
synchronized (mSync) {
@@ -482,7 +479,7 @@
return dir;
}
}
-
+
@Override
public File getCacheDir() {
synchronized (mSync) {
@@ -502,7 +499,7 @@
}
return mCacheDir;
}
-
+
@Override
public File getExternalCacheDir() {
synchronized (mSync) {
@@ -524,7 +521,7 @@
return mExternalCacheDir;
}
}
-
+
@Override
public File getFileStreamPath(String name) {
return makeFilename(getFilesDir(), name);
@@ -565,7 +562,7 @@
return (list != null) ? list : EMPTY_FILE_LIST;
}
-
+
private File getDatabasesDir() {
synchronized (mSync) {
if (mDatabasesDir == null) {
@@ -577,7 +574,7 @@
return mDatabasesDir;
}
}
-
+
@Override
public Drawable getWallpaper() {
return getWallpaperManager().getDrawable();
@@ -645,7 +642,7 @@
} catch (RemoteException e) {
}
}
-
+
@Override
public void sendBroadcast(Intent intent) {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
@@ -1558,15 +1555,15 @@
final void setActivityToken(IBinder token) {
mActivityToken = token;
}
-
+
final void setOuterContext(Context context) {
mOuterContext = context;
}
-
+
final Context getOuterContext() {
return mOuterContext;
}
-
+
final IBinder getActivityToken() {
return mActivityToken;
}
@@ -1643,7 +1640,7 @@
{
return mMainThread.releaseProvider(provider);
}
-
+
private final ActivityThread mMainThread;
}
@@ -1676,7 +1673,7 @@
throw new RuntimeException("Package manager has died", e);
}
}
-
+
@Override
public String[] canonicalToCurrentPackageNames(String[] names) {
try {
@@ -1685,7 +1682,7 @@
throw new RuntimeException("Package manager has died", e);
}
}
-
+
@Override
public Intent getLaunchIntentForPackage(String packageName) {
// First see if the package has an INFO activity; the existence of
@@ -1707,8 +1704,9 @@
if (resolveInfo == null) {
return null;
}
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClassName(packageName, resolveInfo.activityInfo.name);
+ Intent intent = new Intent(intentToResolve);
+ intent.setClassName(resolveInfo.activityInfo.applicationInfo.packageName,
+ resolveInfo.activityInfo.name);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}
@@ -1859,7 +1857,7 @@
throw new RuntimeException("Package manager has died", e);
}
}
-
+
@Override
public boolean hasSystemFeature(String name) {
try {
@@ -1868,7 +1866,7 @@
throw new RuntimeException("Package manager has died", e);
}
}
-
+
@Override
public int checkPermission(String permName, String pkgName) {
try {
@@ -1940,9 +1938,9 @@
throw new RuntimeException("Package manager has died", e);
}
}
-
+
@Override
- public int getUidForSharedUser(String sharedUserName)
+ public int getUidForSharedUser(String sharedUserName)
throws NameNotFoundException {
try {
int uid = mPM.getUidForSharedUser(sharedUserName);
@@ -2346,7 +2344,7 @@
}
}
}
-
+
private static final class ResourceName {
final String packageName;
final int iconId;
@@ -2518,7 +2516,7 @@
}
}
@Override
- public void clearApplicationUserData(String packageName,
+ public void clearApplicationUserData(String packageName,
IPackageDataObserver observer) {
try {
mPM.clearApplicationUserData(packageName, observer);
@@ -2527,7 +2525,7 @@
}
}
@Override
- public void deleteApplicationCacheFiles(String packageName,
+ public void deleteApplicationCacheFiles(String packageName,
IPackageDataObserver observer) {
try {
mPM.deleteApplicationCacheFiles(packageName, observer);
@@ -2552,9 +2550,9 @@
// Should never happen!
}
}
-
+
@Override
- public void getPackageSizeInfo(String packageName,
+ public void getPackageSizeInfo(String packageName,
IPackageStatsObserver observer) {
try {
mPM.getPackageSizeInfo(packageName, observer);
@@ -2599,7 +2597,7 @@
// Should never happen!
}
}
-
+
@Override
public void replacePreferredActivity(IntentFilter filter,
int match, ComponentName[] set, ComponentName activity) {
@@ -2618,7 +2616,7 @@
// Should never happen!
}
}
-
+
@Override
public int getPreferredActivities(List<IntentFilter> outFilters,
List<ComponentName> outActivities, String packageName) {
@@ -2629,7 +2627,7 @@
}
return 0;
}
-
+
@Override
public void setComponentEnabledSetting(ComponentName componentName,
int newState, int flags) {
@@ -2659,7 +2657,7 @@
// Should never happen!
}
}
-
+
@Override
public int getApplicationEnabledSetting(String packageName) {
try {
@@ -2725,7 +2723,7 @@
return mTimestamp != mFileStatus.mtime;
}
}
-
+
public void replace(Map newContents) {
if (newContents != null) {
synchronized (this) {
@@ -2733,7 +2731,7 @@
}
}
}
-
+
public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
synchronized(this) {
mListeners.put(listener, mContent);
@@ -2899,7 +2897,7 @@
public Editor edit() {
return new EditorImpl();
}
-
+
private FileOutputStream createFileOutputStream(File file) {
FileOutputStream str = null;
try {
@@ -2936,7 +2934,7 @@
mFile.delete();
}
}
-
+
// Attempt to write the file, delete the backup and return true as atomically as
// possible. If any exception occurs, delete the new file; next time we will restore
// from the backup.
@@ -2951,7 +2949,7 @@
if (FileUtils.getFileStatus(mFile.getPath(), mFileStatus)) {
mTimestamp = mFileStatus.mtime;
}
-
+
// Writing was successful, delete the backup file if there is one.
mBackupFile.delete();
return true;
diff --git a/core/java/android/app/DatePickerDialog.java b/core/java/android/app/DatePickerDialog.java
index 78bbb4f..f780e1d 100644
--- a/core/java/android/app/DatePickerDialog.java
+++ b/core/java/android/app/DatePickerDialog.java
@@ -21,7 +21,6 @@
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.text.TextUtils.TruncateAt;
-import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;
@@ -36,13 +35,13 @@
/**
* A simple dialog containing an {@link android.widget.DatePicker}.
*/
-public class DatePickerDialog extends AlertDialog implements OnClickListener,
+public class DatePickerDialog extends AlertDialog implements OnClickListener,
OnDateChangedListener {
private static final String YEAR = "year";
private static final String MONTH = "month";
private static final String DAY = "day";
-
+
private final DatePicker mDatePicker;
private final OnDateSetListener mCallBack;
private final Calendar mCalendar;
@@ -80,7 +79,7 @@
int year,
int monthOfYear,
int dayOfMonth) {
- this(context, com.android.internal.R.style.Theme_Dialog_Alert,
+ this(context, com.android.internal.R.style.Theme_Dialog_Alert,
callBack, year, monthOfYear, dayOfMonth);
}
@@ -106,17 +105,17 @@
mInitialDay = dayOfMonth;
DateFormatSymbols symbols = new DateFormatSymbols();
mWeekDays = symbols.getShortWeekdays();
-
+
mTitleDateFormat = java.text.DateFormat.
getDateInstance(java.text.DateFormat.FULL);
mCalendar = Calendar.getInstance();
updateTitle(mInitialYear, mInitialMonth, mInitialDay);
-
- setButton(context.getText(R.string.date_time_set), this);
- setButton2(context.getText(R.string.cancel), (OnClickListener) null);
+
+ setButton(BUTTON_POSITIVE, context.getText(R.string.date_time_set), this);
+ setButton(BUTTON_NEGATIVE, context.getText(R.string.cancel), (OnClickListener) null);
setIcon(R.drawable.ic_dialog_time);
-
- LayoutInflater inflater =
+
+ LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.date_picker_dialog, null);
setView(view);
@@ -136,20 +135,20 @@
title.setSingleLine();
title.setEllipsize(TruncateAt.END);
}
-
+
public void onClick(DialogInterface dialog, int which) {
if (mCallBack != null) {
mDatePicker.clearFocus();
- mCallBack.onDateSet(mDatePicker, mDatePicker.getYear(),
+ mCallBack.onDateSet(mDatePicker, mDatePicker.getYear(),
mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
}
}
-
+
public void onDateChanged(DatePicker view, int year,
int month, int day) {
updateTitle(year, month, day);
}
-
+
public void updateDate(int year, int monthOfYear, int dayOfMonth) {
mInitialYear = year;
mInitialMonth = monthOfYear;
@@ -163,7 +162,7 @@
mCalendar.set(Calendar.DAY_OF_MONTH, day);
setTitle(mTitleDateFormat.format(mCalendar.getTime()));
}
-
+
@Override
public Bundle onSaveInstanceState() {
Bundle state = super.onSaveInstanceState();
@@ -172,7 +171,7 @@
state.putInt(DAY, mDatePicker.getDayOfMonth());
return state;
}
-
+
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 7625c04..2fb746c 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -1131,7 +1131,7 @@
try {
// If the intent was created from a suggestion, it will always have an explicit
// component here.
- Log.i(LOG_TAG, "Starting (as ourselves) " + intent.toURI());
+ Log.i(LOG_TAG, "Starting (as ourselves) " + intent.toUri(0));
getContext().startActivity(intent);
// If the search switches to a different activity,
// SearchDialogWrapper#performActivityResuming
diff --git a/core/java/android/app/TimePickerDialog.java b/core/java/android/app/TimePickerDialog.java
index 002b01f..a04b9e9 100644
--- a/core/java/android/app/TimePickerDialog.java
+++ b/core/java/android/app/TimePickerDialog.java
@@ -33,7 +33,7 @@
/**
* A dialog that prompts the user for the time of day using a {@link TimePicker}.
*/
-public class TimePickerDialog extends AlertDialog implements OnClickListener,
+public class TimePickerDialog extends AlertDialog implements OnClickListener,
OnTimeChangedListener {
/**
@@ -53,12 +53,12 @@
private static final String HOUR = "hour";
private static final String MINUTE = "minute";
private static final String IS_24_HOUR = "is24hour";
-
+
private final TimePicker mTimePicker;
private final OnTimeSetListener mCallback;
private final Calendar mCalendar;
private final java.text.DateFormat mDateFormat;
-
+
int mInitialHourOfDay;
int mInitialMinute;
boolean mIs24HourView;
@@ -98,12 +98,13 @@
mDateFormat = DateFormat.getTimeFormat(context);
mCalendar = Calendar.getInstance();
updateTitle(mInitialHourOfDay, mInitialMinute);
-
- setButton(context.getText(R.string.date_time_set), this);
- setButton2(context.getText(R.string.cancel), (OnClickListener) null);
+
+ setButton(BUTTON_POSITIVE, context.getText(R.string.date_time_set), this);
+ setButton(BUTTON_NEGATIVE, context.getText(R.string.cancel),
+ (OnClickListener) null);
setIcon(R.drawable.ic_dialog_time);
-
- LayoutInflater inflater =
+
+ LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.time_picker_dialog, null);
setView(view);
@@ -115,11 +116,11 @@
mTimePicker.setIs24HourView(mIs24HourView);
mTimePicker.setOnTimeChangedListener(this);
}
-
+
public void onClick(DialogInterface dialog, int which) {
if (mCallback != null) {
mTimePicker.clearFocus();
- mCallback.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(),
+ mCallback.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(),
mTimePicker.getCurrentMinute());
}
}
@@ -127,7 +128,7 @@
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
updateTitle(hourOfDay, minute);
}
-
+
public void updateTime(int hourOfDay, int minutOfHour) {
mTimePicker.setCurrentHour(hourOfDay);
mTimePicker.setCurrentMinute(minutOfHour);
@@ -138,7 +139,7 @@
mCalendar.set(Calendar.MINUTE, minute);
setTitle(mDateFormat.format(mCalendar.getTime()));
}
-
+
@Override
public Bundle onSaveInstanceState() {
Bundle state = super.onSaveInstanceState();
@@ -147,7 +148,7 @@
state.putBoolean(IS_24_HOUR, mTimePicker.is24HourView());
return state;
}
-
+
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index d4ce6a1..d2ab85e 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -22,7 +22,6 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.util.TypedValue;
import android.widget.RemoteViews;
@@ -149,7 +148,7 @@
* instances as possible.</td>
* </tr>
* </table>
- *
+ *
* @see AppWidgetProvider#onUpdate AppWidgetProvider.onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
*/
public static final String ACTION_APPWIDGET_UPDATE = "android.appwidget.action.APPWIDGET_UPDATE";
@@ -163,7 +162,7 @@
/**
* Sent when an instance of an AppWidget is removed from the last host.
- *
+ *
* @see AppWidgetProvider#onEnabled AppWidgetProvider.onEnabled(Context context)
*/
public static final String ACTION_APPWIDGET_DISABLED = "android.appwidget.action.APPWIDGET_DISABLED";
@@ -172,7 +171,7 @@
* Sent when an instance of an AppWidget is added to a host for the first time.
* This broadcast is sent at boot time if there is a AppWidgetHost installed with
* an instance for this provider.
- *
+ *
* @see AppWidgetProvider#onEnabled AppWidgetProvider.onEnabled(Context context)
*/
public static final String ACTION_APPWIDGET_ENABLED = "android.appwidget.action.APPWIDGET_ENABLED";
@@ -183,20 +182,21 @@
* @see AppWidgetProviderInfo
*/
public static final String META_DATA_APPWIDGET_PROVIDER = "android.appwidget.provider";
-
+
/**
* Field for the manifest meta-data tag used to indicate any previous name for the
* app widget receiver.
*
* @see AppWidgetProviderInfo
- *
+ *
* @hide Pending API approval
*/
public static final String META_DATA_APPWIDGET_OLD_NAME = "android.appwidget.oldName";
- static WeakHashMap<Context, WeakReference<AppWidgetManager>> sManagerCache = new WeakHashMap();
+ static WeakHashMap<Context, WeakReference<AppWidgetManager>> sManagerCache =
+ new WeakHashMap<Context, WeakReference<AppWidgetManager>>();
static IAppWidgetService sService;
-
+
Context mContext;
private DisplayMetrics mDisplayMetrics;
@@ -219,7 +219,7 @@
}
if (result == null) {
result = new AppWidgetManager(context);
- sManagerCache.put(context, new WeakReference(result));
+ sManagerCache.put(context, new WeakReference<AppWidgetManager>(result));
}
return result;
}
@@ -310,7 +310,7 @@
AppWidgetProviderInfo info = sService.getAppWidgetInfo(appWidgetId);
if (info != null) {
// Converting complex to dp.
- info.minWidth =
+ info.minWidth =
TypedValue.complexToDimensionPixelSize(info.minWidth, mDisplayMetrics);
info.minHeight =
TypedValue.complexToDimensionPixelSize(info.minHeight, mDisplayMetrics);
@@ -344,7 +344,7 @@
/**
* Get the list of appWidgetIds that have been bound to the given AppWidget
* provider.
- *
+ *
* @param provider The {@link android.content.BroadcastReceiver} that is the
* AppWidget provider to find appWidgetIds for.
*/
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
old mode 100644
new mode 100755
index 0608cc0..e671359
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -25,6 +25,7 @@
import android.graphics.Movie;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable.ConstantState;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
@@ -66,6 +67,8 @@
= new LongSparseArray<Drawable.ConstantState>();
private static final SparseArray<ColorStateList> mPreloadedColorStateLists
= new SparseArray<ColorStateList>();
+ private static final LongSparseArray<Drawable.ConstantState> sPreloadedColorDrawables
+ = new LongSparseArray<Drawable.ConstantState>();
private static boolean mPreloaded;
/*package*/ final TypedValue mTmpValue = new TypedValue();
@@ -75,6 +78,8 @@
= new LongSparseArray<WeakReference<Drawable.ConstantState> >();
private final SparseArray<WeakReference<ColorStateList> > mColorStateListCache
= new SparseArray<WeakReference<ColorStateList> >();
+ private final LongSparseArray<WeakReference<Drawable.ConstantState> > mColorDrawableCache
+ = new LongSparseArray<WeakReference<Drawable.ConstantState> >();
private boolean mPreloading;
/*package*/ TypedArray mCachedStyledAttributes = null;
@@ -1299,37 +1304,13 @@
(int)(mMetrics.density*160), mConfiguration.keyboard,
keyboardHidden, mConfiguration.navigation, width, height,
mConfiguration.screenLayout, mConfiguration.uiMode, sSdkVersion);
- int N = mDrawableCache.size();
- if (DEBUG_CONFIG) {
- Log.d(TAG, "Cleaning up drawables config changes: 0x"
- + Integer.toHexString(configChanges));
- }
- for (int i=0; i<N; i++) {
- WeakReference<Drawable.ConstantState> ref = mDrawableCache.valueAt(i);
- if (ref != null) {
- Drawable.ConstantState cs = ref.get();
- if (cs != null) {
- if (Configuration.needNewResources(
- configChanges, cs.getChangingConfigurations())) {
- if (DEBUG_CONFIG) {
- Log.d(TAG, "FLUSHING #0x"
- + Long.toHexString(mDrawableCache.keyAt(i))
- + " / " + cs + " with changes: 0x"
- + Integer.toHexString(cs.getChangingConfigurations()));
- }
- mDrawableCache.setValueAt(i, null);
- } else if (DEBUG_CONFIG) {
- Log.d(TAG, "(Keeping #0x"
- + Long.toHexString(mDrawableCache.keyAt(i))
- + " / " + cs + " with changes: 0x"
- + Integer.toHexString(cs.getChangingConfigurations())
- + ")");
- }
- }
- }
- }
- mDrawableCache.clear();
+
+ clearDrawableCache(mDrawableCache, configChanges);
+ clearDrawableCache(mColorDrawableCache, configChanges);
+
mColorStateListCache.clear();
+
+
flushLayoutCache();
}
synchronized (mSync) {
@@ -1339,6 +1320,41 @@
}
}
+ private void clearDrawableCache(
+ LongSparseArray<WeakReference<ConstantState>> cache,
+ int configChanges) {
+ int N = cache.size();
+ if (DEBUG_CONFIG) {
+ Log.d(TAG, "Cleaning up drawables config changes: 0x"
+ + Integer.toHexString(configChanges));
+ }
+ for (int i=0; i<N; i++) {
+ WeakReference<Drawable.ConstantState> ref = cache.valueAt(i);
+ if (ref != null) {
+ Drawable.ConstantState cs = ref.get();
+ if (cs != null) {
+ if (Configuration.needNewResources(
+ configChanges, cs.getChangingConfigurations())) {
+ if (DEBUG_CONFIG) {
+ Log.d(TAG, "FLUSHING #0x"
+ + Long.toHexString(mDrawableCache.keyAt(i))
+ + " / " + cs + " with changes: 0x"
+ + Integer.toHexString(cs.getChangingConfigurations()));
+ }
+ cache.setValueAt(i, null);
+ } else if (DEBUG_CONFIG) {
+ Log.d(TAG, "(Keeping #0x"
+ + Long.toHexString(cache.keyAt(i))
+ + " / " + cs + " with changes: 0x"
+ + Integer.toHexString(cs.getChangingConfigurations())
+ + ")");
+ }
+ }
+ }
+ }
+ cache.clear();
+ }
+
/**
* Update the system resources configuration if they have previously
* been initialized.
@@ -1661,13 +1677,18 @@
}
final long key = (((long) value.assetCookie) << 32) | value.data;
- Drawable dr = getCachedDrawable(key);
+ boolean isColorDrawable = false;
+ if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT &&
+ value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
+ isColorDrawable = true;
+ }
+ Drawable dr = getCachedDrawable(isColorDrawable ? mColorDrawableCache : mDrawableCache, key);
if (dr != null) {
return dr;
}
- Drawable.ConstantState cs = sPreloadedDrawables.get(key);
+ Drawable.ConstantState cs = isColorDrawable ? sPreloadedColorDrawables.get(key) : sPreloadedDrawables.get(key);
if (cs != null) {
dr = cs.newDrawable(this);
} else {
@@ -1726,13 +1747,21 @@
cs = dr.getConstantState();
if (cs != null) {
if (mPreloading) {
- sPreloadedDrawables.put(key, cs);
+ if (isColorDrawable) {
+ sPreloadedColorDrawables.put(key, cs);
+ } else {
+ sPreloadedDrawables.put(key, cs);
+ }
} else {
synchronized (mTmpValue) {
//Log.i(TAG, "Saving cached drawable @ #" +
// Integer.toHexString(key.intValue())
// + " in " + this + ": " + cs);
- mDrawableCache.put(key, new WeakReference<Drawable.ConstantState>(cs));
+ if (isColorDrawable) {
+ mColorDrawableCache.put(key, new WeakReference<Drawable.ConstantState>(cs));
+ } else {
+ mDrawableCache.put(key, new WeakReference<Drawable.ConstantState>(cs));
+ }
}
}
}
@@ -1741,9 +1770,11 @@
return dr;
}
- private Drawable getCachedDrawable(long key) {
+ private Drawable getCachedDrawable(
+ LongSparseArray<WeakReference<ConstantState>> drawableCache,
+ long key) {
synchronized (mTmpValue) {
- WeakReference<Drawable.ConstantState> wr = mDrawableCache.get(key);
+ WeakReference<Drawable.ConstantState> wr = drawableCache.get(key);
if (wr != null) { // we have the key
Drawable.ConstantState entry = wr.get();
if (entry != null) {
@@ -1753,7 +1784,7 @@
return entry.newDrawable(this);
}
else { // our entry has been purged
- mDrawableCache.delete(key);
+ drawableCache.delete(key);
}
}
}
diff --git a/core/java/android/database/AbstractCursor.java b/core/java/android/database/AbstractCursor.java
index 038eedf..a5e5e46 100644
--- a/core/java/android/database/AbstractCursor.java
+++ b/core/java/android/database/AbstractCursor.java
@@ -204,7 +204,7 @@
* @param window
*/
public void fillWindow(int position, CursorWindow window) {
- if (position < 0 || position > getCount()) {
+ if (position < 0 || position >= getCount()) {
return;
}
window.acquireReference();
diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java
index 66eefb2..22c30a5 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -16,12 +16,18 @@
package android.net;
+import org.apache.http.HttpHost;
+
import android.content.ContentResolver;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.UnknownHostException;
+
import junit.framework.Assert;
/**
@@ -120,4 +126,73 @@
}
}
+ /**
+ * Returns the preferred proxy to be used by clients. This is a wrapper
+ * around {@link android.net.Proxy#getHost()}. Currently no proxy will
+ * be returned for localhost or if the active network is Wi-Fi.
+ *
+ * @param context the context which will be passed to
+ * {@link android.net.Proxy#getHost()}
+ * @param url the target URL for the request
+ * @note Calling this method requires permission
+ * android.permission.ACCESS_NETWORK_STATE
+ * @return The preferred proxy to be used by clients, or null if there
+ * is no proxy.
+ *
+ * {@hide}
+ */
+ static final public HttpHost getPreferredHttpHost(Context context,
+ String url) {
+ if (!isLocalHost(url) && !isNetworkWifi(context)) {
+ final String proxyHost = Proxy.getHost(context);
+ if (proxyHost != null) {
+ return new HttpHost(proxyHost, Proxy.getPort(context), "http");
+ }
+ }
+
+ return null;
+ }
+
+ static final private boolean isLocalHost(String url) {
+ if (url == null) {
+ return false;
+ }
+
+ try {
+ final URI uri = URI.create(url);
+ final String host = uri.getHost();
+ if (host != null) {
+ if (host.equalsIgnoreCase("localhost")) {
+ return true;
+ }
+ if (InetAddress.getByName(host).isLoopbackAddress()) {
+ return true;
+ }
+ }
+ } catch (UnknownHostException uex) {
+ // Ignore (INetworkSystem.ipStringToByteArray)
+ } catch (IllegalArgumentException iex) {
+ // Ignore (URI.create)
+ }
+
+ return false;
+ }
+
+ static final private boolean isNetworkWifi(Context context) {
+ if (context == null) {
+ return false;
+ }
+
+ final ConnectivityManager connectivity = (ConnectivityManager)
+ context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null) {
+ final NetworkInfo info = connectivity.getActiveNetworkInfo();
+ if (info != null &&
+ info.getType() == ConnectivityManager.TYPE_WIFI) {
+ return true;
+ }
+ }
+
+ return false;
+ }
};
diff --git a/core/java/android/net/http/Headers.java b/core/java/android/net/http/Headers.java
index 09f6f4f..74c0de8 100644
--- a/core/java/android/net/http/Headers.java
+++ b/core/java/android/net/http/Headers.java
@@ -262,7 +262,14 @@
break;
case HASH_CACHE_CONTROL:
if (name.equals(CACHE_CONTROL)) {
- mHeaders[IDX_CACHE_CONTROL] = val;
+ // In case where we receive more than one header, create a ',' separated list.
+ // This should be ok, according to RFC 2616 chapter 4.2
+ if (mHeaders[IDX_CACHE_CONTROL] != null &&
+ mHeaders[IDX_CACHE_CONTROL].length() > 0) {
+ mHeaders[IDX_CACHE_CONTROL] += (',' + val);
+ } else {
+ mHeaders[IDX_CACHE_CONTROL] = val;
+ }
}
break;
case HASH_LAST_MODIFIED:
diff --git a/core/java/android/net/http/HttpsConnection.java b/core/java/android/net/http/HttpsConnection.java
index e512a1df..9b842ae 100644
--- a/core/java/android/net/http/HttpsConnection.java
+++ b/core/java/android/net/http/HttpsConnection.java
@@ -204,10 +204,13 @@
BasicHttpRequest proxyReq = new BasicHttpRequest
("CONNECT", mHost.toHostString());
- // add all 'proxy' headers from the original request
+ // add all 'proxy' headers from the original request, we also need
+ // to add 'host' header unless we want proxy to answer us with a
+ // 400 Bad Request
for (Header h : req.mHttpRequest.getAllHeaders()) {
String headerName = h.getName().toLowerCase();
- if (headerName.startsWith("proxy") || headerName.equals("keep-alive")) {
+ if (headerName.startsWith("proxy") || headerName.equals("keep-alive")
+ || headerName.equals("host")) {
proxyReq.addHeader(h);
}
}
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index 2e14667..86f9a6b 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -94,7 +94,8 @@
/**
* Default trace file path and file
*/
- private static final String DEFAULT_TRACE_PATH_PREFIX = "/sdcard/";
+ private static final String DEFAULT_TRACE_PATH_PREFIX =
+ Environment.getExternalStorageDirectory().getPath() + "/";
private static final String DEFAULT_TRACE_BODY = "dmtrace";
private static final String DEFAULT_TRACE_EXTENSION = ".trace";
private static final String DEFAULT_TRACE_FILE_PATH =
@@ -127,7 +128,7 @@
public int otherPrivateDirty;
/** The shared dirty pages used by everything else. */
public int otherSharedDirty;
-
+
public MemoryInfo() {
}
@@ -137,21 +138,21 @@
public int getTotalPss() {
return dalvikPss + nativePss + otherPss;
}
-
+
/**
* Return total private dirty memory usage in kB.
*/
public int getTotalPrivateDirty() {
return dalvikPrivateDirty + nativePrivateDirty + otherPrivateDirty;
}
-
+
/**
* Return total shared dirty memory usage in kB.
*/
public int getTotalSharedDirty() {
return dalvikSharedDirty + nativeSharedDirty + otherSharedDirty;
}
-
+
public int describeContents() {
return 0;
}
@@ -179,7 +180,7 @@
otherPrivateDirty = source.readInt();
otherSharedDirty = source.readInt();
}
-
+
public static final Creator<MemoryInfo> CREATOR = new Creator<MemoryInfo>() {
public MemoryInfo createFromParcel(Parcel source) {
return new MemoryInfo(source);
@@ -460,7 +461,7 @@
* Like startMethodTracing(String, int, int), but taking an already-opened
* FileDescriptor in which the trace is written. The file name is also
* supplied simply for logging. Makes a dup of the file descriptor.
- *
+ *
* Not exposed in the SDK unless we are really comfortable with supporting
* this and find it would be useful.
* @hide
@@ -1070,7 +1071,7 @@
* static {
* // Sets all the fields
* Debug.setFieldsOn(MyDebugVars.class);
- *
+ *
* // Sets only the fields annotated with @Debug.DebugProperty
* // Debug.setFieldsOn(MyDebugVars.class, true);
* }
diff --git a/core/java/android/preference/ListPreference.java b/core/java/android/preference/ListPreference.java
index f842d75..f44cbe4 100644
--- a/core/java/android/preference/ListPreference.java
+++ b/core/java/android/preference/ListPreference.java
@@ -39,6 +39,7 @@
private CharSequence[] mEntries;
private CharSequence[] mEntryValues;
private String mValue;
+ private String mSummary;
private int mClickedDialogEntryIndex;
public ListPreference(Context context, AttributeSet attrs) {
@@ -49,8 +50,16 @@
mEntries = a.getTextArray(com.android.internal.R.styleable.ListPreference_entries);
mEntryValues = a.getTextArray(com.android.internal.R.styleable.ListPreference_entryValues);
a.recycle();
+
+ /* Retrieve the Preference summary attribute since it's private
+ * in the Preference class.
+ */
+ a = context.obtainStyledAttributes(attrs,
+ com.android.internal.R.styleable.Preference, 0, 0);
+ mSummary = a.getString(com.android.internal.R.styleable.Preference_summary);
+ a.recycle();
}
-
+
public ListPreference(Context context) {
this(context, null);
}
@@ -127,6 +136,43 @@
}
/**
+ * Returns the summary of this ListPreference. If the summary
+ * has a {@linkplain java.lang.String#format String formatting}
+ * marker in it (i.e. "%s" or "%1$s"), then the current entry
+ * value will be substituted in its place.
+ *
+ * @return the summary with appropriate string substitution
+ */
+ @Override
+ public CharSequence getSummary() {
+ final CharSequence entry = getEntry();
+ if (mSummary == null || entry == null) {
+ return super.getSummary();
+ } else {
+ return String.format(mSummary, entry);
+ }
+ }
+
+ /**
+ * Sets the summary for this Preference with a CharSequence.
+ * If the summary has a
+ * {@linkplain java.lang.String#format String formatting}
+ * marker in it (i.e. "%s" or "%1$s"), then the current entry
+ * value will be substituted in its place when it's retrieved.
+ *
+ * @param summary The summary for the preference.
+ */
+ @Override
+ public void setSummary(CharSequence summary) {
+ super.setSummary(summary);
+ if (summary == null && mSummary != null) {
+ mSummary = null;
+ } else if (summary != null && !summary.equals(mSummary)) {
+ mSummary = summary.toString();
+ }
+ }
+
+ /**
* Sets the value to the given index from the entry values.
*
* @param index The index of the value to set.
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 7bb89f5..ea4738f 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3534,7 +3534,7 @@
while (intent == null && c.moveToNext()) {
try {
String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
- intent = Intent.getIntent(intentURI);
+ intent = Intent.parseUri(intentURI, 0);
} catch (java.net.URISyntaxException e) {
// The stored URL is bad... ignore it.
} catch (IllegalArgumentException e) {
@@ -3592,7 +3592,7 @@
ContentValues values = new ContentValues();
if (title != null) values.put(TITLE, title);
if (folder != null) values.put(FOLDER, folder);
- values.put(INTENT, intent.toURI());
+ values.put(INTENT, intent.toUri(0));
if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
values.put(ORDERING, ordering);
return cr.insert(CONTENT_URI, values);
@@ -3644,7 +3644,7 @@
Intent intent;
try {
- intent = Intent.getIntent(intentUri);
+ intent = Intent.parseUri(intentUri, 0);
} catch (URISyntaxException e) {
return "";
}
diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java
index bf9e854..d271e93 100644
--- a/core/java/android/provider/Telephony.java
+++ b/core/java/android/provider/Telephony.java
@@ -25,6 +25,7 @@
import android.database.Cursor;
import android.database.sqlite.SqliteWrapper;
import android.net.Uri;
+import android.os.Environment;
import android.telephony.SmsMessage;
import android.text.TextUtils;
import android.util.Config;
@@ -1526,7 +1527,8 @@
* which streams the captured image to the uri. Internally we write the media content
* to this file. It's named '.temp.jpg' so Gallery won't pick it up.
*/
- public static final String SCRAP_FILE_PATH = "/sdcard/mms/scrapSpace/.temp.jpg";
+ public static final String SCRAP_FILE_PATH =
+ Environment.getExternalStorageDirectory().getPath() + "/mms/scrapSpace/.temp.jpg";
}
public static final class Intents {
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index e1d3f13..35a582d 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -30,6 +30,8 @@
import java.util.HashMap;
import java.util.Set;
+import android.os.PowerManager;
+
/**
* TODO: Move this to
@@ -51,6 +53,9 @@
private final BluetoothService mBluetoothService;
private final BluetoothAdapter mAdapter;
private final Context mContext;
+ // The WakeLock is used for bringing up the LCD during a pairing request
+ // from remote device when Android is in Suspend state.
+ private PowerManager.WakeLock mWakeLock;
private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1;
private static final int EVENT_RESTART_BLUETOOTH = 2;
@@ -121,6 +126,11 @@
mContext = context;
mPasskeyAgentRequestData = new HashMap();
mAdapter = adapter;
+ //WakeLock instantiation in BluetoothEventLoop class
+ PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
+ mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
+ | PowerManager.ON_AFTER_RELEASE, TAG);
+ mWakeLock.setReferenceCounted(false);
initializeNativeDataNative();
}
@@ -458,37 +468,46 @@
mHandler.sendMessageDelayed(message, 1500);
return;
}
-
+ // Acquire wakelock during PIN code request to bring up LCD display
+ mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_CONSENT);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
+ // Release wakelock to allow the LCD to go off after the PIN popup notifcation.
+ mWakeLock.release();
return;
}
private void onRequestPasskeyConfirmation(String objectPath, int passkey, int nativeData) {
String address = checkPairingRequestAndGetAddress(objectPath, nativeData);
if (address == null) return;
-
+ // Acquire wakelock during PIN code request to bring up LCD display
+ mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey);
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
+ // Release wakelock to allow the LCD to go off after the PIN popup notifcation.
+ mWakeLock.release();
return;
}
private void onRequestPasskey(String objectPath, int nativeData) {
String address = checkPairingRequestAndGetAddress(objectPath, nativeData);
if (address == null) return;
-
+ // Acquire wakelock during PIN code request to bring up LCD display
+ mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_PASSKEY);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
+ // Release wakelock to allow the LCD to go off after the PIN popup notifcation.
+ mWakeLock.release();
return;
}
@@ -526,10 +545,14 @@
}
}
}
+ // Acquire wakelock during PIN code request to bring up LCD display
+ mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
+ // Release wakelock to allow the LCD to go off after the PIN popup notifcation.
+ mWakeLock.release();
return;
}
@@ -537,12 +560,16 @@
String address = checkPairingRequestAndGetAddress(objectPath, nativeData);
if (address == null) return;
+ // Acquire wakelock during PIN code request to bring up LCD display
+ mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey);
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
+ //Release wakelock to allow the LCD to go off after the PIN popup notifcation.
+ mWakeLock.release();
}
private boolean onAgentAuthorize(String objectPath, String deviceUuid) {
diff --git a/core/java/android/text/format/DateUtils.java b/core/java/android/text/format/DateUtils.java
index dde0889..89b3cba 100644
--- a/core/java/android/text/format/DateUtils.java
+++ b/core/java/android/text/format/DateUtils.java
@@ -496,7 +496,7 @@
}
}
} else if (duration < WEEK_IN_MILLIS && minResolution < WEEK_IN_MILLIS) {
- count = duration / DAY_IN_MILLIS;
+ count = getNumberOfDaysPassed(time, now);
if (past) {
if (abbrevRelative) {
resId = com.android.internal.R.plurals.abbrev_num_days_ago;
@@ -521,6 +521,24 @@
}
/**
+ * Returns the number of days passed between two dates.
+ *
+ * @param date1 first date
+ * @param date2 second date
+ * @return number of days passed between to dates.
+ */
+ private synchronized static long getNumberOfDaysPassed(long date1, long date2) {
+ if (sThenTime == null) {
+ sThenTime = new Time();
+ }
+ sThenTime.set(date1);
+ int day1 = Time.getJulianDay(date1, sThenTime.gmtoff);
+ sThenTime.set(date2);
+ int day2 = Time.getJulianDay(date2, sThenTime.gmtoff);
+ return Math.abs(day2 - day1);
+ }
+
+ /**
* Return string describing the elapsed time since startTime formatted like
* "[relative time/date], [time]".
* <p>
@@ -1550,40 +1568,45 @@
public static CharSequence getRelativeTimeSpanString(Context c, long millis,
boolean withPreposition) {
+ String result;
long now = System.currentTimeMillis();
long span = now - millis;
- if (sNowTime == null) {
- sNowTime = new Time();
- sThenTime = new Time();
- }
+ synchronized (DateUtils.class) {
+ if (sNowTime == null) {
+ sNowTime = new Time();
+ }
- sNowTime.set(now);
- sThenTime.set(millis);
+ if (sThenTime == null) {
+ sThenTime = new Time();
+ }
- String result;
- int prepositionId;
- if (span < DAY_IN_MILLIS && sNowTime.weekDay == sThenTime.weekDay) {
- // Same day
- int flags = FORMAT_SHOW_TIME;
- result = formatDateRange(c, millis, millis, flags);
- prepositionId = R.string.preposition_for_time;
- } else if (sNowTime.year != sThenTime.year) {
- // Different years
- int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE;
- result = formatDateRange(c, millis, millis, flags);
+ sNowTime.set(now);
+ sThenTime.set(millis);
- // This is a date (like "10/31/2008" so use the date preposition)
- prepositionId = R.string.preposition_for_date;
- } else {
- // Default
- int flags = FORMAT_SHOW_DATE | FORMAT_ABBREV_MONTH;
- result = formatDateRange(c, millis, millis, flags);
- prepositionId = R.string.preposition_for_date;
- }
- if (withPreposition) {
- Resources res = c.getResources();
- result = res.getString(prepositionId, result);
+ int prepositionId;
+ if (span < DAY_IN_MILLIS && sNowTime.weekDay == sThenTime.weekDay) {
+ // Same day
+ int flags = FORMAT_SHOW_TIME;
+ result = formatDateRange(c, millis, millis, flags);
+ prepositionId = R.string.preposition_for_time;
+ } else if (sNowTime.year != sThenTime.year) {
+ // Different years
+ int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE;
+ result = formatDateRange(c, millis, millis, flags);
+
+ // This is a date (like "10/31/2008" so use the date preposition)
+ prepositionId = R.string.preposition_for_date;
+ } else {
+ // Default
+ int flags = FORMAT_SHOW_DATE | FORMAT_ABBREV_MONTH;
+ result = formatDateRange(c, millis, millis, flags);
+ prepositionId = R.string.preposition_for_date;
+ }
+ if (withPreposition) {
+ Resources res = c.getResources();
+ result = res.getString(prepositionId, result);
+ }
}
return result;
}
diff --git a/core/java/android/text/format/Time.java b/core/java/android/text/format/Time.java
index 8eae111..c05a8fe 100644
--- a/core/java/android/text/format/Time.java
+++ b/core/java/android/text/format/Time.java
@@ -32,7 +32,7 @@
private static final String Y_M_D_T_H_M_S_000 = "%Y-%m-%dT%H:%M:%S.000";
private static final String Y_M_D_T_H_M_S_000_Z = "%Y-%m-%dT%H:%M:%S.000Z";
private static final String Y_M_D = "%Y-%m-%d";
-
+
public static final String TIMEZONE_UTC = "UTC";
/**
@@ -170,11 +170,11 @@
public Time() {
this(TimeZone.getDefault().getID());
}
-
+
/**
* A copy constructor. Construct a Time object by copying the given
* Time object. No normalization occurs.
- *
+ *
* @param other
*/
public Time(Time other) {
@@ -185,17 +185,17 @@
* Ensures the values in each field are in range. For example if the
* current value of this calendar is March 32, normalize() will convert it
* to April 1. It also fills in weekDay, yearDay, isDst and gmtoff.
- *
+ *
* <p>
* If "ignoreDst" is true, then this method sets the "isDst" field to -1
* (the "unknown" value) before normalizing. It then computes the
* correct value for "isDst".
- *
+ *
* <p>
* See {@link #toMillis(boolean)} for more information about when to
* use <tt>true</tt> or <tt>false</tt> for "ignoreDst".
- *
- * @return the UTC milliseconds since the epoch
+ *
+ * @return the UTC milliseconds since the epoch
*/
native public long normalize(boolean ignoreDst);
@@ -379,13 +379,13 @@
* Parses a date-time string in either the RFC 2445 format or an abbreviated
* format that does not include the "time" field. For example, all of the
* following strings are valid:
- *
+ *
* <ul>
* <li>"20081013T160000Z"</li>
* <li>"20081013T160000"</li>
* <li>"20081013"</li>
* </ul>
- *
+ *
* Returns whether or not the time is in UTC (ends with Z). If the string
* ends with "Z" then the timezone is set to UTC. If the date-time string
* included only a date and no time field, then the <code>allDay</code>
@@ -396,10 +396,10 @@
* <code>yearDay</code>, and <code>gmtoff</code> are always set to zero,
* and the field <code>isDst</code> is set to -1 (unknown). To set those
* fields, call {@link #normalize(boolean)} after parsing.
- *
+ *
* To parse a date-time string and convert it to UTC milliseconds, do
* something like this:
- *
+ *
* <pre>
* Time time = new Time();
* String date = "20081013T160000Z";
@@ -428,25 +428,25 @@
* Parse a time in RFC 3339 format. This method also parses simple dates
* (that is, strings that contain no time or time offset). For example,
* all of the following strings are valid:
- *
+ *
* <ul>
* <li>"2008-10-13T16:00:00.000Z"</li>
* <li>"2008-10-13T16:00:00.000+07:00"</li>
* <li>"2008-10-13T16:00:00.000-07:00"</li>
* <li>"2008-10-13"</li>
* </ul>
- *
+ *
* <p>
* If the string contains a time and time offset, then the time offset will
* be used to convert the time value to UTC.
* </p>
- *
+ *
* <p>
* If the given string contains just a date (with no time field), then
* the {@link #allDay} field is set to true and the {@link #hour},
* {@link #minute}, and {@link #second} fields are set to zero.
* </p>
- *
+ *
* <p>
* Returns true if the resulting time value is in UTC time.
* </p>
@@ -462,7 +462,7 @@
}
return false;
}
-
+
native private boolean nativeParse3339(String s);
/**
@@ -484,13 +484,13 @@
* <em>not</em> change any of the fields in this Time object. If you want
* to normalize the fields in this Time object and also get the milliseconds
* then use {@link #normalize(boolean)}.
- *
+ *
* <p>
* If "ignoreDst" is false, then this method uses the current setting of the
* "isDst" field and will adjust the returned time if the "isDst" field is
* wrong for the given time. See the sample code below for an example of
* this.
- *
+ *
* <p>
* If "ignoreDst" is true, then this method ignores the current setting of
* the "isDst" field in this Time object and will instead figure out the
@@ -499,27 +499,27 @@
* correct value of the "isDst" field is when the time is inherently
* ambiguous because it falls in the hour that is repeated when switching
* from Daylight-Saving Time to Standard Time.
- *
+ *
* <p>
* Here is an example where <tt>toMillis(true)</tt> adjusts the time,
* assuming that DST changes at 2am on Sunday, Nov 4, 2007.
- *
+ *
* <pre>
* Time time = new Time();
- * time.set(2007, 10, 4); // set the date to Nov 4, 2007, 12am
+ * time.set(4, 10, 2007); // set the date to Nov 4, 2007, 12am
* time.normalize(); // this sets isDst = 1
* time.monthDay += 1; // changes the date to Nov 5, 2007, 12am
* millis = time.toMillis(false); // millis is Nov 4, 2007, 11pm
* millis = time.toMillis(true); // millis is Nov 5, 2007, 12am
* </pre>
- *
+ *
* <p>
* To avoid this problem, use <tt>toMillis(true)</tt>
* after adding or subtracting days or explicitly setting the "monthDay"
* field. On the other hand, if you are adding
* or subtracting hours or minutes, then you should use
* <tt>toMillis(false)</tt>.
- *
+ *
* <p>
* You should also use <tt>toMillis(false)</tt> if you want
* to read back the same milliseconds that you set with {@link #set(long)}
@@ -531,14 +531,14 @@
* Sets the fields in this Time object given the UTC milliseconds. After
* this method returns, all the fields are normalized.
* This also sets the "isDst" field to the correct value.
- *
+ *
* @param millis the time in UTC milliseconds since the epoch.
*/
native public void set(long millis);
/**
* Format according to RFC 2445 DATETIME type.
- *
+ *
* <p>
* The same as format("%Y%m%dT%H%M%S").
*/
@@ -584,7 +584,7 @@
* Sets the date from the given fields. Also sets allDay to true.
* Sets weekDay, yearDay and gmtoff to 0, and isDst to -1.
* Call {@link #normalize(boolean)} if you need those.
- *
+ *
* @param monthDay the day of the month (in the range [1,31])
* @param month the zero-based month number (in the range [0,11])
* @param year the year
@@ -606,7 +606,7 @@
/**
* Returns true if the time represented by this Time object occurs before
* the given time.
- *
+ *
* @param that a given Time object to compare against
* @return true if this time is less than the given time
*/
@@ -618,7 +618,7 @@
/**
* Returns true if the time represented by this Time object occurs after
* the given time.
- *
+ *
* @param that a given Time object to compare against
* @return true if this time is greater than the given time
*/
@@ -632,12 +632,12 @@
* closest Thursday yearDay.
*/
private static final int[] sThursdayOffset = { -3, 3, 2, 1, 0, -1, -2 };
-
+
/**
* Computes the week number according to ISO 8601. The current Time
* object must already be normalized because this method uses the
* yearDay and weekDay fields.
- *
+ *
* <p>
* In IS0 8601, weeks start on Monday.
* The first week of the year (week 1) is defined by ISO 8601 as the
@@ -645,12 +645,12 @@
* Or equivalently, the week containing January 4. Or equivalently,
* the week with the year's first Thursday in it.
* </p>
- *
+ *
* <p>
* The week number can be calculated by counting Thursdays. Week N
* contains the Nth Thursday of the year.
* </p>
- *
+ *
* @return the ISO week number.
*/
public int getWeekNumber() {
@@ -661,7 +661,7 @@
if (closestThursday >= 0 && closestThursday <= 364) {
return closestThursday / 7 + 1;
}
-
+
// The week crosses a year boundary.
Time temp = new Time(this);
temp.monthDay += sThursdayOffset[weekDay];
@@ -670,7 +670,7 @@
}
/**
- * Return a string in the RFC 3339 format.
+ * Return a string in the RFC 3339 format.
* <p>
* If allDay is true, expresses the time as Y-M-D</p>
* <p>
@@ -691,13 +691,13 @@
int offset = (int)Math.abs(gmtoff);
int minutes = (offset % 3600) / 60;
int hours = offset / 3600;
-
+
return String.format("%s%s%02d:%02d", base, sign, hours, minutes);
}
}
-
+
/**
- * Returns true if the day of the given time is the epoch on the Julian Calendar
+ * Returns true if the day of the given time is the epoch on the Julian Calendar
* (January 1, 1970 on the Gregorian calendar).
*
* @param time the time to test
@@ -707,7 +707,7 @@
long millis = time.toMillis(true);
return getJulianDay(millis, 0) == EPOCH_JULIAN_DAY;
}
-
+
/**
* Computes the Julian day number, given the UTC milliseconds
* and the offset (in seconds) from UTC. The Julian day for a given
@@ -716,10 +716,10 @@
* what timezone is being used. The Julian day is useful for testing
* if two events occur on the same day and for determining the relative
* time of an event from the present ("yesterday", "3 days ago", etc.).
- *
+ *
* <p>
* Use {@link #toMillis(boolean)} to get the milliseconds.
- *
+ *
* @param millis the time in UTC milliseconds
* @param gmtoff the offset from UTC in seconds
* @return the Julian day
@@ -729,7 +729,7 @@
long julianDay = (millis + offsetMillis) / DateUtils.DAY_IN_MILLIS;
return (int) julianDay + EPOCH_JULIAN_DAY;
}
-
+
/**
* <p>Sets the time from the given Julian day number, which must be based on
* the same timezone that is set in this Time object. The "gmtoff" field
@@ -738,7 +738,7 @@
* After this method returns all the fields will be normalized and the time
* will be set to 12am at the beginning of the given Julian day.
* </p>
- *
+ *
* <p>
* The only exception to this is if 12am does not exist for that day because
* of daylight saving time. For example, Cairo, Eqypt moves time ahead one
@@ -746,7 +746,7 @@
* also change daylight saving time at 12am. In those cases, the time
* will be set to 1am.
* </p>
- *
+ *
* @param julianDay the Julian day in the timezone for this Time object
* @return the UTC milliseconds for the beginning of the Julian day
*/
@@ -756,13 +756,13 @@
// the day.
long millis = (julianDay - EPOCH_JULIAN_DAY) * DateUtils.DAY_IN_MILLIS;
set(millis);
-
+
// Figure out how close we are to the requested Julian day.
// We can't be off by more than a day.
int approximateDay = getJulianDay(millis, gmtoff);
int diff = julianDay - approximateDay;
monthDay += diff;
-
+
// Set the time to 12am and re-normalize.
hour = 0;
minute = 0;
diff --git a/core/java/android/webkit/MimeTypeMap.java b/core/java/android/webkit/MimeTypeMap.java
index ca9ad53..c1ac180 100644
--- a/core/java/android/webkit/MimeTypeMap.java
+++ b/core/java/android/webkit/MimeTypeMap.java
@@ -369,10 +369,13 @@
sMimeTypeMap.loadEntry("application/x-xfig", "fig");
sMimeTypeMap.loadEntry("application/xhtml+xml", "xhtml");
sMimeTypeMap.loadEntry("audio/3gpp", "3gpp");
+ sMimeTypeMap.loadEntry("audio/amr", "amr");
sMimeTypeMap.loadEntry("audio/basic", "snd");
sMimeTypeMap.loadEntry("audio/midi", "mid");
sMimeTypeMap.loadEntry("audio/midi", "midi");
sMimeTypeMap.loadEntry("audio/midi", "kar");
+ sMimeTypeMap.loadEntry("audio/midi", "xmf");
+ sMimeTypeMap.loadEntry("audio/mobile-xmf", "mxmf");
sMimeTypeMap.loadEntry("audio/mpeg", "mpga");
sMimeTypeMap.loadEntry("audio/mpeg", "mpega");
sMimeTypeMap.loadEntry("audio/mpeg", "mp2");
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index bf751f5..4ca210f 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -3831,6 +3831,16 @@
}
}
+ if (keyCode == KeyEvent.KEYCODE_PAGE_UP) {
+ pageUp(false);
+ return true;
+ }
+
+ if (keyCode == KeyEvent.KEYCODE_PAGE_DOWN) {
+ pageDown(false);
+ return true;
+ }
+
if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
switchOutDrawHistory();
diff --git a/core/java/android/widget/ArrayAdapter.java b/core/java/android/widget/ArrayAdapter.java
index 32e5504..03ada94 100644
--- a/core/java/android/widget/ArrayAdapter.java
+++ b/core/java/android/widget/ArrayAdapter.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Comparator;
import java.util.Collections;
@@ -83,7 +84,7 @@
*/
private boolean mNotifyOnChange = true;
- private Context mContext;
+ private Context mContext;
private ArrayList<T> mOriginalValues;
private ArrayFilter mFilter;
@@ -181,6 +182,44 @@
}
/**
+ * Adds the specified Collection at the end of the array.
+ *
+ * @param collection The Collection to add at the end of the array.
+ */
+ public void addAll(Collection<? extends T> collection) {
+ if (mOriginalValues != null) {
+ synchronized (mLock) {
+ mOriginalValues.addAll(collection);
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+ } else {
+ mObjects.addAll(collection);
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+ }
+
+ /**
+ * Adds the specified items at the end of the array.
+ *
+ * @param items The items to add at the end of the array.
+ */
+ public void addAll(T ... items) {
+ if (mOriginalValues != null) {
+ synchronized (mLock) {
+ for (T item : items) {
+ mOriginalValues.add(item);
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+ } else {
+ for (T item : items) {
+ mObjects.add(item);
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+ }
+
+ /**
* Inserts the specified object at the specified index in the array.
*
* @param object The object to insert into the array.
@@ -236,7 +275,7 @@
*/
public void sort(Comparator<? super T> comparator) {
Collections.sort(mObjects, comparator);
- if (mNotifyOnChange) notifyDataSetChanged();
+ if (mNotifyOnChange) notifyDataSetChanged();
}
/**
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 950012c..e6ed70a 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4510,6 +4510,9 @@
partialStartOffset = 0;
partialEndOffset = N;
} else {
+ // Now use the delta to determine the actual amount of text
+ // we need.
+ partialEndOffset += delta;
// Adjust offsets to ensure we contain full spans.
if (content instanceof Spanned) {
Spanned spanned = (Spanned)content;
@@ -4525,10 +4528,8 @@
}
}
outText.partialStartOffset = partialStartOffset;
- outText.partialEndOffset = partialEndOffset;
- // Now use the delta to determine the actual amount of text
- // we need.
- partialEndOffset += delta;
+ outText.partialEndOffset = partialEndOffset - delta;
+
if (partialStartOffset > N) {
partialStartOffset = N;
} else if (partialStartOffset < 0) {
@@ -4592,6 +4593,10 @@
+ ": " + ims.mTmpExtracted.text);
imm.updateExtractedText(this, req.token,
mInputMethodState.mTmpExtracted);
+ ims.mChangedStart = EXTRACT_UNKNOWN;
+ ims.mChangedEnd = EXTRACT_UNKNOWN;
+ ims.mChangedDelta = 0;
+ ims.mContentChanged = false;
return true;
}
}
@@ -6167,8 +6172,8 @@
ims.mChangedStart = start;
ims.mChangedEnd = start+before;
} else {
- if (ims.mChangedStart > start) ims.mChangedStart = start;
- if (ims.mChangedEnd < (start+before)) ims.mChangedEnd = start+before;
+ ims.mChangedStart = Math.min(ims.mChangedStart, start);
+ ims.mChangedEnd = Math.max(ims.mChangedEnd, start + before - ims.mChangedDelta);
}
ims.mChangedDelta += after-before;
}
diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java
index 107b145..4a0617c 100644
--- a/core/java/com/android/internal/app/AlertController.java
+++ b/core/java/com/android/internal/app/AlertController.java
@@ -435,6 +435,7 @@
View titleTemplate = mWindow.findViewById(R.id.title_template);
titleTemplate.setVisibility(View.GONE);
mIconView.setVisibility(View.GONE);
+ topPanel.setVisibility(View.GONE);
hasTitle = false;
}
}
diff --git a/core/java/com/android/internal/os/SamplingProfilerIntegration.java b/core/java/com/android/internal/os/SamplingProfilerIntegration.java
index 5f5c7a4..127fb23 100644
--- a/core/java/com/android/internal/os/SamplingProfilerIntegration.java
+++ b/core/java/com/android/internal/os/SamplingProfilerIntegration.java
@@ -85,7 +85,8 @@
pending = true;
snapshotWriter.execute(new Runnable() {
public void run() {
- String dir = "/sdcard/snapshots";
+ String dir =
+ Environment.getExternalStorageDirectory().getPath() + "/snapshots";
if (!dirMade) {
new File(dir).mkdirs();
if (new File(dir).isDirectory()) {
diff --git a/core/java/com/google/android/mms/pdu/PduParser.java b/core/java/com/google/android/mms/pdu/PduParser.java
index 21f0c93..8edfe52 100644
--- a/core/java/com/google/android/mms/pdu/PduParser.java
+++ b/core/java/com/google/android/mms/pdu/PduParser.java
@@ -163,6 +163,13 @@
// or "application/vnd.wap.multipart.related"
// or "application/vnd.wap.multipart.alternative"
return retrieveConf;
+ } else if (ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {
+ // "application/vnd.wap.multipart.alternative"
+ // should take only the first part.
+ PduPart firstPart = mBody.getPart(0);
+ mBody.removeAll();
+ mBody.addPart(0, firstPart);
+ return retrieveConf;
}
return null;
case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp
index feb0dad..50df9d3 100644
--- a/core/jni/android_net_NetUtils.cpp
+++ b/core/jni/android_net_NetUtils.cpp
@@ -22,29 +22,8 @@
#include <utils/Log.h>
#include <arpa/inet.h>
-extern "C" {
-int ifc_enable(const char *ifname);
-int ifc_disable(const char *ifname);
-int ifc_add_host_route(const char *ifname, uint32_t addr);
-int ifc_remove_host_routes(const char *ifname);
-int ifc_set_default_route(const char *ifname, uint32_t gateway);
-int ifc_get_default_route(const char *ifname);
-int ifc_remove_default_route(const char *ifname);
-int ifc_reset_connections(const char *ifname);
-int ifc_configure(const char *ifname, in_addr_t ipaddr, in_addr_t netmask, in_addr_t gateway, in_addr_t dns1, in_addr_t dns2);
-
-int dhcp_do_request(const char *ifname,
- in_addr_t *ipaddr,
- in_addr_t *gateway,
- in_addr_t *mask,
- in_addr_t *dns1,
- in_addr_t *dns2,
- in_addr_t *server,
- uint32_t *lease);
-int dhcp_stop(const char *ifname);
-int dhcp_release_lease(const char *ifname);
-char *dhcp_get_errmsg();
-}
+#include <netutils/ifc.h>
+#include <netutils/dhcp.h>
#define NETUTILS_PKG_NAME "android/net/NetworkUtils"
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp
index 46000c9..3fc0d58 100644
--- a/core/jni/android_net_wifi_Wifi.cpp
+++ b/core/jni/android_net_wifi_Wifi.cpp
@@ -30,23 +30,6 @@
static jboolean sScanModeActive = false;
-/*
- * The following remembers the jfieldID's of the fields
- * of the DhcpInfo Java object, so that we don't have
- * to look them up every time.
- */
-static struct fieldIds {
- jclass dhcpInfoClass;
- jmethodID constructorId;
- jfieldID ipaddress;
- jfieldID gateway;
- jfieldID netmask;
- jfieldID dns1;
- jfieldID dns2;
- jfieldID serverAddress;
- jfieldID leaseDuration;
-} dhcpInfoFieldIds;
-
static int doCommand(const char *cmd, char *replybuf, int replybuflen)
{
size_t reply_len = replybuflen - 1;
@@ -392,6 +375,20 @@
return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
}
+static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject clazz)
+{
+ char reply[256];
+ int power;
+
+ if (doCommand("DRIVER GETPOWER", reply, sizeof(reply)) != 0) {
+ return (jint)-1;
+ }
+ // reply comes back in the form "powermode = XX" where XX is the
+ // number we're interested in.
+ sscanf(reply, "%*s = %u", &power);
+ return (jint)power;
+}
+
static jboolean android_net_wifi_setNumAllowedChannelsCommand(JNIEnv* env, jobject clazz, jint numChannels)
{
char cmdstr[256];
@@ -479,28 +476,6 @@
return doBooleanCommand("BLACKLIST clear", "OK");
}
-static jboolean android_net_wifi_doDhcpRequest(JNIEnv* env, jobject clazz, jobject info)
-{
- jint ipaddr, gateway, mask, dns1, dns2, server, lease;
- jboolean succeeded = ((jboolean)::do_dhcp_request(&ipaddr, &gateway, &mask,
- &dns1, &dns2, &server, &lease) == 0);
- if (succeeded && dhcpInfoFieldIds.dhcpInfoClass != NULL) {
- env->SetIntField(info, dhcpInfoFieldIds.ipaddress, ipaddr);
- env->SetIntField(info, dhcpInfoFieldIds.gateway, gateway);
- env->SetIntField(info, dhcpInfoFieldIds.netmask, mask);
- env->SetIntField(info, dhcpInfoFieldIds.dns1, dns1);
- env->SetIntField(info, dhcpInfoFieldIds.dns2, dns2);
- env->SetIntField(info, dhcpInfoFieldIds.serverAddress, server);
- env->SetIntField(info, dhcpInfoFieldIds.leaseDuration, lease);
- }
- return succeeded;
-}
-
-static jstring android_net_wifi_getDhcpError(JNIEnv* env, jobject clazz)
-{
- return env->NewStringUTF(::get_dhcp_error_string());
-}
-
// ----------------------------------------------------------------------------
/*
@@ -540,6 +515,7 @@
{ "startPacketFiltering", "()Z", (void*) android_net_wifi_startPacketFiltering },
{ "stopPacketFiltering", "()Z", (void*) android_net_wifi_stopPacketFiltering },
{ "setPowerModeCommand", "(I)Z", (void*) android_net_wifi_setPowerModeCommand },
+ { "getPowerModeCommand", "()I", (void*) android_net_wifi_getPowerModeCommand },
{ "setNumAllowedChannelsCommand", "(I)Z", (void*) android_net_wifi_setNumAllowedChannelsCommand },
{ "getNumAllowedChannelsCommand", "()I", (void*) android_net_wifi_getNumAllowedChannelsCommand },
{ "setBluetoothCoexistenceModeCommand", "(I)Z",
@@ -556,9 +532,6 @@
{ "setScanResultHandlingCommand", "(I)Z", (void*) android_net_wifi_setScanResultHandlingCommand },
{ "addToBlacklistCommand", "(Ljava/lang/String;)Z", (void*) android_net_wifi_addToBlacklistCommand },
{ "clearBlacklistCommand", "()Z", (void*) android_net_wifi_clearBlacklistCommand },
-
- { "doDhcpRequest", "(Landroid/net/DhcpInfo;)Z", (void*) android_net_wifi_doDhcpRequest },
- { "getDhcpError", "()Ljava/lang/String;", (void*) android_net_wifi_getDhcpError },
};
int register_android_net_wifi_WifiManager(JNIEnv* env)
@@ -566,18 +539,6 @@
jclass wifi = env->FindClass(WIFI_PKG_NAME);
LOG_FATAL_IF(wifi == NULL, "Unable to find class " WIFI_PKG_NAME);
- dhcpInfoFieldIds.dhcpInfoClass = env->FindClass("android/net/DhcpInfo");
- if (dhcpInfoFieldIds.dhcpInfoClass != NULL) {
- dhcpInfoFieldIds.constructorId = env->GetMethodID(dhcpInfoFieldIds.dhcpInfoClass, "<init>", "()V");
- dhcpInfoFieldIds.ipaddress = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "ipAddress", "I");
- dhcpInfoFieldIds.gateway = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "gateway", "I");
- dhcpInfoFieldIds.netmask = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "netmask", "I");
- dhcpInfoFieldIds.dns1 = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "dns1", "I");
- dhcpInfoFieldIds.dns2 = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "dns2", "I");
- dhcpInfoFieldIds.serverAddress = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "serverAddress", "I");
- dhcpInfoFieldIds.leaseDuration = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "leaseDuration", "I");
- }
-
return AndroidRuntime::registerNativeMethods(env,
WIFI_PKG_NAME, gWifiMethods, NELEM(gWifiMethods));
}
diff --git a/core/tests/coretests/src/android/preference/ListPreferenceTest.java b/core/tests/coretests/src/android/preference/ListPreferenceTest.java
new file mode 100644
index 0000000..41f8e03
--- /dev/null
+++ b/core/tests/coretests/src/android/preference/ListPreferenceTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009 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 android.preference;
+
+import android.preference.ListPreference;
+import android.test.AndroidTestCase;
+
+public class ListPreferenceTest extends AndroidTestCase {
+ public void testListPreferenceSummaryFromEntries() {
+ String[] entries = { "one", "two", "three" };
+ String[] entryValues = { "1" , "2", "3" };
+ ListPreference lp = new ListPreference(getContext());
+ lp.setEntries(entries);
+ lp.setEntryValues(entryValues);
+
+ lp.setValue(entryValues[1]);
+ assertTrue(lp.getSummary() == null);
+
+ lp.setSummary("%1$s");
+ assertEquals(entries[1], lp.getSummary());
+
+ lp.setValue(entryValues[2]);
+ assertEquals(entries[2], lp.getSummary());
+
+ lp.setSummary(null);
+ assertTrue(lp.getSummary() == null);
+
+ lp.setSummary("The color is %1$s");
+ assertEquals("The color is " + entries[2], lp.getSummary());
+ }
+}
diff --git a/core/tests/hosttests/Android.mk b/core/tests/hosttests/Android.mk
index 0001201..07d99cb 100644
--- a/core/tests/hosttests/Android.mk
+++ b/core/tests/hosttests/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE := FrameworkCoreHostTests
-LOCAL_JAVA_LIBRARIES := hosttestlib ddmlib junit
+LOCAL_JAVA_LIBRARIES := hosttestlib ddmlib-prebuilt junit
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
index 91cbe2f..b225c37 100644
--- a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
+++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
@@ -16,32 +16,32 @@
package android.content.pm;
+import com.android.ddmlib.AdbCommandRejectedException;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.IShellOutputReceiver;
+import com.android.ddmlib.InstallException;
import com.android.ddmlib.Log;
import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.SyncService;
+import com.android.ddmlib.ShellCommandUnresponsiveException;
+import com.android.ddmlib.SyncException;
+import com.android.ddmlib.TimeoutException;
import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.SyncService.SyncResult;
import com.android.ddmlib.testrunner.ITestRunListener;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.hosttest.DeviceTestCase;
-import com.android.hosttest.DeviceTestSuite;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStreamReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.Runtime;
import java.lang.Process;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import junit.framework.Assert;
-import com.android.hosttest.DeviceTestCase;
/**
* Set of tests that verify host side install cases
@@ -119,8 +119,14 @@
* Helper method to run tests and return the listener that collected the results.
* @param pkgName Android application package for tests
* @return the {@link CollectingTestRunListener}
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- private CollectingTestRunListener doRunTests(String pkgName) throws IOException {
+ private CollectingTestRunListener doRunTests(String pkgName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(
pkgName, mDevice);
CollectingTestRunListener listener = new CollectingTestRunListener();
@@ -133,8 +139,14 @@
*
* @param pkgName Android application package for tests
* @return true if every test passed, false otherwise.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException {
+ public boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
CollectingTestRunListener listener = doRunTests(pkgName);
return listener.didAllTestsPass();
}
@@ -142,22 +154,26 @@
/**
* Helper method to push a file to device
* @param apkAppPrivatePath
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
*/
public void pushFile(final String localFilePath, final String destFilePath)
- throws IOException {
- SyncResult result = mDevice.getSyncService().pushFile(
- localFilePath, destFilePath, new NullSyncProgressMonitor());
- assertEquals(SyncService.RESULT_OK, result.getCode());
+ throws IOException, SyncException, TimeoutException, AdbCommandRejectedException {
+ mDevice.getSyncService().pushFile(localFilePath,
+ destFilePath, new NullSyncProgressMonitor());
}
/**
* Helper method to install a file
* @param localFilePath the absolute file system path to file on local host to install
* @param reinstall set to <code>true</code> if re-install of app should be performed
- * @throws IOException
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed
*/
- public void installFile(final String localFilePath, final boolean replace) throws IOException {
+ public void installFile(final String localFilePath, final boolean replace) throws IOException,
+ InstallException {
String result = mDevice.installPackage(localFilePath, replace);
assertEquals(null, result);
}
@@ -167,10 +183,11 @@
* @param localFilePath the absolute file system path to file on local host to install
* @param reinstall set to <code>true</code> if re-install of app should be performed
* @return the string output of the failed install attempt
- * @throws IOException
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed
*/
public String installFileFail(final String localFilePath, final boolean replace)
- throws IOException {
+ throws IOException, InstallException {
String result = mDevice.installPackage(localFilePath, replace);
assertNotNull(result);
return result;
@@ -180,10 +197,17 @@
* Helper method to install a file to device as forward locked
* @param localFilePath the absolute file system path to file on local host to install
* @param reinstall set to <code>true</code> if re-install of app should be performed
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public String installFileForwardLocked(final String localFilePath, final boolean replace)
- throws IOException {
+ throws IOException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
String remoteFilePath = mDevice.syncPackageToDevice(localFilePath);
InstallReceiver receiver = new InstallReceiver();
String cmd = String.format(replace ? "pm install -r -l \"%1$s\"" :
@@ -198,9 +222,14 @@
*
* @param destPath the absolute path of file on device to check
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesRemoteFileExist(String destPath) throws IOException {
+ public boolean doesRemoteFileExist(String destPath) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
String lsGrep = executeShellCommand(String.format("ls %s", destPath));
return !lsGrep.contains("No such file or directory");
}
@@ -211,10 +240,15 @@
* @param destPath the absolute path of the file
* @return <code>true</code> if file exists containing given string,
* <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
public boolean doesRemoteFileExistContainingString(String destPath, String searchString)
- throws IOException {
+ throws IOException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
String lsResult = executeShellCommand(String.format("ls %s", destPath));
return lsResult.contains(searchString);
}
@@ -224,9 +258,14 @@
*
* @param packageName the Android manifest package to check.
* @return <code>true</code> if package exists, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesPackageExist(String packageName) throws IOException {
+ public boolean doesPackageExist(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
String pkgGrep = executeShellCommand(String.format("pm path %s", packageName));
return pkgGrep.contains("package:");
}
@@ -236,9 +275,14 @@
*
* @param packageName package name to check for
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesAppExistOnDevice(String packageName) throws IOException {
+ public boolean doesAppExistOnDevice(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(DEVICE_APP_PATH, packageName);
}
@@ -247,9 +291,14 @@
*
* @param packageName package name to check for
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesAppExistOnSDCard(String packageName) throws IOException {
+ public boolean doesAppExistOnSDCard(String packageName) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(SDCARD_APP_PATH, packageName);
}
@@ -258,9 +307,14 @@
*
* @param packageName package name to check for
* @return <code>true</code> if file exists, <code>false</code> otherwise.
- * @throws IOException if adb shell command failed
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public boolean doesAppExistAsForwardLocked(String packageName) throws IOException {
+ public boolean doesAppExistAsForwardLocked(String packageName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
return doesRemoteFileExistContainingString(APP_PRIVATE_PATH, packageName);
}
@@ -268,9 +322,14 @@
* Waits for device's package manager to respond.
*
* @throws InterruptedException
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void waitForPackageManager() throws InterruptedException, IOException {
+ public void waitForPackageManager() throws InterruptedException, IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "waiting for device");
int currentWaitTime = 0;
// poll the package manager until it returns something for android
@@ -336,9 +395,14 @@
*
* @param packageName The name of the package to wait to load
* @throws InterruptedException
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void waitForApp(String packageName) throws InterruptedException, IOException {
+ public void waitForApp(String packageName) throws InterruptedException, IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "waiting for app to launch");
int currentWaitTime = 0;
// poll the package manager until it returns something for the package we're looking for
@@ -355,9 +419,14 @@
/**
* Helper method which executes a adb shell command and returns output as a {@link String}
* @return the output of the command
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public String executeShellCommand(String command) throws IOException {
+ public String executeShellCommand(String command) throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, String.format("adb shell %s", command));
CollectingOutputReceiver receiver = new CollectingOutputReceiver();
mDevice.executeShellCommand(command, receiver);
@@ -369,9 +438,14 @@
/**
* Helper method ensures we are in root mode on the host side. It returns only after
* PackageManager is actually up and running.
- * @throws IOException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void runAdbRoot() throws IOException, InterruptedException {
+ public void runAdbRoot() throws IOException, InterruptedException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "adb root");
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("adb root"); // adb should be in the path
@@ -389,10 +463,15 @@
/**
* Helper method which reboots the device and returns once the device is online again
* and package manager is up and running (note this function is synchronous to callers).
- * @throws IOException
* @throws InterruptedException
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void rebootDevice() throws IOException, InterruptedException {
+ public void rebootDevice() throws IOException, InterruptedException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
String command = "reboot"; // no need for -s since mDevice is already tied to a device
Log.i(LOG_TAG, command);
CollectingOutputReceiver receiver = new CollectingOutputReceiver();
@@ -468,7 +547,7 @@
mAllTestsPassed = false;
}
- public void testRunEnded(long elapsedTime) {
+ public void testRunEnded(long elapsedTime, Map<String, String> resultBundle) {
// ignore
}
@@ -545,17 +624,23 @@
/**
* Helper method for installing an app to wherever is specified in its manifest, and
* then verifying the app was installed onto SD Card.
+ * <p/>
+ * Assumes adb is running as root in device under test.
*
* @param the path of the apk to install
* @param the name of the package
* @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
- * <p/>
- * Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppAndVerifyExistsOnSDCard(String apkPath, String pkgName, boolean overwrite)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
// Start with a clean slate if we're not overwriting
if (!overwrite) {
// cleanup test app just in case it already exists
@@ -576,17 +661,23 @@
/**
* Helper method for installing an app to wherever is specified in its manifest, and
* then verifying the app was installed onto device.
+ * <p/>
+ * Assumes adb is running as root in device under test.
*
* @param the path of the apk to install
* @param the name of the package
* @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
- * <p/>
- * Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppAndVerifyExistsOnDevice(String apkPath, String pkgName, boolean overwrite)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
// Start with a clean slate if we're not overwriting
if (!overwrite) {
// cleanup test app just in case it already exists
@@ -607,17 +698,24 @@
/**
* Helper method for installing an app as forward-locked, and
* then verifying the app was installed in the proper forward-locked location.
+ * <p/>
+ * Assumes adb is running as root in device under test.
*
* @param the path of the apk to install
* @param the name of the package
* @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
- * <p/>
- * Assumes adb is running as root in device under test.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
*/
public void installFwdLockedAppAndVerifyExists(String apkPath,
- String pkgName, boolean overwrite) throws IOException, InterruptedException {
+ String pkgName, boolean overwrite) throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
// Start with a clean slate if we're not overwriting
if (!overwrite) {
// cleanup test app just in case it already exists
@@ -638,14 +736,21 @@
/**
* Helper method for uninstalling an app.
- *
- * @param pkgName package name to uninstall
- * @throws IOException if adb shell command failed
- * @throws InterruptedException if the thread was interrupted
* <p/>
* Assumes adb is running as root in device under test.
+ *
+ * @param pkgName package name to uninstall
+ * @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the uninstall failed.
*/
- public void uninstallApp(String pkgName) throws IOException, InterruptedException {
+ public void uninstallApp(String pkgName) throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
mDevice.uninstallPackage(pkgName);
// make sure its not installed anymore
assertFalse(doesPackageExist(pkgName));
@@ -655,12 +760,18 @@
* Helper method for clearing any installed non-system apps.
* Useful ensuring no non-system apps are installed, and for cleaning up stale files that
* may be lingering on the system for whatever reason.
- *
- * @throws IOException if adb shell command failed
* <p/>
* Assumes adb is running as root in device under test.
+ *
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the uninstall failed.
*/
- public void wipeNonSystemApps() throws IOException {
+ public void wipeNonSystemApps() throws IOException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException, InstallException {
String allInstalledPackages = executeShellCommand("pm list packages -f");
BufferedReader outputReader = new BufferedReader(new StringReader(allInstalledPackages));
@@ -685,8 +796,14 @@
*
* <p/>
* Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public void setDevicePreferredInstallLocation(InstallLocPreference pref) throws IOException {
+ public void setDevicePreferredInstallLocation(InstallLocPreference pref) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
String command = "pm setInstallLocation %d";
int locValue = 0;
switch (pref) {
@@ -708,8 +825,14 @@
*
* <p/>
* Assumes adb is running as root in device under test.
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
*/
- public InstallLocPreference getDevicePreferredInstallLocation() throws IOException {
+ public InstallLocPreference getDevicePreferredInstallLocation() throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
String result = executeShellCommand("pm getInstallLocation");
if (result.indexOf('0') != -1) {
return InstallLocPreference.AUTO;
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java
index 1b797d5..22a2be6 100644
--- a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java
+++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java
@@ -16,13 +16,12 @@
package android.content.pm;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
+import com.android.ddmlib.AdbCommandRejectedException;
+import com.android.ddmlib.InstallException;
import com.android.ddmlib.Log;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.SyncService.SyncResult;
+import com.android.ddmlib.ShellCommandUnresponsiveException;
+import com.android.ddmlib.SyncException;
+import com.android.ddmlib.TimeoutException;
import com.android.hosttest.DeviceTestCase;
import com.android.hosttest.DeviceTestSuite;
@@ -156,10 +155,18 @@
* the app, and otherwise cause the system to blow up.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testPushAppPrivate() throws IOException, InterruptedException {
+ public void testPushAppPrivate() throws IOException, InterruptedException, InstallException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ SyncException {
Log.i(LOG_TAG, "testing pushing an apk to /data/app-private");
final String apkAppPrivatePath = appPrivatePath + SIMPLE_APK;
@@ -187,12 +194,18 @@
* @param apkName the file name of the test app apk
* @param pkgName the package name of the test app apk
* @param expectedLocation the file name of the test app apk
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
private void doStandardInstall(String apkName, String pkgName,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
if (expectedLocation == PackageManagerHostTestUtils.InstallLocation.DEVICE) {
mPMHostUtils.installAppAndVerifyExistsOnDevice(
@@ -211,12 +224,18 @@
* Assumes adb is running as root in device under test.
* @param preference the device's preferred location of where to install apps
* @param expectedLocation the expected location of where the apk was installed
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference preference,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
PackageManagerHostTestUtils.InstallLocPreference savedPref =
PackageManagerHostTestUtils.InstallLocPreference.AUTO;
@@ -239,10 +258,16 @@
* will install the app to the device when device's preference is auto.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppAutoLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppAutoLocPrefIsAuto() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=auto, prefer=auto gets installed on device");
installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference.AUTO,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -253,10 +278,17 @@
* will install the app to the device when device's preference is internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppAutoLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppAutoLocPrefIsInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=auto, prefer=internal gets installed on device");
installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference.INTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -267,10 +299,17 @@
* will install the app to the SD card when device's preference is external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppAutoLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppAutoLocPrefIsExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=auto, prefer=external gets installed on device");
installAppAutoLoc(PackageManagerHostTestUtils.InstallLocPreference.EXTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -283,12 +322,18 @@
* Assumes adb is running as root in device under test.
* @param preference the device's preferred location of where to install apps
* @param expectedLocation the expected location of where the apk was installed
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the (un)install failed.
*/
public void installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference preference,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
PackageManagerHostTestUtils.InstallLocPreference savedPref =
PackageManagerHostTestUtils.InstallLocPreference.AUTO;
@@ -311,10 +356,17 @@
* will install the app to the device when device's preference is auto.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppInternalLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppInternalLocPrefIsAuto() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=internal, prefer=auto gets installed on device");
installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference.AUTO,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -325,10 +377,17 @@
* will install the app to the device when device's preference is internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppInternalLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppInternalLocPrefIsInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=internal, prefer=internal is installed on device");
installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference.INTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -339,10 +398,17 @@
* will install the app to the device when device's preference is external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppInternalLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppInternalLocPrefIsExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=internal, prefer=external is installed on device");
installAppInternalLoc(PackageManagerHostTestUtils.InstallLocPreference.EXTERNAL,
PackageManagerHostTestUtils.InstallLocation.DEVICE);
@@ -355,12 +421,18 @@
* Assumes adb is running as root in device under test.
* @param preference the device's preferred location of where to install apps
* @param expectedLocation the expected location of where the apk was installed
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference preference,
PackageManagerHostTestUtils.InstallLocation expectedLocation)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException, InstallException {
PackageManagerHostTestUtils.InstallLocPreference savedPref =
PackageManagerHostTestUtils.InstallLocPreference.AUTO;
@@ -384,10 +456,17 @@
* will install the app to the device when device's preference is auto.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppExternalLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppExternalLocPrefIsAuto() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=external, pref=auto gets installed on SD Card");
installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference.AUTO,
PackageManagerHostTestUtils.InstallLocation.SDCARD);
@@ -398,10 +477,17 @@
* will install the app to the device when device's preference is internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppExternalLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppExternalLocPrefIsInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=external, pref=internal gets installed on SD Card");
installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference.INTERNAL,
PackageManagerHostTestUtils.InstallLocation.SDCARD);
@@ -412,10 +498,17 @@
* will install the app to the device when device's preference is external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppExternalLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppExternalLocPrefIsExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installLocation=external, pref=external gets installed on SD Card");
installAppExternalLoc(PackageManagerHostTestUtils.InstallLocPreference.EXTERNAL,
PackageManagerHostTestUtils.InstallLocation.SDCARD);
@@ -427,10 +520,17 @@
* system decide.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppNoLocPrefIsAuto() throws IOException, InterruptedException {
+ public void testInstallAppNoLocPrefIsAuto() throws IOException, InterruptedException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ InstallException {
Log.i(LOG_TAG, "Test an app with no installLocation gets installed on device");
PackageManagerHostTestUtils.InstallLocPreference savedPref =
@@ -456,10 +556,17 @@
* external.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppNoLocPrefIsExternal() throws IOException, InterruptedException {
+ public void testInstallAppNoLocPrefIsExternal() throws IOException, InterruptedException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ InstallException {
Log.i(LOG_TAG, "Test an app with no installLocation gets installed on SD card");
PackageManagerHostTestUtils.InstallLocPreference savedPref =
@@ -485,10 +592,17 @@
* internal.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testInstallAppNoLocPrefIsInternal() throws IOException, InterruptedException {
+ public void testInstallAppNoLocPrefIsInternal() throws IOException, InterruptedException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
+ InstallException {
Log.i(LOG_TAG, "Test an app with no installLocation gets installed on device");
PackageManagerHostTestUtils.InstallLocPreference savedPref =
@@ -513,10 +627,18 @@
* forward-locked will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppInternal() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppInternal() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with installLoc set to Internal gets installed to app-private");
try {
@@ -534,10 +656,18 @@
* forward-locked will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppExternal() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppExternal() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with installLoc set to Internal gets installed to app-private");
try {
@@ -555,10 +685,18 @@
* forward-locked will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppAuto() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppAuto() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with installLoc set to Auto gets installed to app-private");
try {
@@ -576,10 +714,18 @@
* forward-locked installed will get installed to the correct location.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
- public void testInstallFwdLockedAppNone() throws IOException, InterruptedException {
+ public void testInstallFwdLockedAppNone() throws IOException, InterruptedException,
+ InstallException, SyncException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test an app with no installLoc set gets installed to app-private");
try {
@@ -597,14 +743,21 @@
* uninstall it, and reinstall it onto the SD card.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
// TODO: This currently relies on the app's manifest to switch from device to
// SD card install locations. We might want to make Device's installPackage()
// accept a installLocation flag so we can install a package to the
// destination of our choosing.
- public void testReinstallInternalToExternal() throws IOException, InterruptedException {
+ public void testReinstallInternalToExternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing an app first to the device, then to the SD Card");
try {
@@ -625,14 +778,21 @@
* uninstall it, and reinstall it onto the device.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
// TODO: This currently relies on the app's manifest to switch from device to
// SD card install locations. We might want to make Device's installPackage()
// accept a installLocation flag so we can install a package to the
// destination of our choosing.
- public void testReinstallExternalToInternal() throws IOException, InterruptedException {
+ public void testReinstallExternalToInternal() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing an app first to the SD Care, then to the device");
try {
@@ -655,10 +815,16 @@
* the update onto the SD card as well when location is set to external for both versions
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testUpdateBothExternal() throws IOException, InterruptedException {
+ public void testUpdateBothExternal() throws IOException, InterruptedException, InstallException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card stays on the SD card");
try {
@@ -681,10 +847,16 @@
* updated apps' manifest file.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testUpdateToSDCard() throws IOException, InterruptedException {
+ public void testUpdateToSDCard() throws IOException, InterruptedException, InstallException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card stays on the SD card");
try {
@@ -706,10 +878,17 @@
* the update onto the device if the manifest has changed to installLocation=internalOnly
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
- public void testUpdateSDCardToDevice() throws IOException, InterruptedException {
+ public void testUpdateSDCardToDevice() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card to the Device through manifest change");
try {
@@ -731,11 +910,18 @@
* the update onto the device's forward-locked location
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndUpdateExternalLocForwardLockedApp()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, SyncException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating a forward-locked app marked preferExternal");
try {
@@ -757,11 +943,18 @@
* the update onto the device's forward-locked location
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndUpdateNoLocForwardLockedApp()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, SyncException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating a forward-locked app with no installLocation pref set");
try {
@@ -783,11 +976,18 @@
* and then launched without crashing.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws SyncException if the sync failed for another reason.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchAllPermsAppOnSD()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with all perms set, installed on SD card");
try {
@@ -808,11 +1008,17 @@
* run without permissions errors.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchFLPermsAppOnSD()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with location perms set, installed on SD card");
try {
@@ -833,11 +1039,17 @@
* run without permissions errors.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchBTPermsAppOnSD()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with bluetooth perms set, installed on SD card");
try {
@@ -858,11 +1070,17 @@
* SecurityException when launched if its other shared apps are not installed.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchSharedPermsAppOnSD_NoPerms()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with no explicit perms set, installed on SD card");
try {
@@ -888,11 +1106,17 @@
* shared apps are installed.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchSharedPermsAppOnSD_GrantedPerms()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with no explicit perms set, installed on SD card");
try {
@@ -921,11 +1145,17 @@
* run without permissions errors even after a reboot
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchFLPermsAppOnSD_Reboot()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app with location perms set, installed on SD card");
try {
@@ -951,11 +1181,17 @@
* shared apps are installed, even after a reboot.
* <p/>
* Assumes adb is running as root in device under test.
- * @throws IOException if adb shell command failed
* @throws InterruptedException if the thread was interrupted
+ * @throws TimeoutException in case of a timeout on the connection.
+ * @throws AdbCommandRejectedException if adb rejects the command
+ * @throws ShellCommandUnresponsiveException if the device did not output anything for
+ * a period longer than the max time to output.
+ * @throws IOException if connection to device was lost.
+ * @throws InstallException if the install failed.
*/
public void testInstallAndLaunchSharedPermsAppOnSD_Reboot()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException, InstallException, TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test launching an app on SD, with no explicit perms set after reboot");
try {
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java b/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java
index 715c55b..a2a5dd3 100644
--- a/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java
+++ b/core/tests/hosttests/src/android/content/pm/PackageManagerStressHostTests.java
@@ -16,8 +16,11 @@
package android.content.pm;
-import com.android.ddmlib.IDevice;
+import com.android.ddmlib.AdbCommandRejectedException;
+import com.android.ddmlib.InstallException;
import com.android.ddmlib.Log;
+import com.android.ddmlib.ShellCommandUnresponsiveException;
+import com.android.ddmlib.TimeoutException;
import com.android.hosttest.DeviceTestCase;
import com.android.hosttest.DeviceTestSuite;
@@ -138,7 +141,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testUpdateAppManyTimesOnSD() throws IOException, InterruptedException {
+ public void testUpdateAppManyTimesOnSD() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on SD numerous times");
// cleanup test app just in case it already exists
@@ -173,7 +178,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testUninstallReinstallAppOnSDManyTimes() throws IOException, InterruptedException {
+ public void testUninstallReinstallAppOnSDManyTimes() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test updating an app on the SD card stays on the SD card");
// cleanup test app just in case it was already exists
@@ -207,7 +214,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testInstallManyLargeAppsOnSD() throws IOException, InterruptedException {
+ public void testInstallManyLargeAppsOnSD() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing 20 large apps onto the sd card");
try {
@@ -251,7 +260,9 @@
* <p/>
* Assumes adb is running as root in device under test.
*/
- public void testInstallManyAppsOnSD() throws IOException, InterruptedException {
+ public void testInstallManyAppsOnSD() throws IOException, InterruptedException,
+ InstallException, TimeoutException, AdbCommandRejectedException,
+ ShellCommandUnresponsiveException {
Log.i(LOG_TAG, "Test installing 500 small apps onto SD");
try {
diff --git a/docs/html/community/index.jd b/docs/html/community/index.jd
index 3e69de4..23203c1 100644
--- a/docs/html/community/index.jd
+++ b/docs/html/community/index.jd
@@ -4,10 +4,10 @@
<div id="mainBodyFluid">
<h1>Community</h1>
-<p>Welcome to the Android developers community! We're glad you're here and invite you to participate in these discussions. Before posting, please read the <a href="http://source.android.com/discuss/android-discussion-groups-charter">Groups Charter</a> that covers the community guidelines.</p>
+<p>Welcome to the Android developers community! We're glad you're here and invite you to participate in these discussions. Before posting, please read the <a href="http://source.android.com/community/groups-charter.html">Groups Charter</a> that covers the community guidelines.</p>
<p class="note"><strong>Note:</strong> If you are seeking discussion about Android source code (not application development),
-then please refer to the <a href="http://source.android.com/discuss">Open Source Project Mailing lists</a>.</p>
+then please refer to the <a href="http://source.android.com/community">Open Source Project Mailing lists</a>.</p>
<p style="margin-bottom:.5em"><strong>Contents</strong></p>
<ol class="toc">
@@ -31,7 +31,7 @@
As you write your post, please do the following:
<ol>
<li><b>Read
-the <a href="http://sites.google.com/a/android.com/opensource/discuss/android-discussion-groups-charter">mailing list charter</a></b> that covers the community guidelines.
+the <a href="http://source.android.com/community/groups-charter.html">mailing list charter</a></b> that covers the community guidelines.
</li>
<li><b>Select the most appropriate mailing list for your question</b>. There are several different lists for
developers, described below.</li>
diff --git a/docs/html/intl/ja/community/index.jd b/docs/html/intl/ja/community/index.jd
index 659aee7..490b23f 100644
--- a/docs/html/intl/ja/community/index.jd
+++ b/docs/html/intl/ja/community/index.jd
@@ -4,9 +4,9 @@
<div id="mainBodyFluid">
<h1>コミュニティ</h1>
- <p>Android デベロッパー コミュニティへようこそ。コミュニティでのディスカッションにぜひ参加してください。投稿する前に、コミュニティ ガイドラインが記載されている<a href="http://source.android.com/discuss/android-discussion-groups-charter">グループの趣意</a>をお読みください。</p>
+ <p>Android デベロッパー コミュニティへようこそ。コミュニティでのディスカッションにぜひ参加してください。投稿する前に、コミュニティ ガイドラインが記載されている<a href="http://source.android.com/community/groups-charter.html">グループの趣意</a>をお読みください。</p>
-<p class="note"><strong>注:</strong> Android ソース コード(アプリケーション開発ではなく)に関するディスカッションは、<a href="http://source.android.com/discuss">オープンソース プロジェクトのメーリング リスト</a>(英語)を参照してください。</p>
+<p class="note"><strong>注:</strong> Android ソース コード(アプリケーション開発ではなく)に関するディスカッションは、<a href="http://source.android.com/community">オープンソース プロジェクトのメーリング リスト</a>(英語)を参照してください。</p>
<p style="margin-bottom:.5em"><strong>目次</strong></p>
<ol class="toc">
@@ -28,7 +28,7 @@
<p>質問への答えが見つからない場合、コミュニティで質問することをおすすめします。投稿する際は、次の手順に従ってください。
<ol>
-<li>コミュニティ ガイドラインが記載されている<b><a href="http://sites.google.com/a/android.com/opensource/discuss/android-discussion-groups-charter">Android メーリングリストの趣意</a></b>をお読みください。
+<li>コミュニティ ガイドラインが記載されている<b><a href="http://source.android.com/community/groups-charter.html">Android メーリングリストの趣意</a></b>をお読みください。
</li>
<li><b>質問に最適なメーリング リストを選択してください</b>。後述するように、デベロッパー向けのメーリング リストは何種類かに分かれています。</li>
<li>
diff --git a/docs/html/intl/ja/resources/community-groups.jd b/docs/html/intl/ja/resources/community-groups.jd
index c99b1f8..ecedde1 100644
--- a/docs/html/intl/ja/resources/community-groups.jd
+++ b/docs/html/intl/ja/resources/community-groups.jd
@@ -4,9 +4,9 @@
<div id="mainBodyFluid">
<h1>コミュニティ</h1>
- <p>Android デベロッパー コミュニティへようこそ。コミュニティでのディスカッションにぜひ参加してください。投稿する前に、コミュニティ ガイドラインが記載されている<a href="http://source.android.com/discuss/android-discussion-groups-charter">グループの趣意</a>をお読みください。</p>
+ <p>Android デベロッパー コミュニティへようこそ。コミュニティでのディスカッションにぜひ参加してください。投稿する前に、コミュニティ ガイドラインが記載されている<a href="http://source.android.com/community/groups-charter.html">グループの趣意</a>をお読みください。</p>
-<p class="note"><strong>注:</strong> Android ソース コード(アプリケーション開発ではなく)に関するディスカッションは、<a href="http://source.android.com/discuss">オープンソース プロジェクトのメーリング リスト</a>(英語)を参照してください。</p>
+<p class="note"><strong>注:</strong> Android ソース コード(アプリケーション開発ではなく)に関するディスカッションは、<a href="http://source.android.com/community">オープンソース プロジェクトのメーリング リスト</a>(英語)を参照してください。</p>
<p style="margin-bottom:.5em"><strong>目次</strong></p>
<ol class="toc">
@@ -28,7 +28,7 @@
<p>質問への答えが見つからない場合、コミュニティで質問することをおすすめします。投稿する際は、次の手順に従ってください。
<ol>
-<li>コミュニティ ガイドラインが記載されている<b><a href="http://sites.google.com/a/android.com/opensource/discuss/android-discussion-groups-charter">Android メーリングリストの趣意</a></b>をお読みください。
+<li>コミュニティ ガイドラインが記載されている<b><a href="http://source.android.com/community/groups-charter.html">Android メーリングリストの趣意</a></b>をお読みください。
</li>
<li><b>質問に最適なメーリング リストを選択してください</b>。後述するように、デベロッパー向けのメーリング リストは何種類かに分かれています。</li>
<li>
diff --git a/docs/html/resources/articles/painless-threading.jd b/docs/html/resources/articles/painless-threading.jd
index 921f4df..17cec35 100644
--- a/docs/html/resources/articles/painless-threading.jd
+++ b/docs/html/resources/articles/painless-threading.jd
@@ -108,7 +108,7 @@
new DownloadImageTask().execute("http://example.com/image.png");
}
-private class DownloadImageTask extends AsyncTask<string, void,="" bitmap=""> {
+private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
protected Bitmap doInBackground(String... urls) {
return loadImageFromNetwork(urls[0]);
}
diff --git a/docs/html/resources/community-groups.jd b/docs/html/resources/community-groups.jd
index 72bdf7a..6d59648 100644
--- a/docs/html/resources/community-groups.jd
+++ b/docs/html/resources/community-groups.jd
@@ -22,7 +22,7 @@
<p>Welcome to the Android developers community! We're glad you're here and invite you to participate in discussions with other Android application developers on topics that interest you.</p>
-<p>The lists on this page are primarily for discussion about Android application development. If you are seeking discussion about Android source code (not application development), then please refer to the <a href="http://source.android.com/discuss">Open Source Project Mailing lists</a>.</p>
+<p>The lists on this page are primarily for discussion about Android application development. If you are seeking discussion about Android source code (not application development), then please refer to the <a href="http://source.android.com/community">Open Source Project Mailing lists</a>.</p>
<h2 id="StackOverflow">Stack Overflow</h2>
@@ -56,7 +56,7 @@
As you write your post, please do the following:
<ol>
<li><strong>Read
-the <a href="http://source.android.com/discuss/android-discussion-groups-charter">mailing list charter</a></strong> that covers the community guidelines.
+the <a href="http://source.android.com/community/groups-charter.html">mailing list charter</a></strong> that covers the community guidelines.
</li>
<li><strong>Select the most appropriate mailing list for your question</strong>. There are several different lists for
developers, described below.</li>
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 345f810..76cde73 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -1221,7 +1221,7 @@
checkRange(texs.length, texOffset, vertexCount);
}
if (colors != null) {
- checkRange(colors.length, colorOffset, vertexCount);
+ checkRange(colors.length, colorOffset, vertexCount / 2);
}
if (indices != null) {
checkRange(indices.length, indexOffset, indexCount);
diff --git a/libs/rs/rsNoise.cpp b/libs/rs/rsNoise.cpp
index 764dc1a..4b67586 100644
--- a/libs/rs/rsNoise.cpp
+++ b/libs/rs/rsNoise.cpp
@@ -253,4 +253,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 013f8fc..3333268 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -1215,8 +1215,12 @@
prescan(path);
File file = new File(path);
+
+ // lastModified is in milliseconds on Files.
+ long lastModifiedSeconds = file.lastModified() / 1000;
+
// always scan the file, so we can return the content://media Uri for existing files
- return mClient.doScanFile(path, mimeType, file.lastModified(), file.length(), true);
+ return mClient.doScanFile(path, mimeType, lastModifiedSeconds, file.length(), true);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException in MediaScanner.scanFile()", e);
return null;
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 54d7307..32e6c9f 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -485,13 +485,13 @@
copybit_device_t* const copybit = blitengine;
if (copybit) {
copybit_image_t simg;
- simg.w = src->width;
+ simg.w = src->stride;
simg.h = src->height;
simg.format = src->format;
simg.handle = const_cast<native_handle_t*>(src->handle);
copybit_image_t dimg;
- dimg.w = dst->width;
+ dimg.w = dst->stride;
dimg.h = dst->height;
dimg.format = dst->format;
dimg.handle = const_cast<native_handle_t*>(dst->handle);
diff --git a/opengl/tests/gl_jni/jni/gl_code.cpp b/opengl/tests/gl_jni/jni/gl_code.cpp
index f031c79..ef66841 100644
--- a/opengl/tests/gl_jni/jni/gl_code.cpp
+++ b/opengl/tests/gl_jni/jni/gl_code.cpp
@@ -181,4 +181,3 @@
{
background = 1.0f - background;
}
-
diff --git a/services/java/com/android/server/ProcessStats.java b/services/java/com/android/server/ProcessStats.java
index a02c4e7..4fa89d9 100644
--- a/services/java/com/android/server/ProcessStats.java
+++ b/services/java/com/android/server/ProcessStats.java
@@ -687,7 +687,7 @@
break;
}
}
- return new String(mBuffer, 0, 0, i);
+ return new String(mBuffer, 0, i);
}
} catch (java.io.FileNotFoundException e) {
} catch (java.io.IOException e) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index bcbda3e..78f8fd5 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -58,6 +58,7 @@
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IIntentReceiver;
@@ -1077,7 +1078,7 @@
d.setCancelable(false);
d.setTitle("System UIDs Inconsistent");
d.setMessage("UIDs on the system are inconsistent, you need to wipe your data partition or your device will be unstable.");
- d.setButton("I'm Feeling Lucky",
+ d.setButton(DialogInterface.BUTTON_POSITIVE, "I'm Feeling Lucky",
mHandler.obtainMessage(IM_FEELING_LUCKY_MSG));
mUidAlert = d;
d.show();
@@ -3548,10 +3549,12 @@
String[] pkgs = intent.getStringArrayExtra(Intent.EXTRA_PACKAGES);
if (pkgs != null) {
for (String pkg : pkgs) {
- if (forceStopPackageLocked(pkg, -1, false, false, false)) {
- setResultCode(Activity.RESULT_OK);
- return;
- }
+ synchronized (ActivityManagerService.this) {
+ if (forceStopPackageLocked(pkg, -1, false, false, false)) {
+ setResultCode(Activity.RESULT_OK);
+ return;
+ }
+ }
}
}
}
diff --git a/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java b/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java
index 8e9818d..9fb48b3 100644
--- a/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java
+++ b/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java
@@ -17,6 +17,7 @@
package com.android.server.am;
import android.content.Context;
+import android.content.DialogInterface;
import android.os.Handler;
import android.os.Message;
@@ -49,7 +50,7 @@
text.append(" is waiting for the debugger to attach.");
setMessage(text.toString());
- setButton("Force Close", mHandler.obtainMessage(1, app));
+ setButton(DialogInterface.BUTTON_POSITIVE, "Force Close", mHandler.obtainMessage(1, app));
setTitle("Waiting For Debugger");
getWindow().setTitle("Waiting For Debugger: " + app.info.processName);
}
diff --git a/services/java/com/android/server/am/FactoryErrorDialog.java b/services/java/com/android/server/am/FactoryErrorDialog.java
index 2e25474..b19bb5ca 100644
--- a/services/java/com/android/server/am/FactoryErrorDialog.java
+++ b/services/java/com/android/server/am/FactoryErrorDialog.java
@@ -17,6 +17,7 @@
package com.android.server.am;
import android.content.Context;
+import android.content.DialogInterface;
import android.os.Handler;
import android.os.Message;
@@ -26,7 +27,8 @@
setCancelable(false);
setTitle(context.getText(com.android.internal.R.string.factorytest_failed));
setMessage(msg);
- setButton(context.getText(com.android.internal.R.string.factorytest_reboot),
+ setButton(DialogInterface.BUTTON_POSITIVE,
+ context.getText(com.android.internal.R.string.factorytest_reboot),
mHandler.obtainMessage(0));
getWindow().setTitle("Factory Error");
}
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index a60d2be..1d3ad81 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -55,6 +55,12 @@
public static final char WILD = 'N';
/*
+ * Calling Line Identification Restriction (CLIR)
+ */
+ private static final String CLIR_ON = "*31#+";
+ private static final String CLIR_OFF = "#31#+";
+
+ /*
* TOA = TON + NPI
* See TS 24.008 section 10.5.4.7 for details.
* These are the only really useful TOA values
@@ -179,8 +185,6 @@
* Please note that the GSM wild character is allowed in the result.
* This must be resolved before dialing.
*
- * Allows + only in the first position in the result string.
- *
* Returns null if phoneNumber == null
*/
public static String
@@ -203,6 +207,11 @@
}
}
+ int pos = addPlusChar(phoneNumber);
+ if (pos >= 0 && ret.length() > pos) {
+ ret.insert(pos, '+');
+ }
+
return ret.toString();
}
@@ -304,6 +313,28 @@
}
}
+ /** GSM codes
+ * Finds if a GSM code includes the international prefix (+).
+ *
+ * @param number the number to dial.
+ *
+ * @return the position where the + char will be inserted, -1 if the GSM code was not found.
+ */
+ private static int
+ addPlusChar(String number) {
+ int pos = -1;
+
+ if (number.startsWith(CLIR_OFF)) {
+ pos = CLIR_OFF.length() - 1;
+ }
+
+ if (number.startsWith(CLIR_ON)) {
+ pos = CLIR_ON.length() - 1;
+ }
+
+ return pos;
+ }
+
/**
* Extracts the post-dial sequence of DTMF control digits, pauses, and
* waits. Strips separators. This string may be empty, but will not be null
@@ -1119,7 +1150,7 @@
&& text.charAt(2) == '1') {
formatType = FORMAT_JAPAN;
} else {
- return;
+ formatType = FORMAT_UNKNOWN;
}
}
@@ -1130,6 +1161,9 @@
case FORMAT_JAPAN:
formatJapaneseNumber(text);
return;
+ case FORMAT_UNKNOWN:
+ removeDashes(text);
+ return;
}
}
@@ -1165,14 +1199,7 @@
CharSequence saved = text.subSequence(0, length);
// Strip the dashes first, as we're going to add them back
- int p = 0;
- while (p < text.length()) {
- if (text.charAt(p) == '-') {
- text.delete(p, p + 1);
- } else {
- p++;
- }
- }
+ removeDashes(text);
length = text.length();
// When scanning the number we record where dashes need to be added,
@@ -1276,6 +1303,22 @@
JapanesePhoneNumberFormatter.format(text);
}
+ /**
+ * Removes all dashes from the number.
+ *
+ * @param text the number to clear from dashes
+ */
+ private static void removeDashes(Editable text) {
+ int p = 0;
+ while (p < text.length()) {
+ if (text.charAt(p) == '-') {
+ text.delete(p, p + 1);
+ } else {
+ p++;
+ }
+ }
+ }
+
// Three and four digit phone numbers for either special services,
// or 3-6 digit addresses from the network (eg carrier-originated SMS messages) should
// not match.
diff --git a/telephony/java/com/android/internal/telephony/AdnRecordCache.java b/telephony/java/com/android/internal/telephony/AdnRecordCache.java
index c8c0658..a175d49 100644
--- a/telephony/java/com/android/internal/telephony/AdnRecordCache.java
+++ b/telephony/java/com/android/internal/telephony/AdnRecordCache.java
@@ -186,7 +186,12 @@
}
ArrayList<AdnRecord> oldAdnList;
- oldAdnList = getRecordsIfLoaded(efid);
+
+ if (efid == EF_PBR) {
+ oldAdnList = mUsimPhoneBookManager.loadEfFilesFromUsim();
+ } else {
+ oldAdnList = getRecordsIfLoaded(efid);
+ }
if (oldAdnList == null) {
sendErrorResponse(response, "Adn list not exist for EF:" + efid);
@@ -208,6 +213,17 @@
return;
}
+ if (efid == EF_PBR) {
+ AdnRecord foundAdn = oldAdnList.get(index-1);
+ efid = foundAdn.efid;
+ extensionEF = foundAdn.extRecord;
+ index = foundAdn.recordNumber;
+
+ newAdn.efid = efid;
+ newAdn.extRecord = extensionEF;
+ newAdn.recordNumber = index;
+ }
+
Message pendingResponse = userWriteResponse.get(efid);
if (pendingResponse != null) {
@@ -331,6 +347,7 @@
if (ar.exception == null) {
adnLikeFiles.get(efid).set(index - 1, adn);
+ mUsimPhoneBookManager.invalidateCache();
}
Message response = userWriteResponse.get(efid);
diff --git a/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java b/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
index 9f8e57f..2f22d74 100644
--- a/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
+++ b/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
@@ -62,8 +62,8 @@
logd("GET_RECORD_SIZE Size " + recordSize[0] +
" total " + recordSize[1] +
" #record " + recordSize[2]);
- mLock.notifyAll();
}
+ mLock.notifyAll();
}
break;
case EVENT_UPDATE_DONE:
@@ -144,6 +144,9 @@
if (DBG) logd("updateAdnRecordsInEfBySearch: efid=" + efid +
" ("+ oldTag + "," + oldPhoneNumber + ")"+ "==>" +
" ("+ newTag + "," + newPhoneNumber + ")"+ " pin2=" + pin2);
+
+ efid = updateEfForIccType(efid);
+
synchronized(mLock) {
checkThread();
success = false;
diff --git a/telephony/java/com/android/internal/telephony/IccUtils.java b/telephony/java/com/android/internal/telephony/IccUtils.java
index 71936f1..957eddd 100644
--- a/telephony/java/com/android/internal/telephony/IccUtils.java
+++ b/telephony/java/com/android/internal/telephony/IccUtils.java
@@ -51,6 +51,8 @@
ret.append((char)('0' + v));
v = (data[i] >> 4) & 0xf;
+ // Some PLMNs have 'f' as high nibble, ignore it
+ if (v == 0xf) continue;
if (v > 9) break;
ret.append((char)('0' + v));
}
diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index 3d410fd..d79a89e 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -2339,7 +2339,7 @@
case RIL_UNSOL_RESTRICTED_STATE_CHANGED: ret = responseInts(p); break;
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: ret = responseVoid(p); break;
case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: ret = responseCdmaSms(p); break;
- case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseString(p); break;
+ case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseRaw(p); break;
case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
case RIL_UNSOL_CDMA_CALL_WAITING: ret = responseCdmaCallWaiting(p); break;
@@ -3406,6 +3406,8 @@
RILRequest rr = RILRequest.obtain(
RILConstants.RIL_REQUEST_QUERY_TTY_MODE, response);
+ if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
+
send(rr);
}
@@ -3419,6 +3421,9 @@
rr.mp.writeInt(1);
rr.mp.writeInt(ttyMode);
+ if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ + " : " + ttyMode);
+
send(rr);
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java
index d711a80..30f38bd 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java
@@ -93,6 +93,7 @@
static final int SPN_RULE_SHOW_PLMN = 0x02;
// From TS 51.011 EF[SPDI] section
+ static final int TAG_SPDI = 0xA3;
static final int TAG_SPDI_PLMN_LIST = 0x80;
// Full Name IEI from TS 24.008
@@ -559,6 +560,13 @@
break;
case EVENT_GET_CPHS_MAILBOX_DONE:
case EVENT_GET_MBDN_DONE:
+ //Resetting the voice mail number and voice mail tag to null
+ //as these should be updated from the data read from EF_MBDN.
+ //If they are not reset, incase of invalid data/exception these
+ //variables are retaining their previous values and are
+ //causing invalid voice mailbox info display to user.
+ voiceMailNum = null;
+ voiceMailTag = null;
isRecordLoadResponse = true;
ar = (AsyncResult)msg.obj;
@@ -1426,8 +1434,12 @@
byte[] plmnEntries = null;
- // There should only be one TAG_SPDI_PLMN_LIST
for ( ; tlv.isValidObject() ; tlv.nextObject()) {
+ // Skip SPDI tag, if existant
+ if (tlv.getTag() == TAG_SPDI) {
+ tlv = new SimTlv(tlv.getData(), 0, tlv.getData().length);
+ }
+ // There should only be one TAG_SPDI_PLMN_LIST
if (tlv.getTag() == TAG_SPDI_PLMN_LIST) {
plmnEntries = tlv.getData();
break;
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
index 12c6b88..4fd62fb 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
@@ -928,6 +928,8 @@
// TP-Message-Type-Indicator
// 9.2.3
case 0:
+ case 3: //GSM 03.40 9.2.3.1: MTI == 3 is Reserved.
+ //This should be processed in the same way as MTI == 0 (Deliver)
parseSmsDeliver(p, firstByte);
break;
case 2:
diff --git a/telephony/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java b/telephony/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java
old mode 100644
new mode 100755
index 41e527c..b642541
--- a/telephony/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java
+++ b/telephony/java/com/android/internal/telephony/gsm/UsimPhoneBookManager.java
@@ -53,6 +53,7 @@
private ArrayList<byte[]> mIapFileRecord;
private ArrayList<byte[]> mEmailFileRecord;
private Map<Integer, ArrayList<String>> mEmailsForAdnRec;
+ private boolean mRefreshCache = false;
private static final int EVENT_PBR_LOAD_DONE = 1;
private static final int EVENT_USIM_ADN_LOAD_DONE = 2;
@@ -91,11 +92,19 @@
mEmailFileRecord = null;
mPbrFile = null;
mIsPbrPresent = true;
+ mRefreshCache = false;
}
public ArrayList<AdnRecord> loadEfFilesFromUsim() {
synchronized (mLock) {
- if (!mPhoneBookRecords.isEmpty()) return mPhoneBookRecords;
+ if (!mPhoneBookRecords.isEmpty()) {
+ if (mRefreshCache) {
+ mRefreshCache = false;
+ refreshCache();
+ }
+ return mPhoneBookRecords;
+ }
+
if (!mIsPbrPresent) return null;
// Check if the PBR file is present in the cache, if not read it
@@ -116,6 +125,20 @@
return mPhoneBookRecords;
}
+ private void refreshCache() {
+ if (mPbrFile == null) return;
+ mPhoneBookRecords.clear();
+
+ int numRecs = mPbrFile.mFileIds.size();
+ for (int i = 0; i < numRecs; i++) {
+ readAdnFileAndWait(i);
+ }
+ }
+
+ public void invalidateCache() {
+ mRefreshCache = true;
+ }
+
private void readPbrFileAndWait() {
mPhone.getIccFileHandler().loadEFLinearFixedAll(EF_PBR, obtainMessage(EVENT_PBR_LOAD_DONE));
try {
diff --git a/tests/CoreTests/android/AndroidManifest.xml b/tests/CoreTests/android/AndroidManifest.xml
index f02673c..8331f0c 100644
--- a/tests/CoreTests/android/AndroidManifest.xml
+++ b/tests/CoreTests/android/AndroidManifest.xml
@@ -24,6 +24,7 @@
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- location test permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
diff --git a/tests/CoreTests/android/core/HttpHeaderTest.java b/tests/CoreTests/android/core/HttpHeaderTest.java
new file mode 100644
index 0000000..a5d48578
--- /dev/null
+++ b/tests/CoreTests/android/core/HttpHeaderTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 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 android.core;
+
+import android.test.AndroidTestCase;
+import org.apache.http.util.CharArrayBuffer;
+
+import android.net.http.Headers;
+
+public class HttpHeaderTest extends AndroidTestCase {
+
+ static final String LAST_MODIFIED = "Last-Modified: Fri, 18 Jun 2010 09:56:47 GMT";
+ static final String CACHE_CONTROL_MAX_AGE = "Cache-Control:max-age=15";
+ static final String CACHE_CONTROL_PRIVATE = "Cache-Control: private";
+
+ /**
+ * Tests that cache control header supports multiple instances of the header,
+ * according to HTTP specification.
+ *
+ * The HTTP specification states the following about the fields:
+ * Multiple message-header fields with the same field-name MAY be present
+ * in a message if and only if the entire field-value for that header field
+ * is defined as a comma-separated list [i.e., #(values)]. It MUST be
+ * possible to combine the multiple header fields into one "field-name:
+ * field-value" pair, without changing the semantics of the message, by
+ * appending each subsequent field-value to the first, each separated by a
+ * comma. The order in which header fields with the same field-name are
+ * received is therefore significant to the interpretation of the combined
+ * field value, and thus a proxy MUST NOT change the order of these field
+ * values when a message is forwarded.
+ */
+ public void testCacheControl() throws Exception {
+ Headers h = new Headers();
+ CharArrayBuffer buffer = new CharArrayBuffer(64);
+
+ buffer.append(CACHE_CONTROL_MAX_AGE);
+ h.parseHeader(buffer);
+
+ buffer.clear();
+ buffer.append(LAST_MODIFIED);
+ h.parseHeader(buffer);
+ assertEquals("max-age=15", h.getCacheControl());
+
+ buffer.clear();
+ buffer.append(CACHE_CONTROL_PRIVATE);
+ h.parseHeader(buffer);
+ assertEquals("max-age=15,private", h.getCacheControl());
+ }
+}
diff --git a/tests/CoreTests/android/core/ProxyTest.java b/tests/CoreTests/android/core/ProxyTest.java
new file mode 100644
index 0000000..12acfe8
--- /dev/null
+++ b/tests/CoreTests/android/core/ProxyTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010 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 android.core;
+
+import org.apache.http.HttpHost;
+
+import android.content.Context;
+import android.net.Proxy;
+import android.test.AndroidTestCase;
+
+/**
+ * Proxy tests
+ */
+public class ProxyTest extends AndroidTestCase {
+ private Context mContext;
+ private HttpHost mHttpHost;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mContext = getContext();
+ mHttpHost = null;
+ String proxyHost = Proxy.getHost(mContext);
+ int proxyPort = Proxy.getPort(mContext);
+ if (proxyHost != null) {
+ mHttpHost = new HttpHost(proxyHost, proxyPort, "http");
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Bad url parameter should not cause any exception.
+ */
+ public void testProxyGetPreferredHttpHost_UrlBad() throws Exception {
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, null));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, ""));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "bad:"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "bad"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "bad:\\"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "bad://#"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "://#"));
+ }
+
+ /**
+ * Proxy (if available) should be returned when url parameter is not localhost.
+ */
+ public void testProxyGetPreferredHttpHost_UrlNotlLocalhost() throws Exception {
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "http://"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "http://example.com"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "http://example.com/"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "http://192.168.0.1/"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "file:///foo/bar"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "rtsp://example.com"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "rtsp://example.com/"));
+ assertEquals(mHttpHost, Proxy.getPreferredHttpHost(mContext, "javascript:alert(1)"));
+ }
+
+ /**
+ * No proxy should be returned when url parameter is localhost.
+ */
+ public void testProxyGetPreferredHttpHost_UrlLocalhost() throws Exception {
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://localhost"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://localhost/"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://localhost/hej.html"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://127.0.0.1"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://127.0.0.1/"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://127.0.0.1/hej.html"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://127.0.0.1:80/"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "http://127.0.0.1:8080/"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "rtsp://127.0.0.1/"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "rtsp://localhost/"));
+ assertNull(Proxy.getPreferredHttpHost(mContext, "https://localhost/"));
+ }
+}
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index f98cd28..e08f857 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -16,8 +16,6 @@
package android.net.wifi;
-import android.net.DhcpInfo;
-
/**
* Native calls for sending requests to the supplicant daemon, and for
* receiving asynchronous events. All methods of the form "xxxxCommand()"
@@ -109,6 +107,8 @@
public native static boolean setPowerModeCommand(int mode);
+ public native static int getPowerModeCommand();
+
public native static boolean setNumAllowedChannelsCommand(int numChannels);
public native static int getNumAllowedChannelsCommand();
@@ -143,10 +143,6 @@
public native static boolean clearBlacklistCommand();
- public native static boolean doDhcpRequest(DhcpInfo results);
-
- public native static String getDhcpError();
-
/**
* Wait for the supplicant to send an event, returning the event string.
* @return the event string sent by the supplicant.
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 8b2cfc6..99f3d06 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -314,6 +314,7 @@
private static String LS = System.getProperty("line.separator");
private static String[] sDnsPropNames;
+ private Runnable mReleaseWakeLockCallback;
/**
* A structure for supplying information about a supplicant state
@@ -371,9 +372,9 @@
mSettingsObserver = new SettingsObserver(new Handler());
mInterfaceName = SystemProperties.get("wifi.interface", "tiwlan0");
- sDnsPropNames = new String[] {
- "dhcp." + mInterfaceName + ".dns1",
- "dhcp." + mInterfaceName + ".dns2"
+ mDnsPropNames = new String[] {
+ "net." + mInterfaceName + ".dns1",
+ "net." + mInterfaceName + ".dns2"
};
mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
@@ -418,15 +419,6 @@
}
/**
- * Return the IP addresses of the DNS servers available for the WLAN
- * network interface.
- * @return a list of DNS addresses, with no holes.
- */
- public String[] getNameServers() {
- return getNameServerList(sDnsPropNames);
- }
-
- /**
* Return the name of our WLAN network interface.
* @return the name of our interface.
*/
@@ -1357,7 +1349,7 @@
int netId = -1;
String[] lines = reply.split("\n");
for (String line : lines) {
- String[] prop = line.split(" *= *");
+ String[] prop = line.split(" *= *", 2);
if (prop.length < 2)
continue;
String name = prop[0];
@@ -1931,6 +1923,17 @@
}
/**
+ * Get power mode
+ * @return power mode
+ */
+ public synchronized int getPowerMode() {
+ if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ return -1;
+ }
+ return WifiNative.getPowerModeCommand();
+ }
+
+ /**
* Set power mode
* @param mode
* DRIVER_POWER_MODE_AUTO
@@ -2255,6 +2258,8 @@
case EVENT_DHCP_START:
boolean modifiedBluetoothCoexistenceMode = false;
+ int powerMode = DRIVER_POWER_MODE_AUTO;
+
if (shouldDisableCoexistenceMode()) {
/*
* There are problems setting the Wi-Fi driver's power
@@ -2278,8 +2283,16 @@
setBluetoothCoexistenceMode(
WifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED);
}
-
- setPowerMode(DRIVER_POWER_MODE_ACTIVE);
+
+ powerMode = getPowerMode();
+ if (powerMode < 0) {
+ // Handle the case where supplicant driver does not support
+ // getPowerModeCommand.
+ powerMode = DRIVER_POWER_MODE_AUTO;
+ }
+ if (powerMode != DRIVER_POWER_MODE_ACTIVE) {
+ setPowerMode(DRIVER_POWER_MODE_ACTIVE);
+ }
synchronized (this) {
// A new request is being made, so assume we will callback
@@ -2295,7 +2308,9 @@
NetworkUtils.getDhcpError());
}
- setPowerMode(DRIVER_POWER_MODE_AUTO);
+ if (powerMode != DRIVER_POWER_MODE_ACTIVE) {
+ setPowerMode(powerMode);
+ }
if (modifiedBluetoothCoexistenceMode) {
// Set the coexistence mode back to its default value