blob: ecd3f39246219ce3c026ca5091ead1f08492cb3f [file] [log] [blame]
/*
* Copyright 2019 Fairphone B.V.
*
* 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 com.fairphone.common.crash;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.SOURCE;
/**
* Class used for providing information for subsystem crashes.
*/
public final class SubsystemCrash extends Crash {
public static final String DSPS = "dsps";
public static final String LPASS = "lpass";
public static final String MODEM = "modem";
public static final String WCNSS = "wcnss";
/**
* Available subsystems that can provide crash information.
*
* TODO: Are there any more we should be aware of?
*/
@Retention(SOURCE)
@StringDef({
DSPS,
LPASS,
MODEM,
WCNSS
})
public @interface Subsystem {}
private final @NonNull String mSubsystem;
private final @Nullable String mTombstone;
/**
* @param timestamp The epoch Unix timestamp of the crash.
* @param uptime The cumulative uptime of the subsystem since it's last crash.
* @param subsystem The subsystem this crash belongs to.
*/
public SubsystemCrash(long timestamp, long uptime, @NonNull @Subsystem String subsystem) {
this(timestamp, uptime, subsystem, null);
}
/**
* @param timestamp The epoch Unix timestamp of the crash.
* @param uptime The cumulative uptime of the subsystem since it's last crash.
* @param subsystem The subsystem this crash belongs to.
* @param tombstone The tombstone for the crash if available.
*/
public SubsystemCrash(long timestamp, long uptime,
@NonNull @Subsystem String subsystem,
@Nullable String tombstone) {
super(timestamp, uptime);
mSubsystem = subsystem;
mTombstone = tombstone;
}
@NonNull
public @Subsystem String getSubsystem() {
return mSubsystem;
}
/**
* @return The tombstone for this crash if available, otherwise {@code null}.
*/
@Nullable
public String getTombstone() {
return mTombstone;
}
}