下面列出了android.util.Log#w ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Remote client characteristic write request.
* @hide
*/
@Override
public void onCharacteristicWriteRequest(String address, int transId,
int offset, int length, boolean isPrep, boolean needRsp,
int handle, byte[] value) {
if (VDBG) Log.d(TAG, "onCharacteristicWriteRequest() - handle=" + handle);
BluetoothDevice device = mAdapter.getRemoteDevice(address);
BluetoothGattCharacteristic characteristic = getCharacteristicByHandle(handle);
if (characteristic == null) {
Log.w(TAG, "onCharacteristicWriteRequest() no char for handle " + handle);
return;
}
try {
mCallback.onCharacteristicWriteRequest(device, transId, characteristic,
isPrep, needRsp, offset, value);
} catch (Exception ex) {
Log.w(TAG, "Unhandled exception in callback", ex);
}
}
/**打印不同颜色日志*/
private static void logByType(String type, String tag, String content){
if(BuildConfig.DEBUG) {
switch (type){
case "i":
Log.i(tag, ""+(null==content?"":content));
break;
case "d":
Log.d(tag, ""+(null==content?"":content));
break;
case "v":
Log.v(tag, ""+(null==content?"":content));
break;
case "w":
Log.w(tag, ""+(null==content?"":content));
break;
case "e":
Log.e(tag, ""+(null==content?"":content));
break;
}
}
}
/**
* ディスクの空き容量をチェックして足りなければtrueを返す
* @return true: 空き容量が足りない
*/
@Override
protected boolean check() {
final Context context = requireContext();
final StorageInfo info;
try {
info = mOutputFile != null
? StorageUtils.getStorageInfo(context, mOutputFile) : null;
if ((info != null) && (info.totalBytes != 0)) {
return ((info.freeBytes/ (float)info.totalBytes) < FileUtils.FREE_RATIO)
|| (info.freeBytes < FileUtils.FREE_SIZE);
}
} catch (final IOException e) {
Log.w(TAG, e);
}
return (context == null)
|| ((mOutputFile == null)
&& !FileUtils.checkFreeSpace(context,
getConfig().maxDuration(), mStartTime, mSaveTreeId));
}
/**
* Receives hover events when touch exploration is turned on in SDK versions ICS and higher.
*
* @param event The hover event.
* @return {@code true} if the event is handled.
*/
public boolean onHoverEvent(final MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_ENTER:
onHoverEnter(event);
break;
case MotionEvent.ACTION_HOVER_MOVE:
onHoverMove(event);
break;
case MotionEvent.ACTION_HOVER_EXIT:
onHoverExit(event);
break;
default:
Log.w(getClass().getSimpleName(), "Unknown hover event: " + event);
break;
}
return true;
}
/**
* Implementation is provided by the parent class. Cannot be overriden.
*
* @see #getDocumentType(String)
*/
@Override
public final String getType(Uri uri) {
try {
switch (mMatcher.match(uri)) {
case MATCH_ROOT:
return DocumentsContract.Root.MIME_TYPE_ITEM;
case MATCH_DOCUMENT:
case MATCH_DOCUMENT_TREE:
enforceTree(uri);
return getDocumentType(getDocumentId(uri));
default:
return null;
}
} catch (FileNotFoundException e) {
Log.w(TAG, "Failed during getType", e);
return null;
}
}
public DateRecurrenceIterator createIterator(Date now) {
RRule rrule = createRRule();
try {
Log.d("RRULE", "Creating iterator for "+rrule.toIcal());
if (now.before(startDate.getTime())) {
now = startDate.getTime();
}
Calendar c = Calendar.getInstance();
c.setTime(startDate.getTime());
//c.set(Calendar.HOUR_OF_DAY, startDate.get(Calendar.HOUR_OF_DAY));
//c.set(Calendar.MINUTE, startDate.get(Calendar.MINUTE));
//c.set(Calendar.SECOND, startDate.get(Calendar.SECOND));
c.set(Calendar.MILLISECOND, 0);
return DateRecurrenceIterator.create(rrule, now, c.getTime());
} catch (ParseException e) {
Log.w("RRULE", "Unable to create iterator for "+rrule.toIcal());
return DateRecurrenceIterator.empty();
}
}
public synchronized void stop() {
stopped = true;
if (useAutoFocus) {
cancelOutstandingTask();
// Doesn't hurt to call this even if not focusing
try {
camera.cancelAutoFocus();
} catch (RuntimeException re) {
// Have heard RuntimeException reported in Android 4.0.x+;
// continue?
Log.w(TAG, "Unexpected exception while cancelling focusing", re);
}
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
Log.w("MessengerUtils", "client service disconnected:" + name);
mServer = null;
if (!bind()) {
Log.e("MessengerUtils", "client service rebind failed: " + name);
}
}
@Override
protected Bitmap doInBackground(Uri... params) {
if (isCancelled())
return null;
final Context context = mIconThumb.getContext();
final ContentResolver resolver = context.getContentResolver();
ContentProviderClient client = null;
Bitmap result = null;
try {
client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, mUri.getAuthority());
result = DocumentsContract.getDocumentThumbnail(resolver, mUri, mThumbSize, mSignal);
if (null == result){
result = ImageUtils.getThumbnail(mPath, mimeType, mThumbSize.x, mThumbSize.y);
}
if (result != null) {
final ThumbnailCache thumbs = DocumentsApplication.getThumbnailsCache(context, mThumbSize);
thumbs.put(mUri, result);
}
} catch (Exception e) {
if (!(e instanceof OperationCanceledException)) {
Log.w(TAG, "Failed to load thumbnail for " + mUri + ": " + e);
}
CrashReportingManager.logException(e);
} finally {
ContentProviderClientCompat.releaseQuietly(client);
}
return result;
}
private Bitmap loadArtwork(String url, boolean local) {
Bitmap bitmap = null;
try {
// If we are running the app in debug mode, the "local" image will be served from htt://localhost:8080, so we need to check for this case and load those images from URL
if(local && !url.startsWith("http")) {
// Gets the drawable from the RN's helper for local resources
ResourceDrawableIdHelper helper = ResourceDrawableIdHelper.getInstance();
Drawable image = helper.getResourceDrawable(getReactApplicationContext(), url);
if(image instanceof BitmapDrawable) {
bitmap = ((BitmapDrawable)image).getBitmap();
} else {
bitmap = BitmapFactory.decodeFile(url);
}
} else {
// Open connection to the URL and decodes the image
URLConnection con = new URL(url).openConnection();
con.connect();
InputStream input = con.getInputStream();
bitmap = BitmapFactory.decodeStream(input);
input.close();
}
} catch(IOException | IndexOutOfBoundsException ex) {
Log.w(TAG, "Could not load the artwork", ex);
}
return bitmap;
}
final void openURL(String url) {
// Strangely, some Android browsers don't seem to register to handle HTTP:// or HTTPS://.
// Lower-case these as it should always be OK to lower-case these schemes.
if (url.startsWith("HTTP://")) {
url = "http" + url.substring(4);
} else if (url.startsWith("HTTPS://")) {
url = "https" + url.substring(5);
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
try {
launchIntent(intent);
} catch (ActivityNotFoundException ignored) {
Log.w(TAG, "Nothing available to handle " + intent);
}
}
public byte[] encryptBytes(byte[] body) {
try {
Cipher cipher = getEncryptingCipher(masterSecret.getEncryptionKey());
Mac mac = getMac(masterSecret.getMacKey());
byte[] encryptedBody = getEncryptedBody(cipher, body);
byte[] encryptedAndMacBody = getMacBody(mac, encryptedBody);
return encryptedAndMacBody;
} catch (GeneralSecurityException ge) {
Log.w("bodycipher", ge);
return null;
}
}
@Override
public final Object doInBackground(Object... args) {
try {
retrieveSupplementalInfo();
} catch (IOException e) {
Log.w(TAG, e);
}
return null;
}
void doRetain() {
if (DEBUG) Log.v(TAG, "Retaining in " + this);
if (!mStarted) {
RuntimeException e = new RuntimeException("here");
e.fillInStackTrace();
Log.w(TAG, "Called doRetain when not started: " + this, e);
return;
}
mRetaining = true;
mStarted = false;
for (int i = mLoaders.size()-1; i >= 0; i--) {
mLoaders.valueAt(i).retain();
}
}
/**
* Set reading direction mode options for users. This method should be called before
* {@link #setDirection(Direction)} as it has higher preference.
*
* @param allowedDirection reading direction mode options for users. Setting to
* {@link AllowedDirection#VERTICAL_AND_HORIZONTAL} users will have
* choice to select the reading direction at runtime.
*/
public Config setAllowedDirection(AllowedDirection allowedDirection) {
this.allowedDirection = allowedDirection;
if (allowedDirection == null) {
this.allowedDirection = DEFAULT_ALLOWED_DIRECTION;
direction = DEFAULT_DIRECTION;
Log.w(LOG_TAG, "-> allowedDirection cannot be null, defaulting " +
"allowedDirection to " + DEFAULT_ALLOWED_DIRECTION + " and direction to " +
DEFAULT_DIRECTION);
} else if (allowedDirection == AllowedDirection.ONLY_VERTICAL &&
direction != Direction.VERTICAL) {
direction = Direction.VERTICAL;
Log.w(LOG_TAG, "-> allowedDirection is " + allowedDirection +
", defaulting direction to " + direction);
} else if (allowedDirection == AllowedDirection.ONLY_HORIZONTAL &&
direction != Direction.HORIZONTAL) {
direction = Direction.HORIZONTAL;
Log.w(LOG_TAG, "-> allowedDirection is " + allowedDirection
+ ", defaulting direction to " + direction);
}
return this;
}
/**
* The amount of time, in milliseconds, to delay starting the animation after
* {@link #start()} is called. Note that the start delay should always be non-negative. Any
* negative start delay will be clamped to 0 on N and above.
*
* @param startDelay The amount of the delay, in milliseconds
*/
@Override
public void setStartDelay(long startDelay) {
// Clamp start delay to non-negative range.
if (startDelay < 0) {
Log.w(TAG, "Start delay should always be non-negative");
startDelay = 0;
}
mStartDelay = startDelay;
}
public void writeCharacteristic(BluetoothGattCharacteristic characteristic) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.writeCharacteristic(characteristic);
}
public static void w(Throwable tr) {
if (mDebuggable >= LEVEL_WARN) {
Log.w(mTag, "", tr);
}
}
private static void install(ClassLoader loader,
List<? extends File> additionalClassPathEntries,
File optimizedDirectory)
throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, InvocationTargetException, NoSuchMethodException {
/* The patched class loader is expected to be a descendant of
* dalvik.system.BaseDexClassLoader. We modify its
* dalvik.system.DexPathList pathList field to append additional DEX
* file entries.
*/
Field pathListField = findField(loader, "pathList");
Object dexPathList = pathListField.get(loader);
ArrayList<IOException> suppressedExceptions = new ArrayList<IOException>();
expandFieldArray(dexPathList, "dexElements", makeDexElements(dexPathList,
new ArrayList<File>(additionalClassPathEntries), optimizedDirectory,
suppressedExceptions));
if (suppressedExceptions.size() > 0) {
for (IOException e : suppressedExceptions) {
Log.w(TAG, "Exception in makeDexElement", e);
}
Field suppressedExceptionsField =
findField(dexPathList, "dexElementsSuppressedExceptions");
IOException[] dexElementsSuppressedExceptions =
(IOException[]) suppressedExceptionsField.get(dexPathList);
if (dexElementsSuppressedExceptions == null) {
dexElementsSuppressedExceptions =
suppressedExceptions.toArray(
new IOException[suppressedExceptions.size()]);
} else {
IOException[] combined =
new IOException[suppressedExceptions.size() +
dexElementsSuppressedExceptions.length];
suppressedExceptions.toArray(combined);
System.arraycopy(dexElementsSuppressedExceptions, 0, combined,
suppressedExceptions.size(), dexElementsSuppressedExceptions.length);
dexElementsSuppressedExceptions = combined;
}
suppressedExceptionsField.set(dexPathList, dexElementsSuppressedExceptions);
}
}
public void destroySurface() {
if (LOG_EGL) {
Log.w("EglHelper", "destroySurface() tid=" + Thread.currentThread().getId());
}
destroySurfaceImp();
}