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 17 package com.android.internal.pm.pkg.component; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 22 /** 23 * Contains mutation methods so that code doesn't have to cast to the Impl. Meant to eventually 24 * be removed once all post-parsing mutation is moved to parsing. 25 * 26 * @hide 27 */ 28 public class ComponentMutateUtils { 29 setMaxAspectRatio(@onNull ParsedActivity activity, int resizeMode, float maxAspectRatio)30 public static void setMaxAspectRatio(@NonNull ParsedActivity activity, int resizeMode, 31 float maxAspectRatio) { 32 ((ParsedActivityImpl) activity).setMaxAspectRatio(resizeMode, maxAspectRatio); 33 } 34 setMinAspectRatio(@onNull ParsedActivity activity, int resizeMode, float minAspectRatio)35 public static void setMinAspectRatio(@NonNull ParsedActivity activity, int resizeMode, 36 float minAspectRatio) { 37 ((ParsedActivityImpl) activity).setMinAspectRatio(resizeMode, minAspectRatio); 38 } 39 setSupportsSizeChanges(@onNull ParsedActivity activity, boolean supportsSizeChanges)40 public static void setSupportsSizeChanges(@NonNull ParsedActivity activity, 41 boolean supportsSizeChanges) { 42 ((ParsedActivityImpl) activity).setSupportsSizeChanges(supportsSizeChanges); 43 } 44 setResizeMode(@onNull ParsedActivity activity, int resizeMode)45 public static void setResizeMode(@NonNull ParsedActivity activity, int resizeMode) { 46 ((ParsedActivityImpl) activity).setResizeMode(resizeMode); 47 } 48 setExactFlags(ParsedComponent component, int exactFlags)49 public static void setExactFlags(ParsedComponent component, int exactFlags) { 50 ((ParsedComponentImpl) component).setFlags(exactFlags); 51 } 52 setEnabled(@onNull ParsedMainComponent component, boolean enabled)53 public static void setEnabled(@NonNull ParsedMainComponent component, boolean enabled) { 54 ((ParsedMainComponentImpl) component).setEnabled(enabled); 55 } 56 setPackageName(@onNull ParsedComponent component, @NonNull String packageName)57 public static void setPackageName(@NonNull ParsedComponent component, 58 @NonNull String packageName) { 59 ((ParsedComponentImpl) component).setPackageName(packageName); 60 } 61 setDirectBootAware(@onNull ParsedMainComponent component, boolean directBootAware)62 public static void setDirectBootAware(@NonNull ParsedMainComponent component, 63 boolean directBootAware) { 64 ((ParsedMainComponentImpl) component).setDirectBootAware(directBootAware); 65 } 66 setExported(@onNull ParsedMainComponent component, boolean exported)67 public static void setExported(@NonNull ParsedMainComponent component, boolean exported) { 68 ((ParsedMainComponentImpl) component).setExported(exported); 69 } 70 setAuthority(@onNull ParsedProvider provider, @Nullable String authority)71 public static void setAuthority(@NonNull ParsedProvider provider, @Nullable String authority) { 72 ((ParsedProviderImpl) provider).setAuthority(authority); 73 } 74 setSyncable(@onNull ParsedProvider provider, boolean syncable)75 public static void setSyncable(@NonNull ParsedProvider provider, boolean syncable) { 76 ((ParsedProviderImpl) provider).setSyncable(syncable); 77 } 78 setProtectionLevel(@onNull ParsedPermission permission, int protectionLevel)79 public static void setProtectionLevel(@NonNull ParsedPermission permission, 80 int protectionLevel) { 81 ((ParsedPermissionImpl) permission).setProtectionLevel(protectionLevel); 82 } 83 setParsedPermissionGroup(@onNull ParsedPermission permission, @NonNull ParsedPermissionGroup permissionGroup)84 public static void setParsedPermissionGroup(@NonNull ParsedPermission permission, 85 @NonNull ParsedPermissionGroup permissionGroup) { 86 ((ParsedPermissionImpl) permission).setParsedPermissionGroup(permissionGroup); 87 } 88 setPriority(@onNull ParsedPermissionGroup parsedPermissionGroup, int priority)89 public static void setPriority(@NonNull ParsedPermissionGroup parsedPermissionGroup, 90 int priority) { 91 ((ParsedPermissionGroupImpl) parsedPermissionGroup).setPriority(priority); 92 } 93 addStateFrom(@onNull ParsedProcess oldProcess, @NonNull ParsedProcess newProcess)94 public static void addStateFrom(@NonNull ParsedProcess oldProcess, 95 @NonNull ParsedProcess newProcess) { 96 ((ParsedProcessImpl) oldProcess).addStateFrom(newProcess); 97 } 98 } 99