Loading src/com/android/settings/SettingsActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.os.storage.StorageManager; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; Loading Loading @@ -532,7 +533,12 @@ public class SettingsActivity extends Activity getFragmentManager().addOnBackStackChangedListener(this); if (mIsShowingDashboard) { // Run the Index update only if we have some space if (!Utils.isLowStorage(this)) { Index.getInstance(getApplicationContext()).update(); } else { Log.w(LOG_TAG, "Cannot update the Indexer as we are running low on storage space!"); } } if (savedState != null) { Loading src/com/android/settings/Utils.java +12 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.os.storage.StorageManager; import android.preference.Preference; import android.preference.PreferenceFrameLayout; import android.preference.PreferenceGroup; Loading Loading @@ -1071,4 +1072,15 @@ public final class Utils { return inflater.inflate(resId, parent, false); } /** * Return if we are running low on storage space or not. * * @param context The context * @return true if we are running low on storage space */ public static boolean isLowStorage(Context context) { final StorageManager sm = StorageManager.from(context); return (sm.getStorageBytesUntilLow(context.getFilesDir()) < 0); } } src/com/android/settings/search/Index.java +16 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.database.Cursor; import android.database.DatabaseUtils; import android.database.MergeCursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.net.Uri; import android.os.AsyncTask; import android.provider.SearchIndexableData; Loading Loading @@ -501,7 +502,12 @@ public class Index { } private SQLiteDatabase getWritableDatabase() { try { return IndexDatabaseHelper.getInstance(mContext).getWritableDatabase(); } catch (SQLiteException e) { Log.e(LOG_TAG, "Cannot open writable database", e); return null; } } private static Uri buildUriForXmlResources(String authority) { Loading Loading @@ -1172,6 +1178,10 @@ public class Index { final boolean forceUpdate = params[0].forceUpdate; final SQLiteDatabase database = getWritableDatabase(); if (database == null) { Log.e(LOG_TAG, "Cannot update Index as I cannot get a writable database"); return null; } final String localeStr = Locale.getDefault().toString(); try { Loading Loading @@ -1292,8 +1302,12 @@ public class Index { values.put(IndexDatabaseHelper.SavedQueriesColums.TIME_STAMP, now); final SQLiteDatabase database = getWritableDatabase(); if (database == null) { Log.e(LOG_TAG, "Cannot save Search queries as I cannot get a writable database"); return -1L; } long lastInsertedRowId = -1; long lastInsertedRowId = -1L; try { // First, delete all saved queries that are the same database.delete(Tables.TABLE_SAVED_QUERIES, Loading Loading
src/com/android/settings/SettingsActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.os.storage.StorageManager; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; Loading Loading @@ -532,7 +533,12 @@ public class SettingsActivity extends Activity getFragmentManager().addOnBackStackChangedListener(this); if (mIsShowingDashboard) { // Run the Index update only if we have some space if (!Utils.isLowStorage(this)) { Index.getInstance(getApplicationContext()).update(); } else { Log.w(LOG_TAG, "Cannot update the Indexer as we are running low on storage space!"); } } if (savedState != null) { Loading
src/com/android/settings/Utils.java +12 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.os.storage.StorageManager; import android.preference.Preference; import android.preference.PreferenceFrameLayout; import android.preference.PreferenceGroup; Loading Loading @@ -1071,4 +1072,15 @@ public final class Utils { return inflater.inflate(resId, parent, false); } /** * Return if we are running low on storage space or not. * * @param context The context * @return true if we are running low on storage space */ public static boolean isLowStorage(Context context) { final StorageManager sm = StorageManager.from(context); return (sm.getStorageBytesUntilLow(context.getFilesDir()) < 0); } }
src/com/android/settings/search/Index.java +16 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.database.Cursor; import android.database.DatabaseUtils; import android.database.MergeCursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.net.Uri; import android.os.AsyncTask; import android.provider.SearchIndexableData; Loading Loading @@ -501,7 +502,12 @@ public class Index { } private SQLiteDatabase getWritableDatabase() { try { return IndexDatabaseHelper.getInstance(mContext).getWritableDatabase(); } catch (SQLiteException e) { Log.e(LOG_TAG, "Cannot open writable database", e); return null; } } private static Uri buildUriForXmlResources(String authority) { Loading Loading @@ -1172,6 +1178,10 @@ public class Index { final boolean forceUpdate = params[0].forceUpdate; final SQLiteDatabase database = getWritableDatabase(); if (database == null) { Log.e(LOG_TAG, "Cannot update Index as I cannot get a writable database"); return null; } final String localeStr = Locale.getDefault().toString(); try { Loading Loading @@ -1292,8 +1302,12 @@ public class Index { values.put(IndexDatabaseHelper.SavedQueriesColums.TIME_STAMP, now); final SQLiteDatabase database = getWritableDatabase(); if (database == null) { Log.e(LOG_TAG, "Cannot save Search queries as I cannot get a writable database"); return -1L; } long lastInsertedRowId = -1; long lastInsertedRowId = -1L; try { // First, delete all saved queries that are the same database.delete(Tables.TABLE_SAVED_QUERIES, Loading