Loading services/core/java/android/content/pm/PackageManagerInternal.java +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ import java.util.function.Consumer; * * @hide Only for use within the system server. */ public abstract class PackageManagerInternal implements PackageSettingsSnapshotProvider { public abstract class PackageManagerInternal { @IntDef(prefix = "PACKAGE_", value = { PACKAGE_SYSTEM, PACKAGE_SETUP_WIZARD, Loading services/core/java/android/content/pm/PackageSettingsSnapshotProvider.javadeleted 100644 → 0 +0 −77 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.content.pm; import android.annotation.NonNull; import com.android.internal.util.FunctionalUtils; import com.android.server.pm.PackageManagerService; import com.android.server.pm.PackageSetting; import com.android.server.pm.pkg.PackageStateInternal; import java.util.function.Consumer; import java.util.function.Function; /** @hide */ public interface PackageSettingsSnapshotProvider { /** * Run a function block that requires access to {@link PackageStateInternal} data. This will * ensure the {@link PackageManagerService} lock is taken before any caller's internal lock * to avoid deadlock. Note that this method may or may not lock. If a snapshot is available * and valid, it will iterate the snapshot set of data. */ void withPackageSettingsSnapshot( @NonNull Consumer<Function<String, PackageStateInternal>> block); /** * Variant which returns a value to the caller. * @see #withPackageSettingsSnapshot(Consumer) */ <Output> Output withPackageSettingsSnapshotReturning( @NonNull FunctionalUtils.ThrowingFunction<Function<String, PackageStateInternal>, Output> block); /** * Variant which throws. * @see #withPackageSettingsSnapshot(Consumer) */ <ExceptionType extends Exception> void withPackageSettingsSnapshotThrowing( @NonNull FunctionalUtils.ThrowingCheckedConsumer<Function<String, PackageStateInternal>, ExceptionType> block) throws ExceptionType; /** * Variant which throws 2 exceptions. * @see #withPackageSettingsSnapshot(Consumer) */ <ExceptionOne extends Exception, ExceptionTwo extends Exception> void withPackageSettingsSnapshotThrowing2( @NonNull FunctionalUtils.ThrowingChecked2Consumer< Function<String, PackageStateInternal>, ExceptionOne, ExceptionTwo> block) throws ExceptionOne, ExceptionTwo; /** * Variant which returns a value to the caller and throws. * @see #withPackageSettingsSnapshot(Consumer) */ <Output, ExceptionType extends Exception> Output withPackageSettingsSnapshotReturningThrowing( @NonNull FunctionalUtils.ThrowingCheckedFunction< Function<String, PackageStateInternal>, Output, ExceptionType> block) throws ExceptionType; } services/core/java/com/android/server/pm/ComputerEngine.java +2 −2 Original line number Diff line number Diff line Loading @@ -3134,8 +3134,8 @@ public class ComputerEngine implements Computer { writer.println("Domain verification status:"); writer.increaseIndent(); try { mDomainVerificationManager.printState(writer, packageName, UserHandle.USER_ALL, mSettings::getPackage); mDomainVerificationManager.printState(this, writer, packageName, UserHandle.USER_ALL); } catch (Exception e) { pw.println("Failure printing domain verification information"); Slog.e(TAG, "Failure printing domain verification information", e); Loading services/core/java/com/android/server/pm/DeletePackageHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -453,7 +453,8 @@ final class DeletePackageHelper { } for (final int affectedUserId : affectedUserIds) { if (hadSuspendAppsPermission.get(affectedUserId)) { mPm.unsuspendForSuspendingPackage(packageName, affectedUserId); mPm.unsuspendForSuspendingPackage(mPm.snapshotComputer(), packageName, affectedUserId); mPm.removeAllDistractingPackageRestrictions(affectedUserId); } } Loading services/core/java/com/android/server/pm/DomainVerificationConnection.java +3 −42 Original line number Diff line number Diff line Loading @@ -26,17 +26,12 @@ import android.os.Binder; import android.os.Message; import android.os.UserHandle; import com.android.internal.util.FunctionalUtils; import com.android.server.DeviceIdleInternal; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.pm.verify.domain.DomainVerificationService; import com.android.server.pm.verify.domain.proxy.DomainVerificationProxyV1; import com.android.server.pm.verify.domain.proxy.DomainVerificationProxyV2; import java.util.function.Consumer; import java.util.function.Function; public final class DomainVerificationConnection implements DomainVerificationService.Connection, DomainVerificationProxyV1.Connection, DomainVerificationProxyV2.Connection { final PackageManagerService mPm; Loading Loading @@ -111,42 +106,8 @@ public final class DomainVerificationConnection implements DomainVerificationSer return mUmInternal.exists(userId); } @Override public void withPackageSettingsSnapshot( @NonNull Consumer<Function<String, PackageStateInternal>> block) { mPmInternal.withPackageSettingsSnapshot(block); } @Override public <Output> Output withPackageSettingsSnapshotReturning( @NonNull FunctionalUtils.ThrowingFunction<Function<String, PackageStateInternal>, Output> block) { return mPmInternal.withPackageSettingsSnapshotReturning(block); } @Override public <ExceptionType extends Exception> void withPackageSettingsSnapshotThrowing( @NonNull FunctionalUtils.ThrowingCheckedConsumer<Function<String, PackageStateInternal>, ExceptionType> block) throws ExceptionType { mPmInternal.withPackageSettingsSnapshotThrowing(block); } @Override public <ExceptionOne extends Exception, ExceptionTwo extends Exception> void withPackageSettingsSnapshotThrowing2( @NonNull FunctionalUtils.ThrowingChecked2Consumer< Function<String, PackageStateInternal>, ExceptionOne, ExceptionTwo> block) throws ExceptionOne, ExceptionTwo { mPmInternal.withPackageSettingsSnapshotThrowing2(block); } @Override public <Output, ExceptionType extends Exception> Output withPackageSettingsSnapshotReturningThrowing( @NonNull FunctionalUtils.ThrowingCheckedFunction< Function<String, PackageStateInternal>, Output, ExceptionType> block) throws ExceptionType { return mPmInternal.withPackageSettingsSnapshotReturningThrowing(block); @NonNull public Computer snapshot() { return (Computer) mPmInternal.snapshot(); } } Loading
services/core/java/android/content/pm/PackageManagerInternal.java +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ import java.util.function.Consumer; * * @hide Only for use within the system server. */ public abstract class PackageManagerInternal implements PackageSettingsSnapshotProvider { public abstract class PackageManagerInternal { @IntDef(prefix = "PACKAGE_", value = { PACKAGE_SYSTEM, PACKAGE_SETUP_WIZARD, Loading
services/core/java/android/content/pm/PackageSettingsSnapshotProvider.javadeleted 100644 → 0 +0 −77 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.content.pm; import android.annotation.NonNull; import com.android.internal.util.FunctionalUtils; import com.android.server.pm.PackageManagerService; import com.android.server.pm.PackageSetting; import com.android.server.pm.pkg.PackageStateInternal; import java.util.function.Consumer; import java.util.function.Function; /** @hide */ public interface PackageSettingsSnapshotProvider { /** * Run a function block that requires access to {@link PackageStateInternal} data. This will * ensure the {@link PackageManagerService} lock is taken before any caller's internal lock * to avoid deadlock. Note that this method may or may not lock. If a snapshot is available * and valid, it will iterate the snapshot set of data. */ void withPackageSettingsSnapshot( @NonNull Consumer<Function<String, PackageStateInternal>> block); /** * Variant which returns a value to the caller. * @see #withPackageSettingsSnapshot(Consumer) */ <Output> Output withPackageSettingsSnapshotReturning( @NonNull FunctionalUtils.ThrowingFunction<Function<String, PackageStateInternal>, Output> block); /** * Variant which throws. * @see #withPackageSettingsSnapshot(Consumer) */ <ExceptionType extends Exception> void withPackageSettingsSnapshotThrowing( @NonNull FunctionalUtils.ThrowingCheckedConsumer<Function<String, PackageStateInternal>, ExceptionType> block) throws ExceptionType; /** * Variant which throws 2 exceptions. * @see #withPackageSettingsSnapshot(Consumer) */ <ExceptionOne extends Exception, ExceptionTwo extends Exception> void withPackageSettingsSnapshotThrowing2( @NonNull FunctionalUtils.ThrowingChecked2Consumer< Function<String, PackageStateInternal>, ExceptionOne, ExceptionTwo> block) throws ExceptionOne, ExceptionTwo; /** * Variant which returns a value to the caller and throws. * @see #withPackageSettingsSnapshot(Consumer) */ <Output, ExceptionType extends Exception> Output withPackageSettingsSnapshotReturningThrowing( @NonNull FunctionalUtils.ThrowingCheckedFunction< Function<String, PackageStateInternal>, Output, ExceptionType> block) throws ExceptionType; }
services/core/java/com/android/server/pm/ComputerEngine.java +2 −2 Original line number Diff line number Diff line Loading @@ -3134,8 +3134,8 @@ public class ComputerEngine implements Computer { writer.println("Domain verification status:"); writer.increaseIndent(); try { mDomainVerificationManager.printState(writer, packageName, UserHandle.USER_ALL, mSettings::getPackage); mDomainVerificationManager.printState(this, writer, packageName, UserHandle.USER_ALL); } catch (Exception e) { pw.println("Failure printing domain verification information"); Slog.e(TAG, "Failure printing domain verification information", e); Loading
services/core/java/com/android/server/pm/DeletePackageHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -453,7 +453,8 @@ final class DeletePackageHelper { } for (final int affectedUserId : affectedUserIds) { if (hadSuspendAppsPermission.get(affectedUserId)) { mPm.unsuspendForSuspendingPackage(packageName, affectedUserId); mPm.unsuspendForSuspendingPackage(mPm.snapshotComputer(), packageName, affectedUserId); mPm.removeAllDistractingPackageRestrictions(affectedUserId); } } Loading
services/core/java/com/android/server/pm/DomainVerificationConnection.java +3 −42 Original line number Diff line number Diff line Loading @@ -26,17 +26,12 @@ import android.os.Binder; import android.os.Message; import android.os.UserHandle; import com.android.internal.util.FunctionalUtils; import com.android.server.DeviceIdleInternal; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.pm.verify.domain.DomainVerificationService; import com.android.server.pm.verify.domain.proxy.DomainVerificationProxyV1; import com.android.server.pm.verify.domain.proxy.DomainVerificationProxyV2; import java.util.function.Consumer; import java.util.function.Function; public final class DomainVerificationConnection implements DomainVerificationService.Connection, DomainVerificationProxyV1.Connection, DomainVerificationProxyV2.Connection { final PackageManagerService mPm; Loading Loading @@ -111,42 +106,8 @@ public final class DomainVerificationConnection implements DomainVerificationSer return mUmInternal.exists(userId); } @Override public void withPackageSettingsSnapshot( @NonNull Consumer<Function<String, PackageStateInternal>> block) { mPmInternal.withPackageSettingsSnapshot(block); } @Override public <Output> Output withPackageSettingsSnapshotReturning( @NonNull FunctionalUtils.ThrowingFunction<Function<String, PackageStateInternal>, Output> block) { return mPmInternal.withPackageSettingsSnapshotReturning(block); } @Override public <ExceptionType extends Exception> void withPackageSettingsSnapshotThrowing( @NonNull FunctionalUtils.ThrowingCheckedConsumer<Function<String, PackageStateInternal>, ExceptionType> block) throws ExceptionType { mPmInternal.withPackageSettingsSnapshotThrowing(block); } @Override public <ExceptionOne extends Exception, ExceptionTwo extends Exception> void withPackageSettingsSnapshotThrowing2( @NonNull FunctionalUtils.ThrowingChecked2Consumer< Function<String, PackageStateInternal>, ExceptionOne, ExceptionTwo> block) throws ExceptionOne, ExceptionTwo { mPmInternal.withPackageSettingsSnapshotThrowing2(block); } @Override public <Output, ExceptionType extends Exception> Output withPackageSettingsSnapshotReturningThrowing( @NonNull FunctionalUtils.ThrowingCheckedFunction< Function<String, PackageStateInternal>, Output, ExceptionType> block) throws ExceptionType { return mPmInternal.withPackageSettingsSnapshotReturningThrowing(block); @NonNull public Computer snapshot() { return (Computer) mPmInternal.snapshot(); } }