use of com.android.settingslib.AppItem in project android_frameworks_base by DirtyUnicorns.
the class ChartDataLoader method loadInBackground.
@Override
public ChartData loadInBackground() {
final NetworkTemplate template = mArgs.getParcelable(KEY_TEMPLATE);
final AppItem app = mArgs.getParcelable(KEY_APP);
final int fields = mArgs.getInt(KEY_FIELDS);
try {
return loadInBackground(template, app, fields);
} catch (RemoteException e) {
// leave with half-baked UI, we bail hard.
throw new RuntimeException("problem reading network stats", e);
}
}
use of com.android.settingslib.AppItem in project android_frameworks_base by AOSPA.
the class ChartDataLoader method loadInBackground.
@Override
public ChartData loadInBackground() {
final NetworkTemplate template = mArgs.getParcelable(KEY_TEMPLATE);
final AppItem app = mArgs.getParcelable(KEY_APP);
final int fields = mArgs.getInt(KEY_FIELDS);
try {
return loadInBackground(template, app, fields);
} catch (RemoteException e) {
// leave with half-baked UI, we bail hard.
throw new RuntimeException("problem reading network stats", e);
}
}
use of com.android.settingslib.AppItem in project android_frameworks_base by ResurrectionRemix.
the class ChartDataLoader method loadInBackground.
@Override
public ChartData loadInBackground() {
final NetworkTemplate template = mArgs.getParcelable(KEY_TEMPLATE);
final AppItem app = mArgs.getParcelable(KEY_APP);
final int fields = mArgs.getInt(KEY_FIELDS);
try {
return loadInBackground(template, app, fields);
} catch (RemoteException e) {
// leave with half-baked UI, we bail hard.
throw new RuntimeException("problem reading network stats", e);
}
}
use of com.android.settingslib.AppItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppDataUsage method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Bundle args = getArguments();
try {
mStatsSession = services.mStatsService.openSession();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
mAppItem = (args != null) ? (AppItem) args.getParcelable(ARG_APP_ITEM) : null;
mTemplate = (args != null) ? (NetworkTemplate) args.getParcelable(ARG_NETWORK_TEMPLATE) : null;
mPolicyManager = NetworkPolicyManager.from(getActivity());
if (mTemplate == null) {
Context context = getContext();
mTemplate = DataUsageSummary.getDefaultTemplate(context, DataUsageSummary.getDefaultSubscriptionId(context));
}
if (mAppItem == null) {
int uid = (args != null) ? args.getInt(AppInfoBase.ARG_PACKAGE_UID, -1) : getActivity().getIntent().getIntExtra(AppInfoBase.ARG_PACKAGE_UID, -1);
if (uid == -1) {
// TODO: Log error.
getActivity().finish();
} else {
addUid(uid);
mAppItem = new AppItem(uid);
mAppItem.addUid(uid);
}
} else {
for (int i = 0; i < mAppItem.uids.size(); i++) {
addUid(mAppItem.uids.keyAt(i));
}
}
addPreferencesFromResource(R.xml.app_data_usage);
mTotalUsage = findPreference(KEY_TOTAL_USAGE);
mForegroundUsage = findPreference(KEY_FOREGROUND_USAGE);
mBackgroundUsage = findPreference(KEY_BACKGROUND_USAGE);
mCycle = (SpinnerPreference) findPreference(KEY_CYCLE);
mCycleAdapter = new CycleAdapter(getContext(), mCycle, mCycleListener, false);
if (mAppItem.key > 0) {
if (mPackages.size() != 0) {
PackageManager pm = getPackageManager();
try {
ApplicationInfo info = pm.getApplicationInfo(mPackages.valueAt(0), 0);
mIcon = info.loadIcon(pm);
mLabel = info.loadLabel(pm);
mPackageName = info.packageName;
} catch (PackageManager.NameNotFoundException e) {
}
}
if (!UserHandle.isApp(mAppItem.key)) {
removePreference(KEY_UNRESTRICTED_DATA);
removePreference(KEY_RESTRICT_BACKGROUND);
removePreference(KEY_RESTRICT_ALL_DATA);
removePreference(KEY_RESTRICT_ALL_WIFI);
} else {
mRestrictBackground = (SwitchPreference) findPreference(KEY_RESTRICT_BACKGROUND);
mRestrictBackground.setOnPreferenceChangeListener(this);
mUnrestrictedData = (SwitchPreference) findPreference(KEY_UNRESTRICTED_DATA);
mUnrestrictedData.setOnPreferenceChangeListener(this);
mRestrictAllData = (SwitchPreference) findPreference(KEY_RESTRICT_ALL_DATA);
mRestrictAllData.setOnPreferenceChangeListener(this);
mRestrictAllWifi = (SwitchPreference) findPreference(KEY_RESTRICT_ALL_WIFI);
mRestrictAllWifi.setOnPreferenceChangeListener(this);
}
mDataSaverBackend = new DataSaverBackend(getContext());
mAppSettings = findPreference(KEY_APP_SETTINGS);
mAppSettingsIntent = new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE);
mAppSettingsIntent.addCategory(Intent.CATEGORY_DEFAULT);
PackageManager pm = getPackageManager();
boolean matchFound = false;
for (String packageName : mPackages) {
mAppSettingsIntent.setPackage(packageName);
if (pm.resolveActivity(mAppSettingsIntent, 0) != null) {
matchFound = true;
break;
}
}
if (!matchFound) {
removePreference(KEY_APP_SETTINGS);
mAppSettings = null;
}
if (mPackages.size() > 1) {
mAppList = (PreferenceCategory) findPreference(KEY_APP_LIST);
final int packageSize = mPackages.size();
final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(packageSize);
final ThreadPoolExecutor executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_SECONDS, TimeUnit.SECONDS, workQueue);
for (int i = 1; i < mPackages.size(); i++) {
final AppPrefLoader loader = new AppPrefLoader();
loader.executeOnExecutor(executor, mPackages.valueAt(i));
}
} else {
removePreference(KEY_APP_LIST);
}
} else {
final Context context = getActivity();
UidDetail uidDetail = new UidDetailProvider(context).getUidDetail(mAppItem.key, true);
mIcon = uidDetail.icon;
mLabel = uidDetail.label;
mPackageName = context.getPackageName();
removePreference(KEY_UNRESTRICTED_DATA);
removePreference(KEY_APP_SETTINGS);
removePreference(KEY_RESTRICT_BACKGROUND);
removePreference(KEY_APP_LIST);
removePreference(KEY_RESTRICT_ALL_DATA);
removePreference(KEY_RESTRICT_ALL_WIFI);
}
}
use of com.android.settingslib.AppItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageList method accumulate.
/**
* Accumulate data usage of a network stats entry for the item mapped by the collapse key.
* Creates the item if needed.
* @param collapseKey the collapse key used to map the item.
* @param knownItems collection of known (already existing) items.
* @param entry the network stats entry to extract data usage from.
* @param itemCategory the item is categorized on the list view by this category. Must be
*/
private static long accumulate(int collapseKey, final SparseArray<AppItem> knownItems, NetworkStats.Entry entry, int itemCategory, ArrayList<AppItem> items, long largest) {
final int uid = entry.uid;
AppItem item = knownItems.get(collapseKey);
if (item == null) {
item = new AppItem(collapseKey);
item.category = itemCategory;
items.add(item);
knownItems.put(item.key, item);
}
item.addUid(uid);
item.total += entry.rxBytes + entry.txBytes;
return Math.max(largest, item.total);
}
Aggregations