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

Commit 1bb93bf7 authored by Kurt Nelson's avatar Kurt Nelson
Browse files

Structure StrictMode violations as Throwables

All violations of StrictMode now inherit from one central Violation
class. This unlocks adding penaltyCallback(Violation).
Parsing strings is no longer required to infer what type of violation
something is.
Violation classes have no need to be loaded in Zygote as only developers
opt-in to this feature and will see violations.

Cross-binder thread violation perf test:
before
2872331
2574093
2481208
after
1938227
1742714
2654538

Bug: 64258734
Test: cts-tradefed run cts-dev --module CtsOsTestCases --test
android.os.cts.StrictModeTest
Change-Id: I1971feb03ff77cf297c940cacee62fadb5b8422c
parent 0075dda8
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -32081,13 +32081,13 @@ package android.os {
  }
  public static final class StrictMode.ViolationInfo implements android.os.Parcelable {
    ctor public StrictMode.ViolationInfo();
    ctor public StrictMode.ViolationInfo(java.lang.Throwable, int);
    ctor public StrictMode.ViolationInfo(android.os.Parcel);
    ctor public StrictMode.ViolationInfo(android.os.Parcel, boolean);
    method public int describeContents();
    method public void dump(android.util.Printer, java.lang.String);
    method public int getPolicyMask();
    method public java.lang.String getStackTrace();
    method public int getViolationBit();
    method public java.lang.String getViolationDetails();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.os.StrictMode.ViolationInfo> CREATOR;
@@ -32095,7 +32095,6 @@ package android.os {
    field public int durationMillis;
    field public int numAnimationsRunning;
    field public long numInstances;
    field public final int policy;
    field public java.lang.String[] tags;
    field public int violationNumThisLoop;
    field public long violationUptimeMillis;
+0 −6
Original line number Diff line number Diff line
@@ -3340,14 +3340,8 @@ android.os.StrictMode$9
android.os.StrictMode$AndroidBlockGuardPolicy
android.os.StrictMode$AndroidBlockGuardPolicy$1
android.os.StrictMode$AndroidCloseGuardReporter
android.os.StrictMode$InstanceCountViolation
android.os.StrictMode$InstanceTracker
android.os.StrictMode$LogStackTrace
android.os.StrictMode$Span
android.os.StrictMode$StrictModeCustomViolation
android.os.StrictMode$StrictModeDiskReadViolation
android.os.StrictMode$StrictModeDiskWriteViolation
android.os.StrictMode$StrictModeViolation
android.os.StrictMode$ThreadPolicy
android.os.StrictMode$ThreadPolicy$Builder
android.os.StrictMode$ThreadSpanState
+0 −3
Original line number Diff line number Diff line
@@ -1865,9 +1865,6 @@ android.os.StrictMode$InstanceCountViolation
android.os.StrictMode$InstanceTracker
android.os.StrictMode$LogStackTrace
android.os.StrictMode$Span
android.os.StrictMode$StrictModeDiskReadViolation
android.os.StrictMode$StrictModeDiskWriteViolation
android.os.StrictMode$StrictModeViolation
android.os.StrictMode$ThreadPolicy
android.os.StrictMode$ThreadPolicy$Builder
android.os.StrictMode$ThreadSpanState
+127 −234

File changed.

Preview size limit exceeded, changes collapsed.

+23 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.os.strictmode;

/** @hide */
public final class CleartextNetworkViolation extends Violation {
    public CleartextNetworkViolation(String msg) {
        super(msg);
    }
}
Loading