public void handleMoving(String[] fields) { String volunteerString = fields[1]; String startString = fields[2]; String destinationString = fields[3]; int transitTime = Integer.parseInt(fields[4]); Log.i( "MOVING: volunteer=%s start=%s destination=%s transitTime=%d", volunteerString, startString, destinationString, transitTime); Volunteer volunteer = model.getVolunteerByName(volunteerString); if (volunteer == null) { Log.w("Haven't seen moving volunteer %s yet", volunteerString); return; } Location start = model.getLocationByName(startString); if (start == null) { Log.w("Haven't see start location %s yet", startString); return; } Location destination = model.getLocationByName(destinationString); if (destination == null) { Log.w("Haven't seen destination location %s yet", destinationString); return; } if (!start.getName().equals(startString)) Log.w( "MOVING violation: %s not at %s but rather at %s", volunteerString, startString, start.getName()); volunteer.startMoving(destination, transitTime); }
public void removeListener(String eventName, int eventId) { if (eventId > -1 && eventListeners != null) { checkSupportsEvent(eventName); // Throws exception of failure HashMap<Integer, TitaniumJSEvent> listeners = eventListeners.get(eventName); if (listeners != null) { synchronized (listeners) { TitaniumJSEvent event = listeners.get(eventId); if (event != null) { listeners.remove(eventId); } else { Log.w( LCAT, "Attempt to remove non-existant listener on event queue " + eventName + " with id " + eventId); } } } } else { Log.w( LCAT, "Invalid listener id: " + eventId + " or eventListeners is null" + (eventListeners == null)); } }
public void handleRequest(String[] fields) { String requesterName = fields[1]; String startString = fields[2]; String destinationString = fields[3]; int value = Integer.parseInt(fields[4]); Log.i( "REQUEST: requester=%s start=%s, destination=%s value=%d", requesterName, startString, destinationString, value); // Remove any old request with the same name... Request request = model.getRequestByName(requesterName); if (request != null) model.removeRequest(request); Location start = model.getLocationByName(startString); Location destination = model.getLocationByName(destinationString); if (start == null) { Log.w("Haven't see the request start location %s yet", startString); return; } if (destination == null) { Log.w("Haven't see the request destination location %s yet", destinationString); return; } new Request(model, requesterName, start, destination, value); }
public Bitmap run(ThreadPool.JobContext paramJobContext) { ImageCacheService localImageCacheService = this.mApplication.getImageCacheService(); BytesBufferPool.BytesBuffer localBytesBuffer = MediaItem.getBytesBufferPool().get(); Bitmap localBitmap1; try { boolean bool1 = localImageCacheService.getImageData(this.mPath, this.mType, localBytesBuffer); boolean bool2 = paramJobContext.isCancelled(); if (bool2) return null; if (bool1) { BitmapFactory.Options localOptions = new BitmapFactory.Options(); localOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; if (this.mType == 2) ; Bitmap localBitmap3; for (Object localObject2 = DecodeUtils.decode( paramJobContext, localBytesBuffer.data, localBytesBuffer.offset, localBytesBuffer.length, localOptions, MediaItem.getMicroThumbPool()); ; localObject2 = localBitmap3) { if ((localObject2 == null) && (!paramJobContext.isCancelled())) Log.w("ImageCacheRequest", "decode cached failed " + debugTag()); return localObject2; localBitmap3 = DecodeUtils.decode( paramJobContext, localBytesBuffer.data, localBytesBuffer.offset, localBytesBuffer.length, localOptions, MediaItem.getThumbPool()); } } MediaItem.getBytesBufferPool().recycle(localBytesBuffer); localBitmap1 = onDecodeOriginal(paramJobContext, this.mType); return null; } finally { MediaItem.getBytesBufferPool().recycle(localBytesBuffer); } if (localBitmap1 == null) { Log.w("ImageCacheRequest", "decode orig failed " + debugTag()); return null; } if (this.mType == 2) ; for (Bitmap localBitmap2 = BitmapUtils.resizeAndCropCenter(localBitmap1, this.mTargetSize, true); paramJobContext.isCancelled(); localBitmap2 = BitmapUtils.resizeDownBySideLength(localBitmap1, this.mTargetSize, true)) return null; byte[] arrayOfByte = BitmapUtils.compressToBytes(localBitmap2); if (paramJobContext.isCancelled()) return null; localImageCacheService.putImageData(this.mPath, this.mType, arrayOfByte); return (Bitmap) localBitmap2; }
public static void dumpRecentTasks(Context context) { ActivityManager mgr = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RecentTaskInfo> taskList = mgr.getRecentTasks(100, ActivityManager.RECENT_WITH_EXCLUDED); Log.w("Recent task information"); for (ActivityManager.RecentTaskInfo task : taskList) { Intent intent = task.baseIntent; dumpIntent(intent); Log.w(""); } }
public String get(String language, String key, String... vars) { Map<String, String> langMap; if (langDb.containsKey(language)) { langMap = langDb.get(language); } else { Log.w("Requested localized string in language '" + language + "' was not found."); langMap = langDb.get(defaultLanguage); if (langMap == null) { Log.e("Default language is not avaialable as fallback!"); } } if (langMap == null) { return "LANG_" + language.toUpperCase() + "_NOTFOUND"; } else { // Check if the key exists, if not, try the default language. if (!langMap.containsKey(key)) { langMap = langDb.get(defaultLanguage); if ((langMap == null) || !langMap.containsKey(key)) { Log.w( "Requested localized string '" + key + "' in language '" + language + "' was not found in the language " + ((langMap == null) ? " and defaultLanguage is not loaded!" : " or defaultLanguage!")); return language.toUpperCase() + "_" + key.toUpperCase() + "_NOTFOUND"; } } String localizedString = langMap.get(key); String varName = ""; for (String var : vars) { if (varName.isEmpty()) { varName = var; } else { Log.d("Replacing $" + varName + " with '" + var + "'"); localizedString = localizedString.replaceAll("\\$" + varName, var); varName = ""; } } return localizedString; } }
public static void retrieveMsg(Context context) { ContentResolver res = context.getContentResolver(); int id = -1; String msg_id = "0ECCC4DDA63A0000D940000101"; if (id < 0) { Uri uri = Uri.parse("content://mms"); Cursor cur = res.query(uri, MMS_COL_LIST, "tr_id=?", new String[] {msg_id}, null); if (cur == null) return; Log.w("rec count:" + cur.getCount()); if (!cur.moveToFirst()) return; id = cur.getInt(0); String sub = cur.getString(1); Log.w("_ID=" + id + " sub=" + sub); } Uri uri = Uri.parse("content://mms/" + id + "/part"); Cursor cur = res.query(uri, PART_COL_LIST, null, null, null); dumpCursor("MMS part", cur); if (cur == null || !cur.moveToFirst()) return; String text = cur.getString(0); if (text == null) { byte[] ba = cur.getBlob(1); if (ba == null) return; text = new String(ba); } Log.w("Contents=" + text); // // InputStream is = null; // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try { // is = res.openInputStream(uri); // // byte[] buffer = new byte[256]; // int len = is.read(buffer); // while (len >= 0) { // baos.write(buffer, 0, len); // len = is.read(buffer); // } // } catch (IOException ex) { // throw new RuntimeException(ex.getMessage(), ex); // } finally { // if (is != null) try {is.close();} catch (IOException ex) {} // } // // Log.w("Msg contents: " + baos.toString()); }
@Override public void onStart() { super.onStart(); mPaused = false; if (!init(mSavedUri)) { Log.w(TAG, "init failed: " + mSavedUri); finish(); return; } // normally this will never be zero but if one "backs" into this // activity after removing the sdcard it could be zero. in that // case just "finish" since there's nothing useful that can happen. int count = mAllImages.getCount(); if (count == 0) { finish(); return; } else if (count <= mCurrentPosition) { mCurrentPosition = count - 1; } if (mGetter == null) { makeGetter(); } //show controls only for first time setImage(mCurrentPosition, mShowControls); mShowControls = false; }
@Override public synchronized void saveRequest() { if (mData == null) { Log.w(TAG, "[saveRequest]mData is null,return!"); return; } int orientation = Exif.getOrientation(mData); // M: ConShots mGroupId = Exif.getGroupId(mData); mGroupIndex = Exif.getGroupIndex(mData); mFocusValueHigh = Exif.getFocusValueHigh(mData); mFocusValueLow = Exif.getFocusValueLow(mData); mOrientation = orientation; mDataSize = mData.length; if (null != mFileName) { mTitle = mFileName.substring(0, mFileName.indexOf('.')); } else { mTitle = createName(mFileType, mDateTaken, mGroupIndex); mFileName = Storage.generateFileName(mTitle, mTempPictureType); Log.i(TAG, "[saveRequest]PhotoOperator,mFileName = " + mFileName); } mFilePath = Storage.generateFilepath(mFileName); mTempFilePath = mFilePath + TEMP_SUFFIX; saveImageToSDCard(mTempFilePath, mFilePath, mData); // camera decouple mMimeType = Storage.generateMimetype(mTitle, mTempPictureType); checkDataProperty(); saveImageToDatabase(this); }
@Override public void saveSync() { if (mData == null) { Log.w(TAG, "[saveSync]why mData==null???", new Throwable()); return; } FileOutputStream out = null; try { // Write to a temporary file and rename it to the final name. // This // avoids other apps reading incomplete data. out = new FileOutputStream(mTempFilePath); out.write(mData); out.close(); } catch (IOException e) { Log.e(TAG, "[saveSync]Failed to write image", e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { Log.e(TAG, "[saveSync]exception : ", e); } } } }
@Override public void setData(byte[] data) { if (data == null) { Log.w(TAG, "[setData]data is null,please check the reason!"); } mData = data; }
/* * Handle a heap info message. */ private void handleHPIF(Client client, ByteBuffer data) { Log.d("ddm-heap", "HPIF!"); try { int numHeaps = data.getInt(); for (int i = 0; i < numHeaps; i++) { int heapId = data.getInt(); @SuppressWarnings("unused") long timeStamp = data.getLong(); @SuppressWarnings("unused") byte reason = data.get(); long maxHeapSize = (long) data.getInt() & 0x00ffffffff; long heapSize = (long) data.getInt() & 0x00ffffffff; long bytesAllocated = (long) data.getInt() & 0x00ffffffff; long objectsAllocated = (long) data.getInt() & 0x00ffffffff; client .getClientData() .setHeapInfo(heapId, maxHeapSize, heapSize, bytesAllocated, objectsAllocated); client.update(Client.CHANGE_HEAP_DATA); } } catch (BufferUnderflowException ex) { Log.w("ddm-heap", "malformed HPIF chunk from client"); } }
/** * Special fast path for appending items to the end of the array without validation. The array * must already be large enough to contain the item. * * @hide */ public void append(K key, V value) { int index = mSize; final int hash = key == null ? 0 : key.hashCode(); if (index >= mHashes.length) { throw new IllegalStateException("Array is full"); } if (index > 0 && mHashes[index - 1] > hash) { RuntimeException e = new RuntimeException("here"); e.fillInStackTrace(); Log.w( TAG, "New hash " + hash + " is before end of array hash " + mHashes[index - 1] + " at index " + index + " key " + key, e); put(key, value); return; } mSize = index + 1; mHashes[index] = hash; index <<= 1; mArray[index] = key; mArray[index + 1] = value; }
/** * Sends this message using one three methods: * * <ul> * <li>If the current thread is the same thread as the message Handler's thread, it is * dispatched immediately to the Handler * <li>If this TiMessenger is currently blocking, it is pushed into the internal message queue * to be processed by the next call to {@link #dispatchMessage()} * <li>If this TiMessenger is <b>NOT</b> current blocking, it is queued to it's Handler normally * by using msg.sendToTarget() * </ul> * * @param message The message to send */ public void sendMessage(Message message) { Handler target = message.getTarget(); long currentThreadId = Thread.currentThread().getId(); long targetThreadId = -1; if (target != null) { targetThreadId = target.getLooper().getThread().getId(); } if (target != null && currentThreadId == targetThreadId) { target.dispatchMessage(message); } else { if (isBlocking()) { try { messageQueue.put(message); } catch (InterruptedException e) { Log.w(TAG, "Interrupted trying to put new message, sending to handler", e); message.sendToTarget(); } } else { message.sendToTarget(); } } }
// Relative path is the absolute path minus external storage path public static String getRelativePath(int bucketId) { String relativePath = "/"; if (bucketId == MediaSetUtils.CAMERA_BUCKET_ID) { relativePath += BucketNames.CAMERA; } else if (bucketId == MediaSetUtils.DOWNLOAD_BUCKET_ID) { relativePath += BucketNames.DOWNLOAD; } else if (bucketId == MediaSetUtils.IMPORTED_BUCKET_ID) { relativePath += BucketNames.IMPORTED; } else if (bucketId == MediaSetUtils.SNAPSHOT_BUCKET_ID) { relativePath += BucketNames.SCREENSHOTS; } else if (bucketId == MediaSetUtils.EDITED_ONLINE_PHOTOS_BUCKET_ID) { relativePath += BucketNames.EDITED_ONLINE_PHOTOS; } else { // If the first few cases didn't hit the matching path, do a // thorough search in the local directories. File extStorage = Environment.getExternalStorageDirectory(); String path = GalleryUtils.searchDirForPath(extStorage, bucketId); if (path == null) { Log.w(TAG, "Relative path for bucket id: " + bucketId + " is not found."); relativePath = null; } else { relativePath = path.substring(extStorage.getAbsolutePath().length()); } } return relativePath; }
@Override public ArrayList<MediaItem> getMediaItem(int start, int count) { DataManager dataManager = mApplication.getDataManager(); Uri uri = mBaseUri.buildUpon().appendQueryParameter("limit", start + "," + count).build(); ArrayList<MediaItem> list = new ArrayList<MediaItem>(); GalleryUtils.assertNotInRenderThread(); Cursor cursor = mResolver.query( uri, mProjection, mWhereClause, new String[] {String.valueOf(mBucketId)}, mOrderClause); if (cursor == null) { Log.w(TAG, "query fail: " + uri); return list; } try { while (cursor.moveToNext()) { int id = cursor.getInt(0); // _id must be in the first column Path childPath = mItemPath.getChild(id); MediaItem item = loadOrUpdateItem(childPath, cursor, dataManager, mApplication, mIsImage); list.add(item); } } finally { cursor.close(); } return list; }
private void a(CircuitBreaker circuitBreaker, byte[] bArr, String str) { if (!circuitBreaker.b()) { try { OutputStream bufferedOutputStream = new BufferedOutputStream(a(str)); try { a(bufferedOutputStream, bArr); try { bufferedOutputStream.flush(); bufferedOutputStream.close(); } catch (IOException e) { } } catch (IOException e2) { try { Log.w(a, "Caught IOException while writing asset to disk: %s", new Object[] {str}); circuitBreaker.a(); try { bufferedOutputStream.flush(); bufferedOutputStream.close(); } catch (IOException e3) { } } catch (Throwable th) { try { bufferedOutputStream.flush(); bufferedOutputStream.close(); } catch (IOException e4) { } } } } catch (IOException e5) { Log.e(a, "Could not write an asset to disk: %s", new Object[] {str}); circuitBreaker.a(); } } }
private Connection findConnectionForAction(String callId, String action) { if (mConnectionById.containsKey(callId)) { return mConnectionById.get(callId); } Log.w(this, "%s - Cannot find Connection %s", action, callId); return getNullConnection(); }
private Conference findConferenceForAction(String conferenceId, String action) { if (mConferenceById.containsKey(conferenceId)) { return mConferenceById.get(conferenceId); } Log.w(this, "%s - Cannot find conference %s", action, conferenceId); return getNullConference(); }
protected void unpackComponents() throws IOException, FileNotFoundException { File applicationPackage = new File(getApplication().getPackageResourcePath()); File componentsDir = new File(sGREDir, "components"); if (componentsDir.lastModified() == applicationPackage.lastModified()) return; componentsDir.mkdir(); componentsDir.setLastModified(applicationPackage.lastModified()); GeckoAppShell.killAnyZombies(); ZipFile zip = new ZipFile(applicationPackage); byte[] buf = new byte[32768]; try { if (unpackFile(zip, buf, null, "removed-files")) removeFiles(); } catch (Exception ex) { // This file may not be there, so just log any errors and move on Log.w(LOG_FILE_NAME, "error removing files", ex); } // copy any .xpi file into an extensions/ directory Enumeration<? extends ZipEntry> zipEntries = zip.entries(); while (zipEntries.hasMoreElements()) { ZipEntry entry = zipEntries.nextElement(); if (entry.getName().startsWith("extensions/") && entry.getName().endsWith(".xpi")) { Log.i("GeckoAppJava", "installing extension : " + entry.getName()); unpackFile(zip, buf, entry, entry.getName()); } } }
public Bitmap run(JobContext jc) { String debugTag = mPath + "," + ((mType == MediaItem.TYPE_THUMBNAIL) ? "THUMB" : (mType == MediaItem.TYPE_MICROTHUMBNAIL) ? "MICROTHUMB" : "?"); ImageCacheService cacheService = mApplication.getImageCacheService(); ImageData data = cacheService.getImageData(mPath, mType); if (jc.isCancelled()) return null; if (data != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = DecodeUtils.requestDecode( jc, data.mData, data.mOffset, data.mData.length - data.mOffset, options); if (bitmap == null && !jc.isCancelled()) { Log.w(TAG, "decode cached failed " + debugTag); } return bitmap; } else { Bitmap bitmap = onDecodeOriginal(jc, mType); if (jc.isCancelled()) return null; if (bitmap == null) { Log.w(TAG, "decode orig failed " + debugTag); return null; } if (mType == MediaItem.TYPE_MICROTHUMBNAIL) { /* bitmap = BitmapUtils.resizeDownAndCropCenter(bitmap, mTargetSize, true);*/ } else { /*bitmap = BitmapUtils.resizeDownBySideLength(bitmap, mTargetSize, true);*/ } if (jc.isCancelled()) return null; /*byte[] array = BitmapUtils.compressBitmap(bitmap); if (jc.isCancelled()) return null; cacheService.putImageData(mPath, mType, array);*/ return bitmap; } }
public static void dumpCursor(String title, Cursor cursor) { if (cursor == null) { Log.w(title + ": No Results returned"); return; } Log.w(title + ": " + cursor.getCount() + " row returned"); if (cursor.moveToFirst()) { do { Log.w("\n"); for (int ndx = 0; ndx < cursor.getColumnCount(); ndx++) { Log.w(" " + cursor.getColumnName(ndx) + " = " + cursor.getString(ndx)); } } while (cursor.moveToNext()); } }
private void handleDelete(String[] fields) { Volunteer volunteer = model.getVolunteerByName(fields[1]); if (volunteer == null) { Log.w("Haven't see deleted volunteer %s yet", fields[1]); return; } model.removeVolunteer(volunteer); }
private void conference(String callId1, String callId2) { Log.d(this, "conference %s, %s", callId1, callId2); // Attempt to get second connection or conference. Connection connection2 = findConnectionForAction(callId2, "conference"); Conference conference2 = getNullConference(); if (connection2 == getNullConnection()) { conference2 = findConferenceForAction(callId2, "conference"); if (conference2 == getNullConference()) { Log.w(this, "Connection2 or Conference2 missing in conference request %s.", callId2); return; } } // Attempt to get first connection or conference and perform merge. Connection connection1 = findConnectionForAction(callId1, "conference"); if (connection1 == getNullConnection()) { Conference conference1 = findConferenceForAction(callId1, "addConnection"); if (conference1 == getNullConference()) { Log.w(this, "Connection1 or Conference1 missing in conference request %s.", callId1); } else { // Call 1 is a conference. if (connection2 != getNullConnection()) { // Call 2 is a connection so merge via call 1 (conference). conference1.onMerge(connection2); } else { // Call 2 is ALSO a conference; this should never happen. Log.wtf( this, "There can only be one conference and an attempt was made to " + "merge two conferences."); return; } } } else { // Call 1 is a connection. if (conference2 != getNullConference()) { // Call 2 is a conference, so merge via call 2. conference2.onMerge(connection1); } else { // Call 2 is a connection, so merge together. onConference(connection1, connection2); } } }
public static void postOnMain(Runnable runnable) { if (mainMessenger == null) { Log.w(TAG, "Unable to post runnable on main thread, main messenger is null"); return; } mainMessenger.handler.post(runnable); }
public synchronized void waitUntilReady() { while (!mReady) { try { wait(); } catch (InterruptedException e) { Log.w(TAG, "Interrupt waiting for RenderContext ready", e); } } }
@Override public void addRequest() { if (mData == null) { Log.w(TAG, "[addRequest]PhotoOperator,data is null,return!"); return; } Log.i(TAG, "[addRequest]PhotoOperator..."); addSaveRequest(this); }
public static void postOnRuntime(Runnable runnable) { if (runtimeMessenger == null) { Log.w(TAG, "Unable to post runnable on runtime thread, runtime messenger is null"); return; } runtimeMessenger.handler.post(runnable); }
public static BitmapRegionDecoder createBitmapRegionDecoder( JobContext jc, FileDescriptor fd, boolean shareable) { try { return BitmapRegionDecoder.newInstance(fd, shareable); } catch (Throwable t) { Log.w(TAG, t); return null; } }
public static BitmapRegionDecoder createBitmapRegionDecoder( JobContext jc, String filePath, boolean shareable) { try { return BitmapRegionDecoder.newInstance(filePath, shareable); } catch (Throwable t) { Log.w(TAG, t); return null; } }