All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.com.android.clockwork.common.DebugAssert Maven / Gradle / Ivy

Go to download

A library jar that provides APIs for Applications written for the Google Android Platform.

There is a newer version: 15-robolectric-12650502
Show newest version
package com.android.clockwork.common;

import android.os.Build;
import android.os.Looper;

/**
 * A class that throws if an assertion fails. These assertions are compiled away in user builds
 * similar to C assertions.
 */
public class DebugAssert {
    private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);

    // Do not instantiate.
    private DebugAssert() {}

    /**
     * Asserts that execution control is on the main thread.
     */
    public static void isMainThread() {
        if (!IS_USER_BUILD && Looper.getMainLooper().getThread() != Thread.currentThread()) {
            throw new AssertionError("This function should be called from the main thread.");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy