List of usage examples for android.os RemoteException printStackTrace
public void printStackTrace()
From source file:cz.maresmar.sfm.utils.ActionUtils.java
/** * Make edits in Actions for corresponding Menu entry. These action are saved as * {@link ProviderContract#ACTION_SYNC_STATUS_LOCAL} then. * <p>/* w ww. jav a2 s .co m*/ * Handles menu group restrictions (like one order per group), in such cases creates * {@link ProviderContract#ACTION_ENTRY_TYPE_VIRTUAL} actions to override the * {@link ProviderContract#ACTION_SYNC_STATUS_SYNCED} ones. If an action reserves nothing, * the action is removed. * </p> * * @param context Some valid context * @param userUri User Uri prefix * @param relativeId Relative ID of corresponding Menu entry * @param portalId Portal ID of corresponding Menu entry * @param reserved New amount of reserved food * @param offered New amount of offered food */ @WorkerThread public static void makeEdit(@NonNull Context context, @NonNull Uri userUri, long relativeId, long portalId, int reserved, int offered) { // Load the corresponding menu entry @ProviderContract.PortalFeatures int portalFeatures; long menuGroupId; int price; long date; int syncedReserved, syncedOffered, syncedTaken; boolean hasLocal; int localReserved, localOffered; long portalGroupId; Uri menuUri = Uri.withAppendedPath(userUri, ProviderContract.MENU_ENTRY_PATH); ArrayList<ContentProviderOperation> ops = new ArrayList<>(); try (Cursor menuCursor = context.getContentResolver().query(menuUri, new String[] { ProviderContract.MenuEntry.PORTAL_FEATURES, ProviderContract.MenuEntry.GROUP_ID, ProviderContract.MenuEntry.PRICE, ProviderContract.MenuEntry.DATE, ProviderContract.MenuEntry.SYNCED_RESERVED_AMOUNT, ProviderContract.MenuEntry.SYNCED_OFFERED_AMOUNT, ProviderContract.MenuEntry.SYNCED_TAKEN_AMOUNT, ProviderContract.MenuEntry.LOCAL_RESERVED_AMOUNT, ProviderContract.MenuEntry.LOCAL_OFFERED_AMOUNT, ProviderContract.MenuEntry.PORTAL_GROUP_ID }, ProviderContract.MenuEntry.ME_RELATIVE_ID + " = " + relativeId + " AND " + ProviderContract.MenuEntry.PORTAL_ID + " = " + portalId, null, null)) { if (BuildConfig.DEBUG) { Assert.isOne(menuCursor.getCount()); } menuCursor.moveToFirst(); // Info portalFeatures = menuCursor.getInt(0); menuGroupId = menuCursor.getLong(1); price = menuCursor.getInt(2); date = menuCursor.getLong(3); // Synced syncedReserved = menuCursor.getInt(4); syncedOffered = menuCursor.getInt(5); syncedTaken = menuCursor.getInt(6); // Local hasLocal = !menuCursor.isNull(7); localReserved = menuCursor.getInt(7); localOffered = menuCursor.getInt(8); // Portal group portalGroupId = menuCursor.getLong(9); // Insert changes Uri actionUri = Uri.withAppendedPath(userUri, ProviderContract.ACTION_PATH); // Insert virtual group changes boolean restrictToOneOrderPerGroup = (portalFeatures & ProviderContract.FEATURE_RESTRICT_TO_ONE_ORDER_PER_GROUP) == ProviderContract.FEATURE_RESTRICT_TO_ONE_ORDER_PER_GROUP; // Delete old edits as I want something new if (!restrictToOneOrderPerGroup) { // Delete action for this menu entry ops.add((ContentProviderOperation.newDelete(actionUri) .withSelection(ProviderContract.Action.ME_RELATIVE_ID + " = " + relativeId + " AND " + ProviderContract.Action.ME_PORTAL_ID + " = " + portalId + " AND " + ProviderContract.Action.SYNC_STATUS + " = " + ProviderContract.ACTION_SYNC_STATUS_EDIT, null) .build())); } else { // Delete actions for whole menu entry group ops.add(ContentProviderOperation.newDelete(actionUri) .withSelection(ProviderContract.Action.ME_PORTAL_ID + " IN " + "(SELECT " + DbContract.Portal._ID + " FROM " + DbContract.Portal.TABLE_NAME + " WHERE " + DbContract.Portal.COLUMN_NAME_PGID + " == " + portalGroupId + " ) AND " + ProviderContract.Action.SYNC_STATUS + " = " + ProviderContract.ACTION_SYNC_STATUS_EDIT + " AND " + "EXISTS ( SELECT * FROM " + DbContract.MenuEntry.TABLE_NAME + " WHERE " + DbContract.MenuEntry.COLUMN_NAME_PID + " == " + ProviderContract.Action.ME_PORTAL_ID + " AND " + DbContract.MenuEntry.COLUMN_NAME_RELATIVE_ID + " == " + ProviderContract.Action.ME_RELATIVE_ID + " AND " + DbContract.MenuEntry.COLUMN_NAME_DATE + " == " + date + " AND " + DbContract.MenuEntry.COLUMN_NAME_MGID + " == " + menuGroupId + " )", null) .build()); } // Insert new edits if ((hasLocal && !(reserved == localReserved && offered == localOffered)) || (!hasLocal && !(reserved == syncedReserved && offered == syncedOffered))) { if (restrictToOneOrderPerGroup) { // Sets other actions in group to zeros try (Cursor groupCursor = context.getContentResolver().query(menuUri, new String[] { ProviderContract.MenuEntry.ME_RELATIVE_ID, ProviderContract.MenuEntry.PRICE, ProviderContract.MenuEntry.STATUS, ProviderContract.MenuEntry.SYNCED_RESERVED_AMOUNT, ProviderContract.MenuEntry.SYNCED_TAKEN_AMOUNT, ProviderContract.MenuEntry.PORTAL_ID }, ProviderContract.MenuEntry.PORTAL_ID + " IN " + "(SELECT " + DbContract.Portal._ID + " FROM " + DbContract.Portal.TABLE_NAME + " WHERE " + DbContract.Portal.COLUMN_NAME_PGID + " == " + portalGroupId + " ) AND " + ProviderContract.MenuEntry.DATE + " = " + date + " AND " + ProviderContract.MenuEntry.GROUP_ID + " = " + menuGroupId + " AND (" + "(IFNULL(" + ProviderContract.MenuEntry.SYNCED_RESERVED_AMOUNT + ", 0)" + " - IFNULL(" + ProviderContract.MenuEntry.SYNCED_TAKEN_AMOUNT + ", 0)) > 0 OR " + "(IFNULL(" + ProviderContract.MenuEntry.LOCAL_RESERVED_AMOUNT + ", 0)" + " - IFNULL(" + ProviderContract.MenuEntry.SYNCED_TAKEN_AMOUNT + ", 0)) > 0)", null, null)) { if (groupCursor != null) { while (groupCursor.moveToNext()) { // Skip main changed row if (groupCursor.getLong(0) == relativeId) { continue; } @ProviderContract.MenuStatus int status = groupCursor.getInt(2); boolean canCancel = (status & ProviderContract.MENU_STATUS_CANCELABLE) == ProviderContract.MENU_STATUS_CANCELABLE; boolean canUseStock = (status & ProviderContract.FEATURE_FOOD_STOCK) == ProviderContract.FEATURE_FOOD_STOCK; // Insert virtual actions ContentValues newAction = new ContentValues(); newAction.put(ProviderContract.Action.ME_RELATIVE_ID, groupCursor.getLong(0)); newAction.put(ProviderContract.Action.ME_PORTAL_ID, groupCursor.getLong(5)); newAction.put(ProviderContract.Action.SYNC_STATUS, ProviderContract.ACTION_SYNC_STATUS_EDIT); newAction.put(ProviderContract.Action.ENTRY_TYPE, ProviderContract.ACTION_ENTRY_TYPE_VIRTUAL); newAction.put(ProviderContract.Action.PRICE, groupCursor.getInt(1)); if (canCancel) { newAction.put(ProviderContract.Action.RESERVED_AMOUNT, 0); newAction.put(ProviderContract.Action.OFFERED_AMOUNT, 0); } else { newAction.put(ProviderContract.Action.RESERVED_AMOUNT, groupCursor.getInt(3)); newAction.put(ProviderContract.Action.OFFERED_AMOUNT, groupCursor.getInt(3)); Toast.makeText(context, R.string.actions_food_stock_on_restricted_to_one, Toast.LENGTH_LONG).show(); } newAction.put(ProviderContract.Action.TAKEN_AMOUNT, groupCursor.getInt(4)); ops.add(ContentProviderOperation.newInsert(actionUri).withValues(newAction) .build()); } } } } // Insert main edit ContentValues newAction = new ContentValues(); newAction.put(ProviderContract.Action.ME_RELATIVE_ID, relativeId); newAction.put(ProviderContract.Action.ME_PORTAL_ID, portalId); newAction.put(ProviderContract.Action.SYNC_STATUS, ProviderContract.ACTION_SYNC_STATUS_EDIT); newAction.put(ProviderContract.Action.ENTRY_TYPE, ProviderContract.ACTION_ENTRY_TYPE_STANDARD); newAction.put(ProviderContract.Action.PRICE, price); newAction.put(ProviderContract.Action.RESERVED_AMOUNT, reserved); newAction.put(ProviderContract.Action.OFFERED_AMOUNT, offered); newAction.put(ProviderContract.Action.TAKEN_AMOUNT, syncedTaken); ops.add(ContentProviderOperation.newInsert(actionUri).withValues(newAction).build()); } // Apply changes at once (it boost the performance) try { context.getContentResolver().applyBatch(ProviderContract.AUTHORITY, ops); } catch (RemoteException e) { e.printStackTrace(); } catch (OperationApplicationException e) { e.printStackTrace(); } } }
From source file:com.sentaroh.android.TaskAutomation.TaskManager.java
static final public void callBackToActivity(TaskManagerParms taskMgrParms, EnvironmentParms envParms, CommonUtilities util, String resp_time, String resp_id, String grp, String task, String action, String dlg_id, int resp_cd, String msg) { if (envParms.settingDebugLevel >= 2) util.addDebugMsg(2, "I", "callBackToActivity entered, resp=", resp_id, ", task=", task, ", action=", action, ", msg=", msg); synchronized (taskMgrParms.callBackList) { int on = taskMgrParms.callBackList.beginBroadcast(); if (on != 0) { ISchedulerCallback isv = null; for (int i = 0; i < on; i++) { try { isv = taskMgrParms.callBackList.getBroadcastItem(i); if (isv != null && envParms != null) isv.notifyToClient(resp_time, resp_id, grp, task, action, dlg_id, envParms.statsActiveTaskCount, resp_cd, msg); } catch (RemoteException e) { e.printStackTrace(); util.addLogMsg("E", "callBackToActivity error, num=", String.valueOf(on), "\n", e.toString()); }//w w w.j av a2 s . co m } taskMgrParms.callBackList.finishBroadcast(); } } }
From source file:org.lunci.lunci_waveform_example.ActivityServiceManagerBase.java
protected boolean sendMessageToService(Message msg) { if (mServiceMessenger == null) { Log.w(TAG, "service messenger is null"); return false; }/*from w w w . j a v a2 s.c o m*/ msg.replyTo = mServiceMessenger; if (msg.arg1 != 0) Log.e(TAG, "Message argument 1 is reserved for service assigned id. Do not use argument 1."); msg.arg1 = mServiceKey; try { mServiceMessenger.send(msg); } catch (RemoteException e) { e.printStackTrace(); return false; } return true; }
From source file:com.terracom.mumbleclient.util.JumbleServiceFragment.java
private void onServiceDetached(IJumbleService service) { mBound = false;/*from w w w .j ava 2 s. co m*/ try { if (getServiceObserver() != null) service.unregisterObserver(getServiceObserver()); } catch (RemoteException e) { e.printStackTrace(); } }
From source file:com.terracom.mumbleclient.util.JumbleServiceFragment.java
private void onServiceAttached(IJumbleService service) { mBound = true;/*from ww w.j a v a 2 s . co m*/ try { if (getServiceObserver() != null) service.registerObserver(getServiceObserver()); } catch (RemoteException e) { e.printStackTrace(); } onServiceBound(service); }
From source file:org.lunci.lunci_waveform_fragments.Fragment_ServiceManagerBase.java
protected boolean sendMessageToService(Message msg) { if (mServiceMessenger == null) return false; msg.replyTo = mServiceMessenger;/*from w w w . jav a2s. c om*/ if (msg.arg1 != 0) Log.e(TAG, "Message argument 1 is reserved for service assigned id. Do not use argument 1."); msg.arg1 = mServiceKey; try { mServiceMessenger.send(msg); } catch (RemoteException e) { e.printStackTrace(); return false; } return true; }
From source file:org.lunci.dumbthing.fragment.ServiceFragmentBase.java
@SuppressWarnings("unused") protected boolean sendMessageToService(Message msg) { if (mServiceMessenger == null) return false; msg.replyTo = mServiceMessenger;//from www . j a v a2 s . c om try { mServiceMessenger.send(msg); } catch (RemoteException e) { e.printStackTrace(); return false; } return true; }
From source file:MyWeatherService.java
void sendWeatherToClient(String actualWeatherString) { Bundle reply = new Bundle(); reply.putString("weather", actualWeatherString); Message replyMessage = Message.obtain(); replyMessage.setData(reply);//from w w w .j av a2 s . c o m try { messengerToClient.send(replyMessage); } catch (RemoteException e) { e.printStackTrace(); } }
From source file:xiaofei.library.hermes.util.HermesCallbackGc.java
private void gc() { synchronized (mReferenceQueue) { PhantomReference<Object> reference; Triple<IHermesServiceCallback, Long, Integer> triple; HashMap<IHermesServiceCallback, Pair<ArrayList<Long>, ArrayList<Integer>>> timeStamps = new HashMap<IHermesServiceCallback, Pair<ArrayList<Long>, ArrayList<Integer>>>(); while ((reference = (PhantomReference<Object>) mReferenceQueue.poll()) != null) { triple = mTimeStamps.remove(reference); if (triple != null) { Pair<ArrayList<Long>, ArrayList<Integer>> tmp = timeStamps.get(triple.first); if (tmp == null) { tmp = new Pair<ArrayList<Long>, ArrayList<Integer>>(new ArrayList<Long>(), new ArrayList<Integer>()); timeStamps.put(triple.first, tmp); }/*from ww w. ja v a2 s .c om*/ tmp.first.add(triple.second); tmp.second.add(triple.third); } } Set<Map.Entry<IHermesServiceCallback, Pair<ArrayList<Long>, ArrayList<Integer>>>> set = timeStamps .entrySet(); for (Map.Entry<IHermesServiceCallback, Pair<ArrayList<Long>, ArrayList<Integer>>> entry : set) { Pair<ArrayList<Long>, ArrayList<Integer>> values = entry.getValue(); if (!values.first.isEmpty()) { try { entry.getKey().gc(values.first, values.second); } catch (RemoteException e) { e.printStackTrace(); } } } } }
From source file:org.pluginporo.honeywell.BarcodeScannerPlugin.java
private void doScan() throws Exception { try {/*ww w. j a va 2 s.c om*/ decodeManager.doDecode(SCANTIMEOUT); } catch (RemoteException e) { e.printStackTrace(); } }