Log data transfer statistics to the Android log.

@param tag the Android log tag to use.
@param startTime the starting time for the stats calculation in
nanoseconds.
@param bytesReceived the number of bytes received over the given period
of time
438144
public static void logTransferStats(final String tag,
            final long startTime, final double bytesReceived) {
        double kilobytesTransferred = bytesReceived / 1024.0;
        long elapsedTime = TimeUnit.SECONDS.convert(
            System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
        Log.i(tag, "Transferred " + kilobytesTransferred + " KB in the last "
            + elapsedTime + " seconds at an average of " +
            kilobytesTransferred / elapsedTime + " KB/s");
    }
93414
public static int w(String tag, String msg) {
        collectLogEntry(Constants.WARN, tag, msg, null);
        if (isLoggable(tag, Constants.WARN)) {
            return android.util.Log.w(tag, msg);
        }
        return 0;
    }
680988
public void writeTag(int tagClass, boolean primitive, int tag) throws AsnException {
		
		if (tag < 0)
			throw new AsnException("Tag must not be negative");

		if (tag <= 30) {
			
			int toEncode = (tagClass & 0x03) << 6;
			toEncode |= (primitive ? 0 : 1) << 5;
			toEncode |= tag & 0x1F;
			this.write(toEncode);
		} else {
			
			int toEncode = (tagClass & 0x03) << 6;
			toEncode |= (primitive ? 0 : 1) << 5;
			toEncode |= 0x1F;
			this.write(toEncode);

			int byteArr = 8;
			byte[] buf = new byte[byteArr];
			int pos = byteArr;
			while (true) {
				int dd;
				if (tag <= 0x7F) {
					dd = tag;
					if (pos != byteArr)
						dd = dd | 0x80;
					buf[--pos] = (byte) dd;
					break;
				} else {
					dd = (tag & 0x7F);
					tag >>= 7;
					if (pos != byteArr)
						dd = dd | 0x80;
					buf[--pos] = (byte) dd;
				}
			}
			this.write(buf, pos, byteArr - pos);
		}
	}
738726
@InterfaceAudience.Public
    public void start() {

        if (runningState.get() == true) {
            Log.v(Log.TAG_QUERY, "%s: start() called, but runningState is already true.  Ignoring.", this);
            return;
        } else {
            Log.d(Log.TAG_QUERY, "%s: start() called", this);
            runningState.set(true);
        }

        if (!observing) {
            observing = true;
            getDatabase().addChangeListener(this);
            Log.v(Log.TAG_QUERY, "%s: start() is calling update()", this);
            update();
        }
    }
1017393
public static int d(String tag, String msg) {
        collectLogEntry(Constants.DEBUG, tag, msg, null);
        if (isLoggable(tag, Constants.DEBUG)) {
            return android.util.Log.d(tag, msg);
        }
        return 0;
    }
274507
public void onReceive(NotificationRemote remote, NotificationEntry entry,
                          Intent intent, String intentAction) {
        if (DBG) Log.d(TAG, "onReceive - " + entry.ID + ", " + intentAction);
    }
569440
public static void setTag(String tag) {
        d("Changing log tag to %s", tag);
        TAG = tag;

        // Reinitialize the DEBUG "constant"
        DEBUG = Log.isLoggable(TAG, Log.VERBOSE);
    }
17604
public static void i(String tag, String msg) {
        if (logger != null && isLoggingEnabled(tag, INFO)) {
            logger.i(tag, msg);
        }
    }
355866
public static void setLogTag(final String logTag) {
        Logger.logTag = TextUtils.isEmpty(logTag) ? LOG_TAG : logTag;
    }
1174196
void logInfo(String tag, String msg) {
        log(Log.INFO, tag, msg);
    }
508179
public static int w(String tag, Throwable tr) {
        collectLogEntry(Constants.WARN, tag, "", null);
        if (isLoggable(tag, Constants.WARN)) {
            return android.util.Log.w(tag, tr);
        }
        return 0;
    }
66289
@Override
    public ITag readTag() {
        //log.debug("Read tag");
        ITag tag = null;
        try {
            lock.acquire();
            //empty-out the pre-streaming tags first
            if (!firstTags.isEmpty()) {
                log.debug("Returning pre-tag");
                // Return first tags before media data
                return firstTags.removeFirst();
            }
            //log.debug("Read tag - sample {} prevFrameSize {} audio: {} video: {}", new Object[]{currentSample, prevFrameSize, audioCount, videoCount});

            //get the current frame
            MP4Frame frame = frames.get(currentFrame);
            log.debug("Playback {}", frame);

            int sampleSize = frame.getSize();

            int time = (int) Math.round(frame.getTime() * 1000.0);
            //log.debug("Read tag - dst: {} base: {} time: {}", new Object[]{frameTs, baseTs, time});

            long samplePos = frame.getOffset();
            //log.debug("Read tag - samplePos {}", samplePos);

            //determine frame type and packet body padding
            byte type = frame.getType();

            //create a byte buffer of the size of the sample
            ByteBuffer data = ByteBuffer.allocate(sampleSize + 2);
            try {
                //log.debug("Writing audio prefix");
                data.put(MP4Reader.PREFIX_AUDIO_FRAME);
                //do we need to add the mdat offset to the sample position?
                dataSource.position(samplePos);
                dataSource.read(data);
            } catch (IOException e) {
                log.error("Error on channel position / read", e);
            }

            //chunk the data
            IoBuffer payload = IoBuffer.wrap(data.array());

            //create the tag
            tag = new Tag(type, time, payload.limit(), payload, prevFrameSize);
            //log.debug("Read tag - type: {} body size: {}", (type == TYPE_AUDIO ? "Audio" : "Video"), tag.getBodySize());

            //increment the sample number
            currentFrame++;
            //set the frame / tag size
            prevFrameSize = tag.getBodySize();
        } catch (InterruptedException e) {
            log.warn("Exception acquiring lock", e);
        } finally {
            lock.release();
        }
        //log.debug("Tag: {}", tag);
        return tag;
    }
1234295
public void reuse(Tag tag) {
	tag.release();
	Queue<Tag> queue = getQueue(tag.getClass().getName());
	queue.add(tag);
    }
1238218
public static void e(String tag, String msg) {
    if (logEnabled) {
      Log.e(tag, msg);
    }
  }
256730
public static long current(Context context, String tag) {
        Long appRxValue = sReceivedBytes.get(tag);
        Long appTxValue = sSendBytes.get(tag);
        if (appRxValue == null || appTxValue == null) {
            if (DEBUG) {
                LogUtils.w(TAG, "current() appRxValue or appTxValue is null.");
            }
            return 0;
        }
        final int uid = getUid(context);
        long appRxValue2 = TrafficStats.getUidRxBytes(uid);
        long appTxValue2 = TrafficStats.getUidTxBytes(uid);
        long rxValue = appRxValue2 - appRxValue;
        long txValue = appTxValue2 - appTxValue;
        if (DEBUG) {
            LogUtils.v(TAG, "current() rxValue=" + rxValue / 1000 + " txValue=" + txValue / 1000 + " uid=" + uid);
        }
        return rxValue;

    }
926558
public final void bytes(Class sourceClass, byte[] data, int start, int count)
    {
        bytes(null, sourceClass, data, start, count);
    }
339614
public synchronized void message(String tag,
                                     Object msg,
                                     Frame frame,
                                     long time)
    {
        if (!_initialized)
            defaultInit();
        
        boolean logged=false;
        if (_sinks!=null)
        {
            for (int s=_sinks.length;s-->0;)
            {
                if (_sinks[s]==null)
                    continue;
            
                if (_sinks[s].isStarted())
                {
                    logged=true;
                    _sinks[s].log(tag,msg,frame,time);
                }
            }		
        }

        if (!logged)
            System.err.println(time+": "+tag+":"+msg+" @ "+frame);
    }