Example usage for android.util Log v

List of usage examples for android.util Log v

Introduction

In this page you can find the example usage for android.util Log v.

Prototype

public static int v(String tag, String msg) 

Source Link

Document

Send a #VERBOSE log message.

Usage

From source file:Main.java

/**
 * Return a String List representing response from invokeOemRilRequestRaw
 *
 * @param aob Byte array response from invokeOemRilRequestRaw
 *//*from  ww  w  .ja va2  s  .co m*/
public static List<String> unpackByteListOfStrings(byte aob[]) {

    if (aob.length == 0) {
        Log.v(TAG, "Length = 0");
        return Collections.emptyList();
    }

    int lines = aob.length / CHARS_PER_LINE;

    String[] display = new String[lines];
    for (int i = 0; i < lines; i++) {
        int offset, byteCount;
        offset = i * CHARS_PER_LINE + 2;
        byteCount = 0;

        if (offset + byteCount >= aob.length) {
            Log.e(TAG, "Unexpected EOF");
            break;
        }

        while (aob[offset + byteCount] != 0 && (byteCount < CHARS_PER_LINE)) {
            byteCount += 1;
            if (offset + byteCount >= aob.length) {
                Log.e(TAG, "Unexpected EOF");
                break;
            }
        }
        display[i] = new String(aob, offset, byteCount).trim();
    }

    int newLength = display.length;
    while (newLength > 0 && TextUtils.isEmpty(display[newLength - 1])) {
        newLength -= 1;
    }

    return Arrays.asList(Arrays.copyOf(display, newLength));
}

From source file:edu.umich.oasis.testapp.TestSoda.java

public static void nop(boolean addTaint) {
    if (addTaint) {
        TaintSet.Builder ts = new TaintSet.Builder();
        ts.addTaint("edu.umich.oasis.testapp/test");
        Log.v(TAG, "Tainting");
        ((IDynamicAPI) (OASISContext.getInstance().getTrustedAPI("taint"))).invoke("addTaint", ts.build());
    }//from w  ww.  j  a v a2 s .com
}

From source file:Main.java

/**
 * Links a vertex shader and a fragment shader together into an OpenGL
 * program. Returns the OpenGL program object ID, or 0 if linking failed.
 *///from  w w  w .  ja  v a  2  s .  co  m
public static int linkProgram(int vertexShaderId, int fragmentShaderId) {

    // Create a new program object.
    final int programObjectId = glCreateProgram();

    if (programObjectId == 0) {
        if (IS_LOGGING_ON) {
            Log.w(TAG, "Could not create new program");
        }

        return 0;
    }

    // Attach the vertex shader to the program.
    glAttachShader(programObjectId, vertexShaderId);

    // Attach the fragment shader to the program.
    glAttachShader(programObjectId, fragmentShaderId);

    // Link the two shaders together into a program.
    glLinkProgram(programObjectId);

    // Get the link status.
    final int[] linkStatus = new int[1];
    glGetProgramiv(programObjectId, GL_LINK_STATUS, linkStatus, 0);

    if (IS_LOGGING_ON) {
        // Print the program info log to the Android log output.
        Log.v(TAG, "Results of linking program:\n" + glGetProgramInfoLog(programObjectId));
    }

    // Verify the link status.
    if (linkStatus[0] == 0) {
        // If it failed, delete the program object.
        glDeleteProgram(programObjectId);

        if (IS_LOGGING_ON) {
            Log.w(TAG, "Linking of program failed.");
        }

        return 0;
    }

    // Return the program object ID.
    return programObjectId;
}

From source file:fr.kwiatkowski.ApkTrack.UpdateSource.java

/**
 * Reads the update sources from the JSON asset file.
 * @param ctx The context of the application.
 * @return A list of available update sources.
 *///from w w w  .j  a v a 2  s . co  m
public static ArrayList<UpdateSource> getUpdateSources(Context ctx) {
    if (_SOURCES != null) {
        return _SOURCES;
    }

    _SOURCES = new ArrayList<UpdateSource>();
    Log.v(MainActivity.TAG, "Reading update sources...");
    try {
        InputStream is = ctx.getAssets().open("sources.json");

        StringBuilder buffer = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        String s;
        while ((s = br.readLine()) != null) {
            buffer.append(s);
        }

        JSONArray sources = new JSONArray(buffer.toString());
        for (int i = 0; i < sources.length(); ++i) {
            String name = sources.getJSONObject(i).getString("name");
            Log.v(MainActivity.TAG, "Reading " + name);
            String version_check_url = sources.getJSONObject(i).getString("version_check_url");
            String version_check_regexp = sources.getJSONObject(i).getString("version_check_regexp");
            String download_url = sources.getJSONObject(i).optString("download_url", null);
            String applicable_packages = sources.getJSONObject(i).optString("applicable_packages", ".*");
            _SOURCES.add(new UpdateSource(name, version_check_url, version_check_regexp, download_url,
                    applicable_packages));
        }
    } catch (IOException e) {
        Log.v(MainActivity.TAG, "Could not open sources.json!", e);
    } catch (JSONException e) {
        Log.v(MainActivity.TAG, "sources.json seems to be malformed!", e);
    }

    return _SOURCES;
}

From source file:Main.java

static final void v(String mesg) {
    if (DEBUG) {
        Log.v(LOG_TAG, mesg);
    }
}

From source file:com.android.volley.VolleyLog.java

public static void v(String format, Object... args) {
    if (DEBUG) {
        Log.v(TAG, buildMessage(format, args));
    }
}

From source file:com.amazon.android.navigator.NavigatorModelParser.java

/**
 * Parses the Navigator JSON file into a {@link NavigatorModel} object. The JSON file is
 * defined//w w w  .j a  v a  2 s  . c  o m
 * by the {@link Navigator#NAVIGATOR_FILE} string.
 *
 * @param context The context.
 * @return A NavigatorModel object.
 */
public static NavigatorModel parse(Context context, String navigatorFile) {

    NavigatorModel navigatorModel = null;

    try {
        ObjectMapper objectMapper = new ObjectMapper();
        String navigatorFileString = FileHelper.readFile(context, navigatorFile);
        navigatorModel = objectMapper.readValue(navigatorFileString, NavigatorModel.class);

        Log.v(TAG, "Navigator Model: " + navigatorModel.toString());

        // Preload recipes
        for (NavigatorModel.GlobalRecipes globalRecipes : navigatorModel.getGlobalRecipes()) {

            // Load category recipes if there is no hard coded name defined.
            if (globalRecipes.getCategories() != null && globalRecipes.getCategories().name == null) {

                globalRecipes.getCategories().dataLoaderRecipe = Recipe.newInstance(context,
                        globalRecipes.getCategories().dataLoader);

                globalRecipes.getCategories().dynamicParserRecipe = Recipe.newInstance(context,
                        globalRecipes.getCategories().dynamicParser);
            }

            if (globalRecipes.getContents() != null) {
                globalRecipes.getContents().dataLoaderRecipe = Recipe.newInstance(context,
                        globalRecipes.getContents().dataLoader);

                globalRecipes.getContents().dynamicParserRecipe = Recipe.newInstance(context,
                        globalRecipes.getContents().dynamicParser);
            }
        }
        // Preload Recommendation recipes
        if (navigatorModel.getRecommendationRecipes() != null) {
            for (NavigatorModel.RecommendationRecipes recommendationRecipes : navigatorModel
                    .getRecommendationRecipes()) {

                if (recommendationRecipes.getContents() != null) {
                    recommendationRecipes.getContents().dataLoaderRecipe = Recipe.newInstance(context,
                            recommendationRecipes.getContents().dataLoader);

                    recommendationRecipes.getContents().dynamicParserRecipe = Recipe.newInstance(context,
                            recommendationRecipes.getContents().dynamicParser);

                }
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Navigator parsing failed!!! ", e);
    }
    return navigatorModel;
}

From source file:Main.java

/**
 * Logs provided logText in provided tag at given logLevel (like, android.util.Log.DEBUG)
 * @param logLevel int VERBOSE, DEBUG, INFO, WARN, ERROR
 * @param tag String//from  w  w w  .ja v  a2s .  com
 * @param logText String
 */
public static void log(int logLevel, String tag, String logText) {
    switch (logLevel) {
    case Log.VERBOSE:
        Log.v(tag, logText);
        break;

    case Log.DEBUG:
        Log.d(tag, logText);
        break;

    case Log.INFO:
        Log.i(tag, logText);
        break;

    case Log.WARN:
        Log.w(tag, logText);
        break;

    case Log.ERROR:
        Log.e(tag, logText);
        break;
    }
}

From source file:Main.java

@SuppressLint("NewApi")
public static void onTrimMemory(int level) {
    int count = 0;
    if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
        count = 10;//from  w w  w  . j a va 2  s  .  c  om
        if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) {
            count = 0;
        }
    } else
        return;

    int size = 0;
    if (count > 0) {
        for (Bitmap b : placeHolders) {
            size += b.getByteCount();
        }
    }

    int trimSize = placeHolders.size() == 0 ? 0 : ((count * size) / placeHolders.size());
    Log.v(TAG, "trim image cache from " + memCache.size() + " to " + trimSize
            + " to reduce memory usage, max size " + memCache.maxSize());
    memCache.trimToSize(trimSize);
}

From source file:Main.java

public static byte[] makeFontBitmap(String font, String code, int size, float[] arrayOfPos) {
    Canvas c = new Canvas();
    Paint p = new Paint();
    float density = context.getResources().getDisplayMetrics().density;
    //        Log.v(TAG, String.format("makeFontBitmap called(Java): font=%s code=%s density=%f", font, code, density));
    p.setTextSize((float) size * density);
    p.setAntiAlias(true);/*from   ww  w.j  a v a2s  .com*/

    Rect textBounds = new Rect();
    p.getTextBounds(code, 0, code.length(), textBounds);
    //        Log.v(TAG, String.format("makeFontBitmap textBounds: %d,%d,%d,%d", textBounds.left, textBounds.top, textBounds.right, textBounds.bottom));

    Rect textBoundsAxA = new Rect();
    String axa = String.format("A%sA", code);
    p.getTextBounds(axa, 0, axa.length(), textBoundsAxA);
    Rect textBoundsAA = new Rect();
    String aa = "AA";
    p.getTextBounds(aa, 0, aa.length(), textBoundsAA);

    // cache.distDelta = Vec2(0, 0);
    arrayOfPos[0] = textBounds.left;
    arrayOfPos[1] = textBounds.top;

    // cache.srcWidth = Vec2(16, 16);
    arrayOfPos[2] = textBounds.width();
    arrayOfPos[3] = textBounds.height();

    // cache.step = 16;
    //      arrayOfPos[4] = textBounds.width() + 1;
    arrayOfPos[4] = textBoundsAxA.width() - textBoundsAA.width();

    if (textBounds.width() == 0 || textBounds.height() == 0) {
        Log.v(TAG, "makeFontBitmap: empty");
        return null;
    }

    Bitmap b = Bitmap.createBitmap(textBounds.width(), textBounds.height(), Bitmap.Config.ARGB_8888);
    c.setBitmap(b);

    Rect r = new Rect(0, 0, textBounds.width(), textBounds.height());
    //      p.setColor(Color.RED);
    p.setARGB(0, 0, 0, 0);
    c.drawRect(r, p);
    p.setARGB(255, 255, 255, 255);

    //        Log.v(TAG, "makeFontBitmap: drawText");
    c.drawText(code, -textBounds.left, -textBounds.top, p);
    //        Log.v(TAG, String.format("makeFontBitmap: w=%.2f h=%.2f", arrayOfPos[2], arrayOfPos[3]));

    ByteBuffer buf = ByteBuffer.allocate(textBounds.width() * textBounds.height() * 4);
    //        Log.v(TAG, String.format("makeFontBitmap: b.getRowBytes() %d", b.getRowBytes()));
    buf.position(0);
    b.copyPixelsToBuffer(buf);
    //        Log.v(TAG, String.format("makeFontBitmap results: capacity=%d", buf.capacity()));

    return buf.array();
}