| // Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| package com.android.tools.r8.optimize.accessmodification; |
| |
| import com.android.tools.r8.utils.InternalOptions; |
| import com.android.tools.r8.utils.SystemPropertyUtils; |
| |
| public class AccessModifierOptions { |
| |
| // TODO(b/131130038): Do not allow accessmodification when kept. |
| private boolean forceModifyPackagePrivateAndProtectedMethods = |
| SystemPropertyUtils.parseSystemPropertyOrDefault( |
| "com.android.tools.r8.accessmodification.forcePackagePrivateAndProtected", true); |
| |
| private final InternalOptions options; |
| |
| public AccessModifierOptions(InternalOptions options) { |
| this.options = options; |
| } |
| |
| public boolean canPollutePublicApi() { |
| return isAccessModificationRulePresent() || !options.shouldProtectApiSurface(); |
| } |
| |
| public boolean isAccessModificationEnabled() { |
| if (isAccessModificationRulePresent()) { |
| return true; |
| } |
| return !options.forceProguardCompatibility && options.isOptimizing(); |
| } |
| |
| private boolean isAccessModificationRulePresent() { |
| return options.hasProguardConfiguration() |
| && options.getProguardConfiguration().isAccessModificationAllowed(); |
| } |
| |
| public boolean isForceModifyingPackagePrivateAndProtectedMethods() { |
| return forceModifyPackagePrivateAndProtectedMethods; |
| } |
| |
| public void setForceModifyPackagePrivateAndProtectedMethods( |
| boolean forceModifyPackagePrivateAndProtectedMethods) { |
| this.forceModifyPackagePrivateAndProtectedMethods = |
| forceModifyPackagePrivateAndProtectedMethods; |
| } |
| } |