1 /* 2 * Copyright (C) 2014 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.launcher3.compat; 18 19 import android.content.Context; 20 21 import java.util.HashMap; 22 23 public abstract class PackageInstallerCompat { 24 25 public static final int STATUS_INSTALLED = 0; 26 public static final int STATUS_INSTALLING = 1; 27 public static final int STATUS_FAILED = 2; 28 29 private static final Object sInstanceLock = new Object(); 30 private static PackageInstallerCompat sInstance; 31 getInstance(Context context)32 public static PackageInstallerCompat getInstance(Context context) { 33 synchronized (sInstanceLock) { 34 if (sInstance == null) { 35 sInstance = new PackageInstallerCompatVL(context); 36 } 37 return sInstance; 38 } 39 } 40 41 /** 42 * @return a map of active installs to their progress 43 */ updateAndGetActiveSessionCache()44 public abstract HashMap<String, Integer> updateAndGetActiveSessionCache(); 45 onStop()46 public abstract void onStop(); 47 48 public static final class PackageInstallInfo { 49 public final String packageName; 50 51 public int state; 52 public int progress; 53 PackageInstallInfo(String packageName)54 public PackageInstallInfo(String packageName) { 55 this.packageName = packageName; 56 } 57 PackageInstallInfo(String packageName, int state, int progress)58 public PackageInstallInfo(String packageName, int state, int progress) { 59 this.packageName = packageName; 60 this.state = state; 61 this.progress = progress; 62 } 63 } 64 } 65