All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.android.os.IncidentReportArgs Maven / Gradle / Ivy

Go to download

A library jar that provides APIs for Applications written for the Google Android Platform.

There is a newer version: 15-robolectric-12650502
Show newest version
/*
 * Copyright (C) 2005 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;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.IntArray;

import java.util.ArrayList;

/**
 * The arguments for an incident report.
 * {@hide}
 */
@SystemApi
public final class IncidentReportArgs implements Parcelable {

    private final IntArray mSections = new IntArray();
    private final ArrayList mHeaders = new ArrayList();
    private boolean mAll;
    private int mPrivacyPolicy;
    private String mReceiverPkg;
    private String mReceiverCls;

    /**
     * Construct an incident report args with no fields.
     */
    public IncidentReportArgs() {
        mPrivacyPolicy = IncidentManager.PRIVACY_POLICY_AUTO;
    }

    /**
     * Construct an incdent report args from the given parcel.
     */
    public IncidentReportArgs(Parcel in) {
        readFromParcel(in);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(mAll ? 1 : 0);

        int N = mSections.size();
        out.writeInt(N);
        for (int i=0; i CREATOR
            = new Parcelable.Creator() {
        public IncidentReportArgs createFromParcel(Parcel in) {
            return new IncidentReportArgs(in);
        }

        public IncidentReportArgs[] newArray(int size) {
            return new IncidentReportArgs[size];
        }
    };

    /**
     * Print this report as a string.
     */
    @NonNull
    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Incident(");
        if (mAll) {
            sb.append("all");
        } else {
            final int N = mSections.size();
            if (N > 0) {
                sb.append(mSections.get(0));
            }
            for (int i=1; i 1) {
            mSections.add(section);
        }
    }

    /**
     * Returns whether the incident report will include all fields.
     */
    public boolean isAll() {
        return mAll;
    }

    /**
     * Returns whether this section will be included in the incident report.
     */
    public boolean containsSection(int section) {
        return mAll || mSections.indexOf(section) >= 0;
    }

    public int sectionCount() {
        return mSections.size();
    }

    public void addHeader(byte[] header) {
        mHeaders.add(header);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy