use of android.net.NetworkTemplate in project android_frameworks_base by DirtyUnicorns.
the class NetworkPolicyManagerShellCommand method newPolicy.
private NetworkPolicy newPolicy(String ssid) {
final NetworkTemplate template = NetworkTemplate.buildTemplateWifi(ssid);
final NetworkPolicy policy = newWifiPolicy(template, false);
return policy;
}
use of android.net.NetworkTemplate in project android_frameworks_base by DirtyUnicorns.
the class DataUsageController method getDataUsageInfo.
public DataUsageInfo getDataUsageInfo() {
final String subscriberId = getActiveSubscriberId(mContext);
if (subscriberId == null) {
return warn("no subscriber id");
}
NetworkTemplate template = NetworkTemplate.buildTemplateMobileAll(subscriberId);
template = NetworkTemplate.normalize(template, mTelephonyManager.getMergedSubscriberIds());
return getDataUsageInfo(template);
}
use of android.net.NetworkTemplate 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 android.net.NetworkTemplate in project android_frameworks_base by DirtyUnicorns.
the class NetworkStatsManager method querySummaryForDevice.
/**
* Query network usage statistics summaries. Result is summarised data usage for the whole
* device. Result is a single Bucket aggregated over time, state, uid, tag and roaming. This
* means the bucket's start and end timestamp are going to be the same as the 'startTime' and
* 'endTime' parameters. State is going to be {@link NetworkStats.Bucket#STATE_ALL}, uid
* {@link NetworkStats.Bucket#UID_ALL}, tag {@link NetworkStats.Bucket#TAG_NONE}
* and roaming {@link NetworkStats.Bucket#ROAMING_ALL}.
*
* @param networkType As defined in {@link ConnectivityManager}, e.g.
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
* etc.
* @param subscriberId If applicable, the subscriber id of the network interface.
* @param startTime Start of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @return Bucket object or null if permissions are insufficient or error happened during
* statistics collection.
*/
public Bucket querySummaryForDevice(int networkType, String subscriberId, long startTime, long endTime) throws SecurityException, RemoteException {
NetworkTemplate template;
try {
template = createTemplate(networkType, subscriberId);
} catch (IllegalArgumentException e) {
if (DBG)
Log.e(TAG, "Cannot create template", e);
return null;
}
Bucket bucket = null;
NetworkStats stats = new NetworkStats(mContext, template, startTime, endTime);
bucket = stats.getDeviceSummaryForNetwork();
stats.close();
return bucket;
}
use of android.net.NetworkTemplate in project android_frameworks_base by DirtyUnicorns.
the class NetworkStatsManager method querySummaryForUser.
/**
* Query network usage statistics summaries. Result is summarised data usage for all uids
* belonging to calling user. Result is a single Bucket aggregated over time, state and uid.
* This means the bucket's start and end timestamp are going to be the same as the 'startTime'
* and 'endTime' parameters, state is going to be {@link NetworkStats.Bucket#STATE_ALL} and uid
* {@link NetworkStats.Bucket#UID_ALL}.
*
* @param networkType As defined in {@link ConnectivityManager}, e.g.
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
* etc.
* @param subscriberId If applicable, the subscriber id of the network interface.
* @param startTime Start of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @return Bucket object or null if permissions are insufficient or error happened during
* statistics collection.
*/
public Bucket querySummaryForUser(int networkType, String subscriberId, long startTime, long endTime) throws SecurityException, RemoteException {
NetworkTemplate template;
try {
template = createTemplate(networkType, subscriberId);
} catch (IllegalArgumentException e) {
if (DBG)
Log.e(TAG, "Cannot create template", e);
return null;
}
NetworkStats stats;
stats = new NetworkStats(mContext, template, startTime, endTime);
stats.startSummaryEnumeration();
stats.close();
return stats.getSummaryAggregate();
}
Aggregations