Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 878130f7 authored by The Android Automerger's avatar The Android Automerger
Browse files

Merge branch 'gingerbread' into gingerbread-release

parents f0a86c19 a4682ed7
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -24549,7 +24549,7 @@
</parameter>
</method>
<method name="remove"
 return="void"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
@@ -24558,7 +24558,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="id" type="long">
<parameter name="ids" type="long...">
</parameter>
</method>
<field name="ACTION_DOWNLOAD_COMPLETE"
@@ -24951,7 +24951,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="id" type="long">
<parameter name="ids" type="long...">
</parameter>
</method>
<method name="setFilterByStatus"
@@ -125837,6 +125837,8 @@
 deprecated="not deprecated"
 visibility="public"
>
<implements name="java.io.Closeable">
</implements>
<implements name="android.os.Parcelable">
</implements>
<constructor name="DropBoxManager.Entry"
+9 −7
Original line number Diff line number Diff line
@@ -2740,13 +2740,14 @@ class ContextImpl extends Context {
        private final int mMode;

        private Map<String, Object> mMap;     // guarded by 'this'
        private long mTimestamp;  // guarded by 'this'
        private int mDiskWritesInFlight = 0;  // guarded by 'this'
        private boolean mLoaded = false;      // guarded by 'this'
        private long mStatTimestamp;          // guarded by 'this'
        private long mStatSize;               // guarded by 'this'

        private final Object mWritingToDiskLock = new Object();
        private static final Object mContent = new Object();
        private WeakHashMap<OnSharedPreferenceChangeListener, Object> mListeners;
        private final WeakHashMap<OnSharedPreferenceChangeListener, Object> mListeners;

        SharedPreferencesImpl(
            File file, int mode, Map initialContents) {
@@ -2757,7 +2758,7 @@ class ContextImpl extends Context {
            mMap = initialContents != null ? initialContents : new HashMap<String, Object>();
            FileStatus stat = new FileStatus();
            if (FileUtils.getFileStatus(file.getPath(), stat)) {
                mTimestamp = stat.mtime;
                mStatTimestamp = stat.mtime;
            }
            mListeners = new WeakHashMap<OnSharedPreferenceChangeListener, Object>();
        }
@@ -2784,7 +2785,7 @@ class ContextImpl extends Context {
                return true;
            }
            synchronized (this) {
                return mTimestamp != stat.mtime;
                return mStatTimestamp != stat.mtime || mStatSize != stat.size;
            }
        }

@@ -3165,7 +3166,8 @@ class ContextImpl extends Context {
                FileStatus stat = new FileStatus();
                if (FileUtils.getFileStatus(mFile.getPath(), stat)) {
                    synchronized (this) {
                        mTimestamp = stat.mtime;
                        mStatTimestamp = stat.mtime;
                        mStatSize = stat.size;
                    }
                }
                // Writing was successful, delete the backup file if there is one.
+65 −25
Original line number Diff line number Diff line
@@ -567,18 +567,18 @@ public class DownloadManager {
         */
        public static final int ORDER_DESCENDING = 2;

        private Long mId = null;
        private long[] mIds = null;
        private Integer mStatusFlags = null;
        private String mOrderByColumn = Downloads.COLUMN_LAST_MODIFICATION;
        private int mOrderDirection = ORDER_DESCENDING;
        private boolean mOnlyIncludeVisibleInDownloadsUi = false;

        /**
         * Include only the download with the given ID.
         * Include only the downloads with the given IDs.
         * @return this object
         */
        public Query setFilterById(long id) {
            mId = id;
        public Query setFilterById(long... ids) {
            mIds = ids;
            return this;
        }

@@ -639,9 +639,11 @@ public class DownloadManager {
        Cursor runQuery(ContentResolver resolver, String[] projection, Uri baseUri) {
            Uri uri = baseUri;
            List<String> selectionParts = new ArrayList<String>();
            String[] selectionArgs = null;

            if (mId != null) {
                uri = ContentUris.withAppendedId(uri, mId);
            if (mIds != null) {
                selectionParts.add(getWhereClauseForIds(mIds));
                selectionArgs = getWhereArgsForIds(mIds);
            }

            if (mStatusFlags != null) {
@@ -676,7 +678,7 @@ public class DownloadManager {
            String orderDirection = (mOrderDirection == ORDER_ASCENDING ? "ASC" : "DESC");
            String orderBy = mOrderByColumn + " " + orderDirection;

            return resolver.query(uri, projection, selection, null, orderBy);
            return resolver.query(uri, projection, selection, selectionArgs, orderBy);
        }

        private String joinStrings(String joiner, Iterable<String> parts) {
@@ -738,17 +740,28 @@ public class DownloadManager {
    }

    /**
     * Cancel a download and remove it from the download manager.  The download will be stopped if
     * Cancel downloads and remove them from the download manager.  Each download will be stopped if
     * it was running, and it will no longer be accessible through the download manager.  If a file
     * was already downloaded, it will not be deleted.
     * was already downloaded to external storage, it will not be deleted.
     *
     * @param id the ID of the download
     * @param ids the IDs of the downloads to remove
     * @return the number of downloads actually removed
     */
    public void remove(long id) {
        int numDeleted = mResolver.delete(getDownloadUri(id), null, null);
        if (numDeleted == 0) {
            throw new IllegalArgumentException("Download " + id + " does not exist");
    public int remove(long... ids) {
        StringBuilder whereClause = new StringBuilder();
        String[] whereArgs = new String[ids.length];

        whereClause.append(Downloads.Impl._ID + " IN (");
        for (int i = 0; i < ids.length; i++) {
            if (i > 0) {
                whereClause.append(",");
            }
            whereClause.append("?");
            whereArgs[i] = Long.toString(ids[i]);
        }
        whereClause.append(")");

        return mResolver.delete(mBaseUri, whereClause.toString(), whereArgs);
    }

    /**
@@ -776,20 +789,20 @@ public class DownloadManager {
    }

    /**
     * Restart the given download, which must have already completed (successfully or not).  This
     * Restart the given downloads, which must have already completed (successfully or not).  This
     * method will only work when called from within the download manager's process.
     * @param id the ID of the download
     * @param ids the IDs of the downloads
     * @hide
     */
    public void restartDownload(long id) {
        Cursor cursor = query(new Query().setFilterById(id));
    public void restartDownload(long... ids) {
        Cursor cursor = query(new Query().setFilterById(ids));
        try {
            if (!cursor.moveToFirst()) {
                throw new IllegalArgumentException("No download with id " + id);
            }
            for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                int status = cursor.getInt(cursor.getColumnIndex(COLUMN_STATUS));
                if (status != STATUS_SUCCESSFUL && status != STATUS_FAILED) {
                throw new IllegalArgumentException("Cannot restart incomplete download: " + id);
                    throw new IllegalArgumentException("Cannot restart incomplete download: "
                            + cursor.getLong(cursor.getColumnIndex(COLUMN_ID)));
                }
            }
        } finally {
            cursor.close();
@@ -800,7 +813,7 @@ public class DownloadManager {
        values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, -1);
        values.putNull(Downloads.Impl._DATA);
        values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_PENDING);
        mResolver.update(getDownloadUri(id), values, null, null);
        mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids));
    }

    /**
@@ -810,6 +823,33 @@ public class DownloadManager {
        return ContentUris.withAppendedId(mBaseUri, id);
    }

    /**
     * Get a parameterized SQL WHERE clause to select a bunch of IDs.
     */
    static String getWhereClauseForIds(long[] ids) {
        StringBuilder whereClause = new StringBuilder();
        whereClause.append(Downloads.Impl._ID + " IN (");
        for (int i = 0; i < ids.length; i++) {
            if (i > 0) {
                whereClause.append(",");
            }
            whereClause.append("?");
        }
        whereClause.append(")");
        return whereClause.toString();
    }

    /**
     * Get the selection args for a clause returned by {@link #getWhereClauseForIds(long[])}.
     */
    static String[] getWhereArgsForIds(long[] ids) {
        String[] whereArgs = new String[ids.length];
        for (int i = 0; i < ids.length; i++) {
            whereArgs[i] = Long.toString(ids[i]);
        }
        return whereArgs;
    }

    /**
     * This class wraps a cursor returned by DownloadProvider -- the "underlying cursor" -- and
     * presents a different set of columns, those defined in the DownloadManager.COLUMN_* constants.
+4 −0
Original line number Diff line number Diff line
@@ -449,6 +449,10 @@ public abstract class BatteryStats implements Parcelable {
        public static final int STATE_WAKE_LOCK_FLAG = 1<<17;
        public static final int STATE_SENSOR_ON_FLAG = 1<<16;
        
        public static final int MOST_INTERESTING_STATES =
            STATE_BATTERY_PLUGGED_FLAG | STATE_SCREEN_ON_FLAG
            | STATE_GPS_ON_FLAG | STATE_PHONE_IN_CALL_FLAG;

        public int states;

        public HistoryItem() {
+2 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.util.Log;
import com.android.internal.os.IDropBoxManagerService;

import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -61,7 +62,7 @@ public class DropBoxManager {
     * This may include a reference to a stream, so you must call
     * {@link #close()} when you are done using it.
     */
    public static class Entry implements Parcelable {
    public static class Entry implements Parcelable, Closeable {
        private final String mTag;
        private final long mTimeMillis;

Loading