Bug 1186037 - Import bookmarks and history from stock browser (Samsung S4, Android 4.4.2) doesn't work. r=mhaigh
authorChenxia Liu <liuche@mozilla.com>
Thu, 13 Aug 2015 11:45:23 -0700
changeset 293742 8ad3f1c2b954255d25c7850cd86a453453143d45
parent 293741 bb27412c9a7969f0f13c7cba34f075871de83efb
child 293743 bee8a1b9f47a95c5162458ac6c346d90d122dbd9
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1186037
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1186037 - Import bookmarks and history from stock browser (Samsung S4, Android 4.4.2) doesn't work. r=mhaigh
mobile/android/base/preferences/AndroidImport.java
--- a/mobile/android/base/preferences/AndroidImport.java
+++ b/mobile/android/base/preferences/AndroidImport.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.preferences;
 
+import android.os.Build;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.db.BrowserContract;
 import org.mozilla.gecko.db.BrowserContract.Bookmarks;
 import org.mozilla.gecko.db.LocalBrowserDB;
 
 import android.content.ContentProviderOperation;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -38,16 +39,20 @@ class AndroidImport implements Runnable 
             public static final String DATE = "date";
             public static final String BOOKMARK = "bookmark";
             public static final String TITLE = "title";
             public static final String CREATED = "created";
             public static final String FAVICON = "favicon";
         }
     }
 
+    public static final Uri SAMSUNG_BOOKMARKS_URI = Uri.parse("content://com.sec.android.app.sbrowser.browser/bookmarks");
+    public static final Uri SAMSUNG_HISTORY_URI = Uri.parse("content://com.sec.android.app.sbrowser.browser/history");
+    public static final String SAMSUNG_MANUFACTURER = "samsung";
+
     private static final String LOGTAG = "AndroidImport";
     private final Context mContext;
     private final Runnable mOnDoneRunnable;
     private final ArrayList<ContentProviderOperation> mOperations;
     private final ContentResolver mCr;
     private final LocalBrowserDB mDB;
     private final boolean mImportBookmarks;
     private final boolean mImportHistory;
@@ -67,16 +72,20 @@ class AndroidImport implements Runnable 
         Cursor cursor = null;
         try {
             cursor = mCr.query(LegacyBrowserProvider.BOOKMARKS_URI,
                                null,
                                LegacyBrowserProvider.BookmarkColumns.BOOKMARK + " = 1",
                                null,
                                null);
 
+            if (Build.MANUFACTURER.equals(SAMSUNG_MANUFACTURER) && cursor.getCount() == 0) {
+                cursor = mCr.query(SAMSUNG_BOOKMARKS_URI, null, null, null, null);
+            }
+
             if (cursor != null) {
                 final int faviconCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.FAVICON);
                 final int titleCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.TITLE);
                 final int urlCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.URL);
                 // http://code.google.com/p/android/issues/detail?id=17969
                 final int createCol = cursor.getColumnIndex(LegacyBrowserProvider.BookmarkColumns.CREATED);
 
                 cursor.moveToFirst();
@@ -116,16 +125,20 @@ class AndroidImport implements Runnable 
         try {
             cursor = mCr.query(LegacyBrowserProvider.BOOKMARKS_URI,
                                null,
                                LegacyBrowserProvider.BookmarkColumns.BOOKMARK + " = 0 AND " +
                                LegacyBrowserProvider.BookmarkColumns.VISITS + " > 0",
                                null,
                                null);
 
+            if (Build.MANUFACTURER.equals(SAMSUNG_MANUFACTURER) && cursor.getCount() == 0) {
+                cursor = mCr.query(SAMSUNG_HISTORY_URI, null, null, null, null);
+            }
+
             if (cursor != null) {
                 final int dateCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.DATE);
                 final int faviconCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.FAVICON);
                 final int titleCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.TITLE);
                 final int urlCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.URL);
                 final int visitsCol = cursor.getColumnIndexOrThrow(LegacyBrowserProvider.BookmarkColumns.VISITS);
 
                 cursor.moveToFirst();