1 /* 2 * Copyright (C) 2021 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.server.pm; 18 19 import static com.android.server.pm.PackageManagerService.DEBUG_INSTALL; 20 import static com.android.server.pm.PackageManagerService.TAG; 21 22 import android.annotation.NonNull; 23 import android.os.UserHandle; 24 import android.util.Slog; 25 26 abstract class HandlerParams { 27 /** User handle for the user requesting the information or installation. */ 28 private final UserHandle mUser; 29 String mTraceMethod; 30 int mTraceCookie; 31 @NonNull 32 final PackageManagerService mPm; 33 final InstallPackageHelper mInstallPackageHelper; 34 35 // TODO(b/198166813): remove PMS dependency HandlerParams(UserHandle user, PackageManagerService pm)36 HandlerParams(UserHandle user, PackageManagerService pm) { 37 mUser = user; 38 mPm = pm; 39 mInstallPackageHelper = new InstallPackageHelper(mPm); 40 } 41 getUser()42 UserHandle getUser() { 43 return mUser; 44 } 45 setTraceMethod(String traceMethod)46 HandlerParams setTraceMethod(String traceMethod) { 47 mTraceMethod = traceMethod; 48 return this; 49 } 50 setTraceCookie(int traceCookie)51 HandlerParams setTraceCookie(int traceCookie) { 52 mTraceCookie = traceCookie; 53 return this; 54 } 55 startCopy()56 final void startCopy() { 57 if (DEBUG_INSTALL) Slog.i(TAG, "startCopy " + mUser + ": " + this); 58 handleStartCopy(); 59 handleReturnCode(); 60 } 61 handleStartCopy()62 abstract void handleStartCopy(); handleReturnCode()63 abstract void handleReturnCode(); 64 } 65