diff options
-rw-r--r-- | core/java/android/database/sqlite/SQLiteOpenHelper.java | 10 | ||||
-rw-r--r-- | core/java/android/util/Log.java | 35 | ||||
-rw-r--r-- | core/java/android/view/SurfaceView.java | 41 |
3 files changed, 84 insertions, 2 deletions
diff --git a/core/java/android/database/sqlite/SQLiteOpenHelper.java b/core/java/android/database/sqlite/SQLiteOpenHelper.java index 52aac3a822b3..aefbabc4da91 100644 --- a/core/java/android/database/sqlite/SQLiteOpenHelper.java +++ b/core/java/android/database/sqlite/SQLiteOpenHelper.java @@ -28,6 +28,12 @@ import android.util.Log; * Transactions are used to make sure the database is always in a sensible state. * <p>For an example, see the NotePadProvider class in the NotePad sample application, * in the <em>samples/</em> directory of the SDK.</p> + * + * <p class="note"><strong>Note:</strong> this class assumes + * monotonically increasing version numbers for upgrades. Also, there + * is no concept of a database downgrade; installing a new version of + * your app which uses a lower version number than a + * previously-installed version will result in undefined behavior.</p> */ public abstract class SQLiteOpenHelper { private static final String TAG = SQLiteOpenHelper.class.getSimpleName(); @@ -105,6 +111,10 @@ public abstract class SQLiteOpenHelper { if (version == 0) { onCreate(db); } else { + if (version > mNewVersion) { + Log.wtf(TAG, "Can't downgrade read-only database from version " + + version + " to " + mNewVersion + ": " + db.getPath()); + } onUpgrade(db, version, mNewVersion); } db.setVersion(mNewVersion); diff --git a/core/java/android/util/Log.java b/core/java/android/util/Log.java index e1116694e4a6..d577b74d5d2b 100644 --- a/core/java/android/util/Log.java +++ b/core/java/android/util/Log.java @@ -88,6 +88,21 @@ public final class Log { TerribleFailure(String msg, Throwable cause) { super(msg, cause); } } + /** + * Interface to handle terrible failures from {@link #wtf()}. + * + * @hide + */ + public interface TerribleFailureHandler { + void onTerribleFailure(String tag, TerribleFailure what); + } + + private static TerribleFailureHandler sWtfHandler = new TerribleFailureHandler() { + public void onTerribleFailure(String tag, TerribleFailure what) { + RuntimeInit.wtf(tag, what); + } + }; + private Log() { } @@ -257,13 +272,29 @@ public final class Log { * @param tr An exception to log. May be null. */ public static int wtf(String tag, String msg, Throwable tr) { - tr = new TerribleFailure(msg, tr); + TerribleFailure what = new TerribleFailure(msg, tr); int bytes = println_native(LOG_ID_MAIN, ASSERT, tag, getStackTraceString(tr)); - RuntimeInit.wtf(tag, tr); + sWtfHandler.onTerribleFailure(tag, what); return bytes; } /** + * Sets the terrible failure handler, for testing. + * + * @return the old handler + * + * @hide + */ + public static TerribleFailureHandler setWtfHandler(TerribleFailureHandler handler) { + if (handler == null) { + throw new NullPointerException("handler == null"); + } + TerribleFailureHandler oldHandler = sWtfHandler; + sWtfHandler = handler; + return oldHandler; + } + + /** * Handy function to get a loggable stack trace from a Throwable * @param tr An exception to log */ diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index cc30d71de313..0f0cf602727f 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -16,6 +16,7 @@ package android.view; +import android.util.DisplayMetrics; import com.android.internal.view.BaseIWindow; import android.content.Context; @@ -219,6 +220,46 @@ public class SurfaceView extends View { mRequestedVisible = mWindowVisibility && mViewVisibility; updateWindow(false); } + + /** + * This method is not intended for general use. It was created + * temporarily to improve performance of 3D layers in Launcher + * and should be removed and fixed properly. + * + * Do not call this method. Ever. + * + * @hide + */ + protected void showSurface() { + if (mSession != null) { + updateWindow(true); + } + } + + /** + * This method is not intended for general use. It was created + * temporarily to improve performance of 3D layers in Launcher + * and should be removed and fixed properly. + * + * Do not call this method. Ever. + * + * @hide + */ + protected void hideSurface() { + if (mSession != null && mWindow != null) { + mSurfaceLock.lock(); + try { + DisplayMetrics metrics = getResources().getDisplayMetrics(); + mLayout.x = metrics.widthPixels * 3; + mSession.relayout(mWindow, mLayout, mWidth, mHeight, VISIBLE, false, + mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); + } catch (RemoteException e) { + // Ignore + } finally { + mSurfaceLock.unlock(); + } + } + } @Override protected void onDetachedFromWindow() { |