1 /* 2 * Copyright (C) 2024 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 com.google.android.apps.miphone.aiai.matchmaker.overview.api.generatedv2; 18 19 import static androidx.test.core.app.ApplicationProvider.getApplicationContext; 20 21 import android.content.Context; 22 import android.os.Bundle; 23 import android.security.cts.CVE_2023_35676.R; 24 25 import java.util.ArrayList; 26 import java.util.Iterator; 27 28 // For reference 29 // https://source.corp.google.com/piper///depot/google3/java/com/google/android/apps/miphone/aiai/matchmaker/overview/api/generatedv2/SuggestParcelables.java 30 public class SuggestParcelables { 31 static Context context = getApplicationContext(); 32 33 public static final class Action { 34 public String displayName; 35 public String fullDisplayName; 36 public String id; 37 Action()38 public Action() {} 39 Action(Bundle bundle)40 public Action(Bundle bundle) { 41 if (bundle.containsKey(context.getString(R.string.id))) { 42 this.id = bundle.getString(context.getString(R.string.id)); 43 } 44 if (bundle.containsKey(context.getString(R.string.displayName))) { 45 this.displayName = bundle.getString(context.getString(R.string.displayName)); 46 } 47 if (bundle.containsKey(context.getString(R.string.fullDisplayName))) { 48 this.fullDisplayName = 49 bundle.getString(context.getString(R.string.fullDisplayName)); 50 } 51 } 52 writeToBundle()53 public final Bundle writeToBundle() { 54 Bundle bundle = new Bundle(); 55 bundle.putString(context.getString(R.string.id), this.id); 56 bundle.putString(context.getString(R.string.displayName), this.displayName); 57 bundle.putString(context.getString(R.string.fullDisplayName), this.fullDisplayName); 58 bundle.putBundle(context.getString(R.string.proxiedIntentInfo), null); 59 return bundle; 60 } 61 } 62 63 public static final class ActionGroup { 64 public String displayName; 65 public String id; 66 public Action mainAction; 67 ActionGroup()68 public ActionGroup() {} 69 ActionGroup(Bundle bundle)70 public ActionGroup(Bundle bundle) { 71 if (bundle.containsKey(context.getString(R.string.id))) { 72 this.id = bundle.getString(context.getString(R.string.id)); 73 } 74 if (bundle.containsKey(context.getString(R.string.displayName))) { 75 this.displayName = bundle.getString(context.getString(R.string.displayName)); 76 } 77 if (bundle.containsKey(context.getString(R.string.mainAction))) { 78 Bundle bundle2 = bundle.getBundle(context.getString(R.string.mainAction)); 79 if (bundle2 == null) { 80 this.mainAction = null; 81 } else { 82 this.mainAction = new Action(bundle2); 83 } 84 } 85 } 86 } 87 88 public static final class Entities { 89 public ArrayList entities; 90 public ExtrasInfo extrasInfo; 91 Entities()92 public Entities() {} 93 } 94 95 public static final class Entity { 96 public ArrayList actions; 97 public String searchQueryHint; 98 Entity()99 public Entity() {} 100 Entity(Bundle bundle)101 public Entity(Bundle bundle) { 102 if (bundle.containsKey(context.getString(R.string.actions))) { 103 ArrayList parcelableArrayList = 104 bundle.getParcelableArrayList(context.getString(R.string.actions)); 105 if (parcelableArrayList == null) { 106 this.actions = null; 107 } else { 108 this.actions = new ArrayList(parcelableArrayList.size()); 109 Iterator it = parcelableArrayList.iterator(); 110 while (it.hasNext()) { 111 Bundle bundle2 = (Bundle) it.next(); 112 if (bundle2 != null) { 113 this.actions.add(new ActionGroup(bundle2)); 114 } 115 } 116 } 117 } 118 if (bundle.containsKey(context.getString(R.string.searchQueryHint))) { 119 this.searchQueryHint = 120 bundle.getString(context.getString(R.string.searchQueryHint)); 121 } 122 } 123 } 124 125 public static final class ExtrasInfo { 126 public boolean containsBitmaps; 127 public boolean containsPendingIntents; 128 ExtrasInfo(Bundle bundle)129 public ExtrasInfo(Bundle bundle) { 130 if (bundle.containsKey(context.getString(R.string.containsPendingIntents))) { 131 this.containsPendingIntents = 132 bundle.getBoolean(context.getString(R.string.containsPendingIntents)); 133 } 134 if (bundle.containsKey(context.getString(R.string.containsBitmaps))) { 135 this.containsBitmaps = 136 bundle.getBoolean(context.getString(R.string.containsBitmaps)); 137 } 138 } 139 } 140 } 141