Example usage for android.os RemoteException getMessage

List of usage examples for android.os RemoteException getMessage

Introduction

In this page you can find the example usage for android.os RemoteException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:id.ridon.keude.UpdateService.java

private void updateOrInsertApps(List<App> appsToUpdate, int totalUpdateCount, int currentCount) {

    ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
    List<String> knownAppIds = getKnownAppIds(appsToUpdate);
    for (final App a : appsToUpdate) {
        boolean known = false;
        for (String knownId : knownAppIds) {
            if (knownId.equals(a.id)) {
                known = true;//from   www .ja  v  a2s  .  c  om
                break;
            }
        }

        if (known) {
            operations.add(updateExistingApp(a));
        } else {
            operations.add(insertNewApp(a));
        }
    }

    Log.d("Keude", "Updating/inserting " + operations.size() + " apps.");
    try {
        executeBatchWithStatus(AppProvider.getAuthority(), operations, currentCount, totalUpdateCount);
    } catch (RemoteException e) {
        Log.e("Keude", e.getMessage());
    } catch (OperationApplicationException e) {
        Log.e("Keude", e.getMessage());
    }
}

From source file:id.ridon.keude.UpdateService.java

private void updateOrInsertApks(List<Apk> apksToUpdate, int totalApksAppsCount, int currentCount) {

    ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();

    List<Apk> knownApks = getKnownApks(apksToUpdate);
    for (final Apk apk : apksToUpdate) {
        boolean known = false;
        for (final Apk knownApk : knownApks) {
            if (knownApk.id.equals(apk.id) && knownApk.vercode == apk.vercode) {
                known = true;//from w w w .j  ava2s  .com
                break;
            }
        }

        if (known) {
            operations.add(updateExistingApk(apk));
        } else {
            operations.add(insertNewApk(apk));
            knownApks.add(apk); // In case another repo has the same version/id combo for this apk.
        }
    }

    Log.d("Keude", "Updating/inserting " + operations.size() + " apks.");
    try {
        executeBatchWithStatus(ApkProvider.getAuthority(), operations, currentCount, totalApksAppsCount);
    } catch (RemoteException e) {
        Log.e("Keude", e.getMessage());
    } catch (OperationApplicationException e) {
        Log.e("Keude", e.getMessage());
    }
}

From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java

private Error queryPurchases(String itemType) {
    Error ret = null;/*from w w  w .  j  ava 2  s  . c o m*/
    jsLog("queryPurchases for type: " + itemType);

    try {
        Bundle ownedItems = iabService.getPurchases(3, cordova.getActivity().getPackageName(), itemType, null);

        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == BILLING_RESPONSE_RESULT_OK) {
            ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
            ArrayList<String> signatureList = ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
            String continuationToken = ownedItems.getString("INAPP_CONTINUATION_TOKEN");

            jsLog("Got purchases: " + purchaseDataList.size());
            jsLog("Got signatures: " + signatureList.size());

            for (int i = 0; i < purchaseDataList.size(); ++i) {
                String purchaseData = purchaseDataList.get(i);
                String signature = signatureList.get(i);

                try {
                    Purchase purchase = new Purchase(purchaseData, signature);

                    if (base64EncodedPublicKey != null
                            && !Security.verifyPurchase(base64EncodedPublicKey, purchaseData, signature)) {

                        jsLog("Signature verification failed: " + purchaseData + " signature: " + signature);
                    } else {
                        jsLog("Purchase loaded for: " + purchase.getSku());

                        // add the purchase to the inventory
                        myInventory.addPurchase(purchase);
                    }
                } catch (JSONException e) {
                    ret = new Error(ERR_JSON_CONVERSION_FAILED, e.getMessage());
                }
            }
        }

        // TODO: if continuationToken != null, call getPurchases again 
        // and pass in the token to retrieve more items
    } catch (RemoteException ex) {
        Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex);
        ret = new Error(ERR_LOAD_RECEIPTS, ex.getMessage());
    }

    return ret;
}

From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java

/**
 * Consumes an already owned item.//from   w  w  w.j  a  v  a  2  s .  c om
 *
 * @param productId
 * @param callbackContext
 */
private void consumeProduct(final String productId, final CallbackContext callbackContext)
        throws JSONException {
    jsLog("consumeProduct called.");

    Purchase purchase = myInventory.getPurchase(productId);

    if (purchase != null) {
        try {
            int response = iabService.consumePurchase(3, cordova.getActivity().getPackageName(),
                    purchase.getToken());

            if (response == BILLING_RESPONSE_RESULT_OK) {
                myInventory.erasePurchaseByOrderId(purchase.getOrderId());

                callbackContext.success(purchase.toJavaScriptJson());
            }
        } catch (RemoteException ex) {
            Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.WARNING, null, ex);

            callbackContext.error(new Error(ERR_CONSUMPTION_FAILED, ex.getMessage()).toJavaScriptJSON());
        }
    } else {
        callbackContext.error(
                new Error(ERR_CONSUME_NOT_OWNED_ITEM, "No purchase record found for product id: " + productId)
                        .toJavaScriptJSON());
    }

}

From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java

/**
 * Buy an already loaded item./* w  w  w  .j  a v a2s. com*/
 *
 * @param productId
 * @param callbackContext
 */
private void buy(final String productId, final CallbackContext callbackContext) throws JSONException {

    jsLog("buy called for productId: " + productId);

    SkuDetails product = myInventory.getSkuDetails(productId);
    if (product == null) {
        callbackContext
                .error(new Error(ERR_PRODUCT_NOT_LOADED, "Product intended to be bought has not been loaded.")
                        .toJavaScriptJSON());
    } else if (BILLING_ITEM_TYPE_SUBS.equals(product.getType()) && !subscriptionSupported) {
        callbackContext.error(new Error(ERR_SUBSCRIPTION_NOT_SUPPORTED, "Subscriptions are not supported")
                .toJavaScriptJSON());
    } else {
        cordova.setActivityResultCallback(this);
        int requestCode = REQUEST_CODE_BASE++;

        try {
            jsLog("Preparing purchase flow");

            Bundle buyIntentBundle = iabService.getBuyIntent(3, cordova.getActivity().getPackageName(),
                    product.getSku(), product.getType(), null);

            int response = buyIntentBundle.getInt("RESPONSE_CODE");
            if (response == BILLING_RESPONSE_RESULT_OK) {
                PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

                pendingPurchaseCallbacks.put(requestCode, callbackContext);

                cordova.getActivity().startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode,
                        new Intent(), 0, 0, 0);

                jsLog("Purchase flow launched successfully");
            } else if (response == BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
                callbackContext.error(
                        new Error(ERR_PURCHASE_OWNED_ITEM, "Item requested to be bought is already owned.")
                                .toJavaScriptJSON());
            } else {
                callbackContext.error(
                        new Error(ERR_PURCHASE_FAILED, "Could not get buy intent. Response code: " + response)
                                .toJavaScriptJSON());
            }
        } catch (RemoteException ex) {
            Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex);
            callbackContext.error(new Error(ERR_PURCHASE_FAILED, ex.getMessage()).toJavaScriptJSON());
        } catch (IntentSender.SendIntentException ex) {
            Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex);
            callbackContext.error(new Error(ERR_PURCHASE_FAILED, ex.getMessage()).toJavaScriptJSON());
        }

    }
}

From source file:com.piusvelte.taplock.client.core.TapLockService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        String action = intent.getAction();
        if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
            int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF);
            if (state == BluetoothAdapter.STATE_ON) {
                if (mStartedBT) {
                    if (mUIInterface != null) {
                        try {
                            mUIInterface.setMessage("Bluetooth enabled");
                        } catch (RemoteException e) {
                            Log.e(TAG, e.getMessage());
                        }//  ww w.j a  v  a2s .  c om
                    }
                    if ((mQueueAddress != null) && (mQueueState != null))
                        requestWrite(mQueueAddress, mQueueState, mQueuePassphrase);
                    else if (mRequestDiscovery && !mBtAdapter.isDiscovering())
                        mBtAdapter.startDiscovery();
                    else if (mUIInterface != null) {
                        try {
                            mUIInterface.setBluetoothEnabled();
                        } catch (RemoteException e) {
                            Log.e(TAG, e.getMessage());
                        }
                    }
                }
            } else if (state == BluetoothAdapter.STATE_TURNING_OFF) {
                if (mUIInterface != null) {
                    try {
                        mUIInterface.setMessage("Bluetooth disabled");
                    } catch (RemoteException e) {
                        Log.e(TAG, e.getMessage());
                    }
                }
                stopThreads();
            }
        } else if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            // Get the BluetoothDevice object from the Intent
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            if (device.getBondState() == BluetoothDevice.BOND_BONDED) {
                // connect if configured
                String address = device.getAddress();
                for (JSONObject deviceJObj : mDevices) {
                    try {
                        if (deviceJObj.getString(KEY_ADDRESS).equals(address)) {
                            // if queued
                            mDeviceFound = (mQueueAddress != null) && mQueueAddress.equals(address)
                                    && (mQueueState != null);
                            break;
                        }
                    } catch (JSONException e) {
                        Log.e(TAG, e.getMessage());
                    }
                }
            } else if (mRequestDiscovery && (mUIInterface != null)) {
                String unpairedDevice = TapLock
                        .createDevice(device.getName(), device.getAddress(), DEFAULT_PASSPHRASE).toString();
                try {
                    mUIInterface.setUnpairedDevice(unpairedDevice);
                } catch (RemoteException e) {
                    Log.e(TAG, e.getMessage());
                }
            }
        } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
            if (mDeviceFound) {
                requestWrite(mQueueAddress, mQueueState, mQueuePassphrase);
                mDeviceFound = false;
            } else if (mRequestDiscovery) {
                mRequestDiscovery = false;
                if (mUIInterface != null) {
                    try {
                        mUIInterface.setDiscoveryFinished();
                    } catch (RemoteException e) {
                        Log.e(TAG, e.toString());
                    }
                }
            }
        } else if (ACTION_TOGGLE.equals(action) && intent.hasExtra(EXTRA_DEVICE_ADDRESS)) {
            String address = intent.getStringExtra(EXTRA_DEVICE_ADDRESS);
            requestWrite(address, ACTION_TOGGLE, null);
        } else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
            // create widget
            if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
                int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID);
                if (intent.hasExtra(EXTRA_DEVICE_NAME)) {
                    // add a widget
                    String deviceName = intent.getStringExtra(EXTRA_DEVICE_NAME);
                    for (int i = 0, l = mDevices.size(); i < l; i++) {
                        String name = null;
                        try {
                            name = mDevices.get(i).getString(KEY_NAME);
                        } catch (JSONException e1) {
                            e1.printStackTrace();
                        }
                        if ((name != null) && name.equals(deviceName)) {
                            JSONObject deviceJObj = mDevices.remove(i);
                            JSONArray widgetsJArr;
                            if (deviceJObj.has(KEY_WIDGETS)) {
                                try {
                                    widgetsJArr = deviceJObj.getJSONArray(KEY_WIDGETS);
                                } catch (JSONException e) {
                                    widgetsJArr = new JSONArray();
                                }
                            } else
                                widgetsJArr = new JSONArray();
                            widgetsJArr.put(appWidgetId);
                            try {
                                deviceJObj.put(KEY_WIDGETS, widgetsJArr);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            mDevices.add(i, deviceJObj);
                            TapLock.storeDevices(this, getSharedPreferences(KEY_PREFS, MODE_PRIVATE), mDevices);
                            break;
                        }
                    }
                }
                buildWidget(appWidgetId);
            } else if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)) {
                int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
                if (appWidgetIds != null) {
                    for (int appWidgetId : appWidgetIds)
                        buildWidget(appWidgetId);
                }
            }
        } else if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
            int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                    AppWidgetManager.INVALID_APPWIDGET_ID);
            Log.d(TAG, "delete appWidgetId: " + appWidgetId);
            for (int i = 0, l = mDevices.size(); i < l; i++) {
                JSONObject deviceJObj = mDevices.get(i);
                if (deviceJObj.has(KEY_WIDGETS)) {
                    JSONArray widgetsJArr = null;
                    try {
                        widgetsJArr = deviceJObj.getJSONArray(KEY_WIDGETS);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    if (widgetsJArr != null) {
                        boolean wasUpdated = false;
                        JSONArray newWidgetsJArr = new JSONArray();
                        for (int widgetIdx = 0, wdigetsLen = widgetsJArr
                                .length(); widgetIdx < wdigetsLen; widgetIdx++) {
                            int widgetId;
                            try {
                                widgetId = widgetsJArr.getInt(widgetIdx);
                            } catch (JSONException e) {
                                widgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
                                e.printStackTrace();
                            }
                            Log.d(TAG, "eval widgetId: " + widgetId);
                            if ((widgetId != AppWidgetManager.INVALID_APPWIDGET_ID)
                                    && (widgetId == appWidgetId)) {
                                Log.d(TAG, "skip: " + widgetId);
                                wasUpdated = true;
                            } else {
                                Log.d(TAG, "include: " + widgetId);
                                newWidgetsJArr.put(widgetId);
                            }
                        }
                        if (wasUpdated) {
                            try {
                                deviceJObj.put(KEY_WIDGETS, newWidgetsJArr);
                                mDevices.remove(i);
                                mDevices.add(i, deviceJObj);
                                TapLock.storeDevices(this, getSharedPreferences(KEY_PREFS, MODE_PRIVATE),
                                        mDevices);
                                Log.d(TAG, "stored: " + deviceJObj.toString());
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                } else {
                    JSONArray widgetsJArr = new JSONArray();
                    try {
                        deviceJObj.put(KEY_WIDGETS, widgetsJArr);
                        mDevices.remove(i);
                        mDevices.add(i, deviceJObj);
                        TapLock.storeDevices(this, getSharedPreferences(KEY_PREFS, MODE_PRIVATE), mDevices);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    return START_STICKY;
}

From source file:org.exfio.csyncdroid.resource.LocalCalendar.java

protected String resourceToString(Resource resource) throws LocalStorageException {

    String output = "Event:";

    @Cleanup//  w w w.j  a va  2s.c  o m
    Cursor cursor = null;
    try {
        cursor = providerClient.query(ContentUris.withAppendedId(entriesURI(), resource.getLocalID()),
                new String[] { /*  0 */ Events.TITLE, Events.EVENT_LOCATION, Events.DESCRIPTION,
                        /*  3 */ Events.DTSTART, Events.DTEND, Events.EVENT_TIMEZONE, Events.EVENT_END_TIMEZONE,
                        Events.ALL_DAY, /*  8 */ Events.STATUS, Events.ACCESS_LEVEL, /* 10 */ Events.RRULE,
                        Events.RDATE, Events.EXRULE, Events.EXDATE, /* 14 */ Events.HAS_ATTENDEE_DATA,
                        Events.ORGANIZER, Events.SELF_ATTENDEE_STATUS, /* 17 */ entryColumnUID(),
                        Events.DURATION, Events.AVAILABILITY, /* 20 */ entryColumnID(), entryColumnRemoteId() },
                null, null, null);
    } catch (RemoteException e) {
        throw new LocalStorageException("Couldn't find event (" + resource.getLocalID() + ")" + e.getMessage());
    }

    if (cursor != null && cursor.moveToNext()) {

        output += "\nLocalId: " + cursor.getString(20);
        output += "\nRemoteId: " + cursor.getString(21);
        output += "\nUID: " + cursor.getString(17);
        output += "\nTITLE: " + cursor.getString(0);
        output += "\nEVENT_LOCATION: " + cursor.getString(1);
        output += "\nDESCRIPTION: " + cursor.getString(2);

        boolean allDay = cursor.getInt(7) != 0;
        long tsStart = cursor.getLong(3);
        long tsEnd = cursor.getLong(4);
        String duration = cursor.getString(18);
        String tzStart = cursor.getString(5);
        String tzEnd = cursor.getString(6);

        Date dtStart = new Date(tsStart);
        Date dtEnd = new Date(tsEnd);

        output += "\nALL_DAY: " + allDay;
        output += "\nDTSTART: " + dtStart.toString() + "(" + tsStart + ")";
        output += "\nEVENT_TIMEZONE: " + tzStart;
        output += "\nDTEND: " + dtEnd.toString() + "(" + tsEnd + ")";
        output += "\nEVENT_END_TIMEZONE: " + tzEnd;
        output += "\nDURATION: " + duration;
        output += "\nSTATUS: " + cursor.getString(8);
        output += "\nACCESS_LEVEL: " + cursor.getString(9);
        output += "\nRRULE: " + cursor.getString(10);
        output += "\nRDATE: " + cursor.getString(11);
        output += "\nEXRULE: " + cursor.getString(12);
        output += "\nEXDATE: " + cursor.getString(13);
        output += "\nHAS_ATTENDEE_DATA: " + cursor.getString(14);
        output += "\nORGANIZER: " + cursor.getString(15);
        output += "\nSELF_ATTENDEE_STATUS: " + cursor.getString(16);
        output += "\nAVAILABILITY: " + cursor.getString(19);
    } else {
        throw new LocalStorageException("Invalid cursor while fetching event (" + resource.getLocalID() + ")");
    }
    return output;
}

From source file:com.psiphon3.psiphonlibrary.TunnelManager.java

private void sendClientMessage(int what, Bundle data) {
    if (m_incomingMessenger == null || m_outgoingMessenger == null) {
        return;//from   w ww .jav a 2s . c o  m
    }
    try {
        Message msg = Message.obtain(null, what);
        msg.replyTo = m_incomingMessenger;
        if (data != null) {
            msg.setData(data);
        }
        m_outgoingMessenger.send(msg);
    } catch (RemoteException e) {
        MyLog.g("sendClientMessage failed: %s", e.getMessage());
    }
}

From source file:com.jaus.albertogiunta.justintrain_oraritreni.utils.helpers.IAB.IabHelper.java

/**
 * Consumes a given in-app product. Consuming can only be done on an item
 * that's owned, and as a result of consumption, the user will no longer own it.
 * This method may block or take long to return. Do not call from the UI thread.
 * For that, see {@link #consumeAsync}./*from   www .jav  a2 s .com*/
 *
 * @param itemInfo The PurchaseInfo that represents the item to consume.
 * @throws IabException if there is a problem during consumption.
 */
void consume(Purchase itemInfo) throws IabException {
    checkSetupDone("consume");
    try {
        String token = itemInfo.getToken();
        String sku = itemInfo.getSku();
        if (token == null || token.equals("")) {
            logError("Can't consume " + sku + ". No token.");
            throw new IabException(IABHELPER_MISSING_TOKEN,
                    "PurchaseInfo is missing token for sku: " + sku + " " + itemInfo);
        }

        logDebug("Consuming sku: " + sku + ", token: " + token);
        int response = mService.consumePurchase(3, mContext.getPackageName(), token);
        if (response == BILLING_RESPONSE_RESULT_OK) {
            logDebug("Successfully consumed sku: " + sku);
        } else {
            logDebug("Error consuming consuming sku " + sku + ". " + getResponseDesc(response));
            throw new IabException(response, "Error consuming sku " + sku);
        }
    } catch (RemoteException e) {
        throw new IabException(IABHELPER_REMOTE_EXCEPTION,
                "Remote exception while consuming. PurchaseInfo: " + itemInfo, e);
    } catch (NullPointerException e) {
        Log.d("consume: ", e.getMessage());
    }
}

From source file:com.netcompss.ffmpeg4android_client.BaseWizard.java

private void setRemoteNotificationInfo() {
    try {/*w w w  . j  av  a2s. c o  m*/
        if (remoteService != null) {
            Log.i(Prefs.TAG, "setting remote notification info");
            if (notificationTitle != null)
                remoteService.setNotificationTitle(notificationTitle);
            if (notificationMessage != null)
                remoteService.setNotificationMessage(notificationMessage);
        } else {
            Log.w(Prefs.TAG, "remoteService is null, can't set remote notification info");
        }
    } catch (RemoteException e1) {
        Log.w(Prefs.TAG, e1.getMessage(), e1);
    }
}