Bug 743153 - Use ContentUris.parseId instead of RepoUtils.getAndroidIdFromUri. r=rnewman, a=android-only

This commit is contained in:
Nick Alexander 2012-04-30 13:40:27 -07:00
parent e3e986ce65
commit dc024d63b4
4 changed files with 9 additions and 11 deletions

View File

@ -16,6 +16,7 @@ import org.mozilla.gecko.sync.repositories.NullCursorException;
import org.mozilla.gecko.sync.repositories.domain.BookmarkRecord;
import org.mozilla.gecko.sync.repositories.domain.Record;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@ -249,7 +250,7 @@ public class AndroidBrowserBookmarksDataAccessor extends AndroidBrowserRepositor
record.title = AndroidBrowserBookmarksRepositorySession.SPECIAL_GUIDS_MAP.get(guid);
record.type = "folder";
record.androidParentID = parentId;
return(RepoUtils.getAndroidIdFromUri(insert(record)));
return ContentUris.parseId(insert(record));
}
@Override

View File

@ -26,6 +26,7 @@ import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionGuidsSince
import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionWipeDelegate;
import org.mozilla.gecko.sync.repositories.domain.Record;
import android.content.ContentUris;
import android.database.Cursor;
import android.net.Uri;
@ -533,7 +534,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
protected Record insert(Record record) throws NoGuidForIdException, NullCursorException, ParentNotFoundException {
Record toStore = prepareRecord(record);
Uri recordURI = dbHelper.insert(toStore);
long id = RepoUtils.getAndroidIdFromUri(recordURI);
long id = ContentUris.parseId(recordURI);
Logger.debug(LOG_TAG, "Inserted as " + id);
toStore.androidID = id;

View File

@ -28,6 +28,7 @@ import org.mozilla.gecko.sync.repositories.domain.PasswordRecord;
import org.mozilla.gecko.sync.repositories.domain.Record;
import android.content.ContentProviderClient;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@ -445,7 +446,10 @@ public class PasswordsRepositorySession extends
// record.timeLastUsed = now();
ContentValues cv = getContentValues(record);
Uri insertedUri = passwordsProvider.insert(BrowserContractHelpers.PASSWORDS_CONTENT_URI, cv);
record.androidID = RepoUtils.getAndroidIdFromUri(insertedUri);
if (insertedUri == null) {
throw new RemoteException(); // Not much to be done here, save throw.
}
record.androidID = ContentUris.parseId(insertedUri);
return record;
}

View File

@ -119,14 +119,6 @@ public class RepoUtils {
}
}
// Returns android id from the URI that we get after inserting a
// bookmark into the local Android store.
public static long getAndroidIdFromUri(Uri uri) {
String path = uri.getPath();
int lastSlash = path.lastIndexOf('/');
return Long.parseLong(path.substring(lastSlash + 1));
}
//Create a HistoryRecord object from a cursor on a row with a Moz History record in it
public static HistoryRecord historyFromMirrorCursor(Cursor cur) {