下面列出了android.util.Log#wtf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, intent.toString());
if (!mIsAwaitingBroadcast.get())
return;
String installedPackage;
try {
installedPackage = intent.getDataString().replace("package:", "");
String installerPackage = getContext().getPackageManager().getInstallerPackageName(installedPackage);
Log.d(TAG, "installerPackage=" + installerPackage);
if (!BuildConfig.APPLICATION_ID.equals(installerPackage))
return;
} catch (Exception e) {
Log.wtf(TAG, e);
return;
}
mIsAwaitingBroadcast.set(false);
dispatchCurrentSessionUpdate(InstallationStatus.INSTALLATION_SUCCEED, installedPackage);
installationCompleted();
}
private void writeEvent(long eventTimeMs, int eventType, NotificationRecord r) {
ContentValues cv = new ContentValues();
cv.put(COL_EVENT_USER_ID, r.sbn.getUser().getIdentifier());
cv.put(COL_EVENT_TIME, eventTimeMs);
cv.put(COL_EVENT_TYPE, eventType);
putNotificationIdentifiers(r, cv);
if (eventType == EVENT_TYPE_POST) {
putNotificationDetails(r, cv);
} else {
putPosttimeVisibility(r, cv);
}
SQLiteDatabase db = mHelper.getWritableDatabase();
if (db.insert(TAB_LOG, null, cv) < 0) {
Log.wtf(TAG, "Error while trying to insert values: " + cv);
}
sNumWrites++;
pruneIfNecessary(db);
}
private void setSurfaceFlingerTranslate(int x, int y)
{
try
{
if (flinger == null) flinger = ServiceManager.getService("SurfaceFlinger");
if (flinger == null)
{
Log.wtf(TAG, "SurfaceFlinger is null");
return;
}
Parcel data = Parcel.obtain();
data.writeInterfaceToken("android.ui.ISurfaceComposer");
data.writeInt(x);
data.writeInt(y);
flinger.transact(2020, data, null, 0);
data.recycle();
}
catch(Exception e)
{
Log.e(TAG, "SurfaceFlinger error", e);
}
}
public static void wtf(String message, Object... args) {
if(sLogEnable) {
CL.TagInfo tagInfo = getMethodNames((new Throwable()).getStackTrace());
String msg = createLogWithoutFileName(tagInfo, message, args);
Log.wtf(tagInfo.fileName, msg);
}
}
/**
* 最终打印日志方法 ( 全部调用此方法 )
* @param logType 日志类型
* @param tag 打印 Tag
* @param message 日志信息
*/
private static void printLog(final int logType, final String tag, final String message) {
// 防止 null 处理
if (message == null) return;
// 获取日志类型
switch (logType) {
case Log.ERROR:
Log.e(tag, message);
break;
case Log.INFO:
Log.i(tag, message);
break;
case Log.VERBOSE:
Log.v(tag, message);
break;
case Log.WARN:
Log.w(tag, message);
break;
case Log.ASSERT:
Log.wtf(tag, message);
break;
case Log.DEBUG:
Log.d(tag, message);
break;
default:
Log.d(tag, message);
break;
}
}
@Override
public void run() {
final byte[] temp = new byte[8192];
try {
while (read(mServer, temp, 0, MSG_LENGTH) == MSG_LENGTH) {
final int cmd = FileUtils.peekInt(temp, 0, ByteOrder.BIG_ENDIAN);
if (cmd == CMD_WRITE) {
// Shuttle data into local file
int len = FileUtils.peekInt(temp, 4, ByteOrder.BIG_ENDIAN);
while (len > 0) {
int n = read(mServer, temp, 0, Math.min(temp.length, len));
if (n == -1) {
throw new IOException(
"Unexpected EOF; still expected " + len + " bytes");
}
write(mTarget, temp, 0, n);
len -= n;
}
} else if (cmd == CMD_FSYNC) {
// Sync and echo back to confirm
Os.fsync(mTarget);
write(mServer, temp, 0, MSG_LENGTH);
} else if (cmd == CMD_CLOSE) {
// Close and echo back to confirm
Os.fsync(mTarget);
Os.close(mTarget);
mClosed = true;
write(mServer, temp, 0, MSG_LENGTH);
break;
}
}
} catch (ErrnoException | IOException e) {
Log.wtf(TAG, "Failed during bridge", e);
} finally {
forceClose();
}
}
@Override
@BinderThread
public void start(Bundle invocationData, IJobCallback callback) {
JobInvocation.Builder invocation = getJobCoder().decode(invocationData);
if (invocation == null) {
Log.wtf(TAG, "start: unknown invocation provided");
return;
}
JobService.this.handleStartJobRequest(invocation.build(), callback);
}
public static synchronized MediaPlayer playSoundUri(String soundUri) {
try {
JoH.getWakeLock("joh-playsound", 10000);
final MediaPlayer player = MediaPlayer.create(xdrip.getAppContext(), Uri.parse(soundUri));
player.setLooping(false);
player.start();
return player;
} catch (Exception e) {
Log.wtf(TAG, "Failed to play audio: " + soundUri + " exception:" + e);
return null;
}
}
public ShareRest(Context context, OkHttpClient okHttpClient) {
try {
OkHttpClient httpClient = okHttpClient != null ? okHttpClient : getOkHttpClient();
if (httpClient == null) httpClient = getOkHttpClient(); // try again on failure
// if fails second time we've got big problems
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(sharedPreferences.getBoolean("dex_share_us_acct", true) ? US_SHARE_BASE_URL : NON_US_SHARE_BASE_URL)
.client(httpClient)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
dexcomShareApi = retrofit.create(DexcomShare.class);
sessionId = sharedPreferences.getString("dexcom_share_session_id", null);
username = sharedPreferences.getString("dexcom_account_name", null);
password = sharedPreferences.getString("dexcom_account_password", null);
serialNumber = sharedPreferences.getString("share_key", null);
if (sharedPreferences.getBoolean("engineering_mode", false)) {
final String share_test_key = sharedPreferences.getString("share_test_key", "").trim();
if (share_test_key.length() > 4) serialNumber = share_test_key;
}
sharedPreferences.registerOnSharedPreferenceChangeListener(preferenceChangeListener);
if ("".equals(sessionId)) // migrate previous empty sessionIds to null;
sessionId = null;
} catch (IllegalStateException e) {
Log.wtf(TAG, "Illegal state exception: " + e);
}
}
/**
* Extracts the archive.
* @param args the void args (unused)
* @return true if successful.
* @see ArchiveUtil#doExtractArchive(String, FMFile)
*/
@Override
protected Boolean doInBackground(final Void... args) {
try {
return new ArchiveUtil().doExtractArchive(destinationPath, archive);
} catch (BlockingStuffOnMainThreadException e) {
Log.wtf(TAG, "This should not happen here!", e);
return false;
}
}
public static void wtf(String tag, String msg) {
if (BuildConfig.DEBUG) {
Log.wtf(tag, msg);
}
}
public static void wtf(String content, Throwable tr) {
if (!isDebug) return;
String tag = generateTag();
Log.wtf(tag, content, tr);
}
public static void wtf(Throwable tr, String format, Object... args) {
Log.wtf(TAG, buildMessage(format, args), tr);
}
public void wtf(String tag, Throwable tr) {
Log.wtf(tag, tr);
if (level < W) {
PrintLogger.getInstance(context.get()).Log(tag, getStackTraceString("", tr));
}
}
int wtf(String tag, Throwable tr) {
if (enableLogging && logLevel <= Log.ASSERT) return Log.wtf(tag, tr);
return 0;
}
public static void wtf(String format, Object... args) {
Log.wtf(TAG, buildMessage(format, args));
}
int wtf(String tag, String msg) {
if (enableLogging && logLevel <= Log.ASSERT) return Log.wtf(tag, msg);
return 0;
}
public static void wtf(String TAG, String message) {
if (mDebug) {
Log.wtf(TAG, message);
}
}
public static void wtf(String tag, String text) {
if (BuildConfig.DEBUG)
Log.wtf(tag, text);
}
/**
* Send a FATAL ERROR log message
*
* @param tag
* @param msg
* @param throwable
*/
public static void f(String tag, String msg, Throwable throwable) {
if (sLevel > LEVEL_FATAL) {
return;
}
Log.wtf(tag, msg, throwable);
}