165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/* 265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Copyright (C) 2014 The Android Open Source Project 365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Licensed under the Apache License, Version 2.0 (the "License"); 565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * you may not use this file except in compliance with the License. 665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * You may obtain a copy of the License at 765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * http://www.apache.org/licenses/LICENSE-2.0 965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 1065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Unless required by applicable law or agreed to in writing, software 1165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * distributed under the License is distributed on an "AS IS" BASIS, 1265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * See the License for the specific language governing permissions and 1465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * limitations under the License. 1565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 1665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 1765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepackage com.android.tv.settings.device.apps; 1865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 1965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.Context; 2065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.pm.ApplicationInfo; 2165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.text.format.Formatter; 2265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 235762c1a616c21c4cb294fce54ed7c9ab001b6e7cTony Mantlerimport com.android.settingslib.applications.ApplicationsState; 245762c1a616c21c4cb294fce54ed7c9ab001b6e7cTony Mantler 2565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/** 2665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Contains all the info necessary to manage an application. 2765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 2880af6ad8caf35ff81d9e031591492fd11728afdbTony Mantlerpublic class AppInfo { 2965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private final Object mLock = new Object(); 3165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private final Context mContext; 3265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private ApplicationsState.AppEntry mEntry; 3365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3480af6ad8caf35ff81d9e031591492fd11728afdbTony Mantler public AppInfo(Context context, ApplicationsState.AppEntry entry) { 3565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mContext = context; 3665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mEntry = entry; 3765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 3865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3980af6ad8caf35ff81d9e031591492fd11728afdbTony Mantler public void setEntry(ApplicationsState.AppEntry entry) { 4065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane synchronized (mLock) { 4165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mEntry = entry; 4265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 4365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 4465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 4580af6ad8caf35ff81d9e031591492fd11728afdbTony Mantler public String getName() { 4665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane synchronized (mLock) { 4765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mEntry.ensureLabel(mContext); 4865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return mEntry.label; 4965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 5065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 5165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 5280af6ad8caf35ff81d9e031591492fd11728afdbTony Mantler public String getSize() { 5365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane synchronized (mLock) { 5465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return mEntry.sizeStr; 5565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 5665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 5765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 5880af6ad8caf35ff81d9e031591492fd11728afdbTony Mantler public String getPackageName() { 5965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane synchronized (mLock) { 6065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return mEntry.info.packageName; 6165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 6265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 6365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 6465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 6565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public String toString() { 6665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return getName(); 6765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 6865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane} 69