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

Commit 32e60c79 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick
Browse files

Update StrictMode's public API.

This makes it more future-proof and maintainable, not exposing the
internal bitpacking state.

The implementation is unchanged (the policy is still just an int we pass
around).

Also starts to introduce VmPolicy, for things which are process-wide,
not per-thread.  As an initial user, make SQLite's Cursor finalization
leak warnings use StrictMode.

Change-Id: Idedfba4e965716f5089a52036421460b1f383725
parent f7681f84
Loading
Loading
Loading
Loading
+280 −42
Original line number Diff line number Diff line
@@ -128580,7 +128580,7 @@
 visibility="public"
>
<method name="allowThreadDiskReads"
 return="int"
 return="android.os.StrictMode.ThreadPolicy"
 abstract="false"
 native="false"
 synchronized="false"
@@ -128591,7 +128591,7 @@
>
</method>
<method name="allowThreadDiskWrites"
 return="int"
 return="android.os.StrictMode.ThreadPolicy"
 abstract="false"
 native="false"
 synchronized="false"
@@ -128602,7 +128602,18 @@
>
</method>
<method name="getThreadPolicy"
 return="int"
 return="android.os.StrictMode.ThreadPolicy"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getVmPolicy"
 return="android.os.StrictMode.VmPolicy"
 abstract="false"
 native="false"
 synchronized="false"
@@ -128622,86 +128633,313 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="policyMask" type="int">
<parameter name="policy" type="android.os.StrictMode.ThreadPolicy">
</parameter>
</method>
<field name="DISALLOW_DISK_READ"
 type="int"
 transient="false"
 volatile="false"
 value="2"
<method name="setVmPolicy"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="DISALLOW_DISK_WRITE"
 type="int"
 transient="false"
 volatile="false"
 value="1"
<parameter name="policy" type="android.os.StrictMode.VmPolicy">
</parameter>
</method>
</class>
<class name="StrictMode.ThreadPolicy"
 extends="java.lang.Object"
 abstract="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="DISALLOW_NETWORK"
 type="int"
<field name="LAX"
 type="android.os.StrictMode.ThreadPolicy"
 transient="false"
 volatile="false"
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PENALTY_DEATH"
 type="int"
 transient="false"
 volatile="false"
 value="64"
</class>
<class name="StrictMode.ThreadPolicy.Builder"
 extends="java.lang.Object"
 abstract="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PENALTY_DIALOG"
 type="int"
 transient="false"
 volatile="false"
 value="32"
<constructor name="StrictMode.ThreadPolicy.Builder"
 type="android.os.StrictMode.ThreadPolicy.Builder"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
<constructor name="StrictMode.ThreadPolicy.Builder"
 type="android.os.StrictMode.ThreadPolicy.Builder"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="policy" type="android.os.StrictMode.ThreadPolicy">
</parameter>
</constructor>
<method name="build"
 return="android.os.StrictMode.ThreadPolicy"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="detectAll"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="detectDiskReads"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="detectDiskWrites"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="detectNetwork"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="penaltyDeath"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="penaltyDialog"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="penaltyDropBox"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="penaltyLog"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="permitAll"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="permitDiskReads"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="permitDiskWrites"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="permitNetwork"
 return="android.os.StrictMode.ThreadPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
</class>
<class name="StrictMode.VmPolicy"
 extends="java.lang.Object"
 abstract="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PENALTY_DROPBOX"
 type="int"
<field name="LAX"
 type="android.os.StrictMode.VmPolicy"
 transient="false"
 volatile="false"
 value="128"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PENALTY_LOG"
 type="int"
 transient="false"
 volatile="false"
 value="16"
</class>
<class name="StrictMode.VmPolicy.Builder"
 extends="java.lang.Object"
 abstract="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<constructor name="StrictMode.VmPolicy.Builder"
 type="android.os.StrictMode.VmPolicy.Builder"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
<method name="build"
 return="android.os.StrictMode.VmPolicy"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="detectAll"
 return="android.os.StrictMode.VmPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="detectLeakedSqlLiteObjects"
 return="android.os.StrictMode.VmPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="penaltyDeath"
 return="android.os.StrictMode.VmPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="penaltyDropBox"
 return="android.os.StrictMode.VmPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="penaltyLog"
 return="android.os.StrictMode.VmPolicy.Builder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
</class>
<class name="SystemClock"
 extends="java.lang.Object"
@@ -232687,7 +232925,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="n" type="long">
<parameter name="byteCount" type="long">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
+8 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.database.sqlite;

import android.os.StrictMode;
import android.util.Log;

/**
@@ -145,10 +146,14 @@ import android.util.Log;
            if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
                Log.v(TAG, "** warning ** Finalized DbObj (id#" + nStatement + ")");
            }
            if (StrictMode.vmSqliteObjectLeaksEnabled()) {
                int len = mSqlStmt.length();
            Log.w(TAG, "Releasing statement in a finalizer. Please ensure " +
                StrictMode.onSqliteObjectLeaked(
                    "Releasing statement in a finalizer. Please ensure " +
                    "that you explicitly call close() on your cursor: " +
                    mSqlStmt.substring(0, (len > 100) ? 100 : len), mStackTrace);
                    mSqlStmt.substring(0, (len > 100) ? 100 : len),
                    mStackTrace);
            }
            releaseSqlStatement();
        } finally {
            super.finalize();
+6 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.database.SQLException;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.os.StrictMode;
import android.text.TextUtils;
import android.util.Config;
import android.util.Log;
@@ -582,11 +583,14 @@ public class SQLiteCursor extends AbstractWindowedCursor {
        try {
            // if the cursor hasn't been closed yet, close it first
            if (mWindow != null) {
                if (StrictMode.vmSqliteObjectLeaksEnabled()) {
                    int len = mQuery.mSql.length();
                Log.e(TAG, "Finalizing a Cursor that has not been deactivated or closed. " +
                    StrictMode.onSqliteObjectLeaked(
                        "Finalizing a Cursor that has not been deactivated or closed. " +
                        "database = " + mDatabase.getPath() + ", table = " + mEditTable +
                        ", query = " + mQuery.mSql.substring(0, (len > 100) ? 100 : len),
                        mStackTrace);
                }
                close();
                SQLiteDebug.notifyActiveCursorFinalized();
            } else {
+485 −85

File changed.

Preview size limit exceeded, changes collapsed.