1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package android.app; 17 18 import android.annotation.NonNull; 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** 23 * Exception thrown when an app tries to start a foreground {@link Service} with an invalid type. 24 */ 25 public final class InvalidForegroundServiceTypeException 26 extends ForegroundServiceTypeException implements Parcelable { 27 /** 28 * Constructor. 29 */ InvalidForegroundServiceTypeException(@onNull String message)30 public InvalidForegroundServiceTypeException(@NonNull String message) { 31 super(message); 32 } 33 InvalidForegroundServiceTypeException(@onNull Parcel source)34 InvalidForegroundServiceTypeException(@NonNull Parcel source) { 35 super(source.readString()); 36 } 37 38 @Override describeContents()39 public int describeContents() { 40 return 0; 41 } 42 43 @Override writeToParcel(@onNull Parcel dest, int flags)44 public void writeToParcel(@NonNull Parcel dest, int flags) { 45 dest.writeString(getMessage()); 46 } 47 48 public static final @NonNull Creator<android.app.InvalidForegroundServiceTypeException> 49 CREATOR = new Creator<android.app.InvalidForegroundServiceTypeException>() { 50 @NonNull 51 public android.app.InvalidForegroundServiceTypeException createFromParcel( 52 Parcel source) { 53 return new android.app.InvalidForegroundServiceTypeException(source); 54 } 55 56 @NonNull 57 public android.app.InvalidForegroundServiceTypeException[] newArray(int size) { 58 return new android.app.InvalidForegroundServiceTypeException[size]; 59 } 60 }; 61 } 62