Loading core/java/android/app/Instrumentation.java +14 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,20 @@ public class Instrumentation { } } /** * Returns if it is being called in an instrumentation environment. * * @hide */ public boolean isInstrumenting() { // Check if we have an instrumentation context, as init should only get called by // the system in startup processes that are being instrumented. if (mInstrContext == null) { return false; } return true; } /** * Called when the instrumentation is starting, before any application code * has been loaded. Usually this will be implemented to simply call Loading core/java/android/app/PendingIntent.java +12 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.RemoteException; import android.os.UserHandle; import android.util.AndroidException; import android.util.ArraySet; import android.util.Log; import android.util.proto.ProtoOutputStream; import com.android.internal.os.IResultReceiver; Loading Loading @@ -107,6 +108,7 @@ import java.lang.annotation.RetentionPolicy; * FLAG_ONE_SHOT, <b>both</b> FLAG_ONE_SHOT and FLAG_NO_CREATE need to be supplied. */ public final class PendingIntent implements Parcelable { private static final String TAG = "PendingIntent"; private final IIntentSender mTarget; private IResultReceiver mCancelReceiver; private IBinder mWhitelistToken; Loading Loading @@ -350,9 +352,18 @@ public final class PendingIntent implements Parcelable { "Cannot set both FLAG_IMMUTABLE and FLAG_MUTABLE for PendingIntent"); } // TODO(b/178092897) Remove the below instrumentation check and enforce // the explicit mutability requirement for apps under instrumentation. ActivityThread thread = ActivityThread.currentActivityThread(); Instrumentation mInstrumentation = thread.getInstrumentation(); if (Compatibility.isChangeEnabled(PENDING_INTENT_EXPLICIT_MUTABILITY_REQUIRED) && !flagImmutableSet && !flagMutableSet) { if (!mInstrumentation.isInstrumenting()) { throw new IllegalArgumentException(msg); } else { Log.e(TAG, msg); } } } Loading Loading
core/java/android/app/Instrumentation.java +14 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,20 @@ public class Instrumentation { } } /** * Returns if it is being called in an instrumentation environment. * * @hide */ public boolean isInstrumenting() { // Check if we have an instrumentation context, as init should only get called by // the system in startup processes that are being instrumented. if (mInstrContext == null) { return false; } return true; } /** * Called when the instrumentation is starting, before any application code * has been loaded. Usually this will be implemented to simply call Loading
core/java/android/app/PendingIntent.java +12 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.RemoteException; import android.os.UserHandle; import android.util.AndroidException; import android.util.ArraySet; import android.util.Log; import android.util.proto.ProtoOutputStream; import com.android.internal.os.IResultReceiver; Loading Loading @@ -107,6 +108,7 @@ import java.lang.annotation.RetentionPolicy; * FLAG_ONE_SHOT, <b>both</b> FLAG_ONE_SHOT and FLAG_NO_CREATE need to be supplied. */ public final class PendingIntent implements Parcelable { private static final String TAG = "PendingIntent"; private final IIntentSender mTarget; private IResultReceiver mCancelReceiver; private IBinder mWhitelistToken; Loading Loading @@ -350,9 +352,18 @@ public final class PendingIntent implements Parcelable { "Cannot set both FLAG_IMMUTABLE and FLAG_MUTABLE for PendingIntent"); } // TODO(b/178092897) Remove the below instrumentation check and enforce // the explicit mutability requirement for apps under instrumentation. ActivityThread thread = ActivityThread.currentActivityThread(); Instrumentation mInstrumentation = thread.getInstrumentation(); if (Compatibility.isChangeEnabled(PENDING_INTENT_EXPLICIT_MUTABILITY_REQUIRED) && !flagImmutableSet && !flagMutableSet) { if (!mInstrumentation.isInstrumenting()) { throw new IllegalArgumentException(msg); } else { Log.e(TAG, msg); } } } Loading