1 /*
2  * Copyright 2019 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.servertransaction;
18 
19 import android.annotation.Nullable;
20 import android.app.ActivityThread.ActivityClientRecord;
21 import android.app.ClientTransactionHandler;
22 import android.os.Parcel;
23 
24 /**
25  * Request an activity to enter picture-in-picture mode.
26  * @hide
27  */
28 public final class EnterPipRequestedItem extends ActivityTransactionItem {
29 
30     @Override
execute(ClientTransactionHandler client, ActivityClientRecord r, PendingTransactionActions pendingActions)31     public void execute(ClientTransactionHandler client, ActivityClientRecord r,
32             PendingTransactionActions pendingActions) {
33         client.handlePictureInPictureRequested(r);
34     }
35 
36     // ObjectPoolItem implementation
37 
EnterPipRequestedItem()38     private EnterPipRequestedItem() {}
39 
40     /** Obtain an instance initialized with provided params. */
obtain()41     public static EnterPipRequestedItem obtain() {
42         EnterPipRequestedItem instance = ObjectPool.obtain(EnterPipRequestedItem.class);
43         if (instance == null) {
44             instance = new EnterPipRequestedItem();
45         }
46         return instance;
47     }
48 
49     @Override
recycle()50     public void recycle() {
51         ObjectPool.recycle(this);
52     }
53 
54     // Parcelable implementation
55 
56     @Override
writeToParcel(Parcel dest, int flags)57     public void writeToParcel(Parcel dest, int flags) { }
58 
59     public static final @android.annotation.NonNull Creator<EnterPipRequestedItem> CREATOR =
60             new Creator<EnterPipRequestedItem>() {
61                 public EnterPipRequestedItem createFromParcel(Parcel in) {
62                     return new EnterPipRequestedItem();
63                 }
64 
65                 public EnterPipRequestedItem[] newArray(int size) {
66                     return new EnterPipRequestedItem[size];
67                 }
68             };
69 
70     @Override
equals(@ullable Object o)71     public boolean equals(@Nullable Object o) {
72         return this == o;
73     }
74 
75     @Override
toString()76     public String toString() {
77         return "EnterPipRequestedItem{}";
78     }
79 }
80