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 17package com.android.tv.settings.device.apps; 18 19import android.content.Context; 20import android.content.pm.ApplicationInfo; 21import android.text.format.Formatter; 22 23import com.android.settingslib.applications.ApplicationsState; 24 25/** 26 * Contains all the info necessary to manage an application. 27 */ 28public class AppInfo { 29 30 private final Object mLock = new Object(); 31 private final Context mContext; 32 private ApplicationsState.AppEntry mEntry; 33 34 public AppInfo(Context context, ApplicationsState.AppEntry entry) { 35 mContext = context; 36 mEntry = entry; 37 } 38 39 public void setEntry(ApplicationsState.AppEntry entry) { 40 synchronized (mLock) { 41 mEntry = entry; 42 } 43 } 44 45 public String getName() { 46 synchronized (mLock) { 47 mEntry.ensureLabel(mContext); 48 return mEntry.label; 49 } 50 } 51 52 public String getSize() { 53 synchronized (mLock) { 54 return mEntry.sizeStr; 55 } 56 } 57 58 public String getPackageName() { 59 synchronized (mLock) { 60 return mEntry.info.packageName; 61 } 62 } 63 64 @Override 65 public String toString() { 66 return getName(); 67 } 68} 69