Home | History | Annotate | Download | only in app
      1 /*
      2  * Copyright (C) 2017 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 
     17 package android.app;
     18 
     19 import android.content.Intent;
     20 import android.os.Parcel;
     21 import android.os.Parcelable;
     22 
     23 /**
     24  * Describes a Service.onStartCommand() request from the system.
     25  * @hide
     26  */
     27 public class ServiceStartArgs implements Parcelable {
     28     final public boolean taskRemoved;
     29     final public int startId;
     30     final public int flags;
     31     final public Intent args;
     32 
     33     public ServiceStartArgs(boolean _taskRemoved, int _startId, int _flags, Intent _args) {
     34         taskRemoved = _taskRemoved;
     35         startId = _startId;
     36         flags = _flags;
     37         args = _args;
     38     }
     39 
     40     public String toString() {
     41         return "ServiceStartArgs{taskRemoved=" + taskRemoved + ", startId=" + startId
     42                 + ", flags=0x" + Integer.toHexString(flags) + ", args=" + args + "}";
     43     }
     44 
     45     public int describeContents() {
     46         return 0;
     47     }
     48 
     49     public void writeToParcel(Parcel out, int flags) {
     50         out.writeInt(taskRemoved ? 1 : 0);
     51         out.writeInt(startId);
     52         out.writeInt(flags);
     53         if (args != null) {
     54             out.writeInt(1);
     55             args.writeToParcel(out, 0);
     56         } else {
     57             out.writeInt(0);
     58         }
     59     }
     60 
     61     public static final @android.annotation.NonNull Parcelable.Creator<ServiceStartArgs> CREATOR
     62             = new Parcelable.Creator<ServiceStartArgs>() {
     63         public ServiceStartArgs createFromParcel(Parcel in) {
     64             return new ServiceStartArgs(in);
     65         }
     66 
     67         public ServiceStartArgs[] newArray(int size) {
     68             return new ServiceStartArgs[size];
     69         }
     70     };
     71 
     72     public ServiceStartArgs(Parcel in) {
     73         taskRemoved = in.readInt() != 0;
     74         startId = in.readInt();
     75         flags = in.readInt();
     76         if (in.readInt() != 0) {
     77             args = Intent.CREATOR.createFromParcel(in);
     78         } else {
     79             args = null;
     80         }
     81     }
     82 }
     83