Java Code Examples for android.os.RemoteException#getMessage()

The following examples show how to use android.os.RemoteException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BluetoothSocket.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Set the LE Transmit Data Length to be the maximum that the BT Controller is capable of. This
 * parameter is used by the BT Controller to set the maximum transmission packet size on this
 * connection. This function is currently used for testing only.
 * @hide
 */
public void requestMaximumTxDataLength() throws IOException {
    if (mDevice == null) {
        throw new IOException("requestMaximumTxDataLength is called on null device");
    }

    try {
        if (mSocketState == SocketState.CLOSED) {
            throw new IOException("socket closed");
        }
        IBluetooth bluetoothProxy =
                BluetoothAdapter.getDefaultAdapter().getBluetoothService(null);
        if (bluetoothProxy == null) {
            throw new IOException("Bluetooth is off");
        }

        if (DBG) Log.d(TAG, "requestMaximumTxDataLength");
        bluetoothProxy.getSocketManager().requestMaximumTxDataLength(mDevice);
    } catch (RemoteException e) {
        Log.e(TAG, Log.getStackTraceString(new Throwable()));
        throw new IOException("unable to send RPC: " + e.getMessage());
    }
}
 
Example 2
Source File: Channel.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the data as received from the application select command inclusively the status word
 * received at applet selection.
 * The returned byte array contains the data bytes in the following order:
 * [<first data byte>, ..., <last data byte>, <sw1>, <sw2>]
 * @return The data as returned by the application select command inclusively the status word.
 * Only the status word if the application select command has no returned data.
 * Returns null if an application select command has not been performed or the selection
 * response can not be retrieved by the reader implementation.
 */
public @Nullable byte[] getSelectResponse() {
    if (!mService.isConnected()) {
        throw new IllegalStateException("service not connected to system");
    }

    byte[] response;
    try {
        response = mChannel.getSelectResponse();
    } catch (RemoteException e) {
        throw new IllegalStateException(e.getMessage());
    }

    if (response != null && response.length == 0) {
        response = null;
    }
    return response;
}
 
Example 3
Source File: PurchaseFlowLauncher.java    From android-easy-checkout with Apache License 2.0 6 votes vote down vote up
private Bundle getBuyIntent(IInAppBillingService service, List<String> oldItemIds,
                            String itemId, String developerPayload) throws BillingException {
    try {
        // Purchase an item
        if (oldItemIds == null || oldItemIds.isEmpty()) {
            return service.getBuyIntent(
                    mApiVersion, mPackageName, itemId, mItemType, developerPayload);
        }
        // Upgrade/downgrade of subscriptions must be done on api version 5
        // See https://developer.android.com/google/play/billing/billing_reference.html#upgrade-getBuyIntentToReplaceSkus
        return service.getBuyIntentToReplaceSkus(
                BillingApi.VERSION_5.getValue(),
                mPackageName,
                oldItemIds,
                itemId,
                mItemType,
                developerPayload);

    } catch (RemoteException e) {
        throw new BillingException(Constants.ERROR_REMOTE_EXCEPTION, e.getMessage());
    }
}
 
Example 4
Source File: BluetoothSocket.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Attempt to connect to a remote device.
 * <p>This method will block until a connection is made or the connection
 * fails. If this method returns without an exception then this socket
 * is now connected.
 * <p>Creating new connections to
 * remote Bluetooth devices should not be attempted while device discovery
 * is in progress. Device discovery is a heavyweight procedure on the
 * Bluetooth adapter and will significantly slow a device connection.
 * Use {@link BluetoothAdapter#cancelDiscovery()} to cancel an ongoing
 * discovery. Discovery is not managed by the Activity,
 * but is run as a system service, so an application should always call
 * {@link BluetoothAdapter#cancelDiscovery()} even if it
 * did not directly request a discovery, just to be sure.
 * <p>{@link #close} can be used to abort this call from another thread.
 *
 * @throws IOException on error, for example connection failure
 */
public void connect() throws IOException {
    if (mDevice == null) throw new IOException("Connect is called on null device");

    try {
        if (mSocketState == SocketState.CLOSED) throw new IOException("socket closed");
        IBluetooth bluetoothProxy =
                BluetoothAdapter.getDefaultAdapter().getBluetoothService(null);
        if (bluetoothProxy == null) throw new IOException("Bluetooth is off");
        mPfd = bluetoothProxy.getSocketManager().connectSocket(mDevice, mType,
                mUuid, mPort, getSecurityFlags());
        synchronized (this) {
            if (DBG) Log.d(TAG, "connect(), SocketState: " + mSocketState + ", mPfd: " + mPfd);
            if (mSocketState == SocketState.CLOSED) throw new IOException("socket closed");
            if (mPfd == null) throw new IOException("bt socket connect failed");
            FileDescriptor fd = mPfd.getFileDescriptor();
            mSocket = LocalSocket.createConnectedLocalSocket(fd);
            mSocketIS = mSocket.getInputStream();
            mSocketOS = mSocket.getOutputStream();
        }
        int channel = readInt(mSocketIS);
        if (channel <= 0) {
            throw new IOException("bt socket connect failed");
        }
        mPort = channel;
        waitSocketSignal(mSocketIS);
        synchronized (this) {
            if (mSocketState == SocketState.CLOSED) {
                throw new IOException("bt socket closed");
            }
            mSocketState = SocketState.CONNECTED;
        }
    } catch (RemoteException e) {
        Log.e(TAG, Log.getStackTraceString(new Throwable()));
        throw new IOException("unable to send RPC: " + e.getMessage());
    }
}
 
Example 5
Source File: Session.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Get the Answer to Reset of this Secure Element. <br>
 * The returned byte array can be null if the ATR for this Secure Element is
 * not available.
 *
 * @throws IllegalStateException if there was an error connecting to SE or
 *                               if the service was not connected.
 * @return the ATR as a byte array or null.
 */
public @Nullable byte[] getATR() {
    if (!mService.isConnected()) {
        throw new IllegalStateException("service not connected to system");
    }
    try {
        return mSession.getAtr();
    } catch (RemoteException e) {
        throw new IllegalStateException(e.getMessage());
    }
}
 
Example 6
Source File: SEService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Obtain a Reader instance from the SecureElementService
 */
private @NonNull ISecureElementReader getReader(String name) {
    try {
        return mSecureElementService.getReader(name);
    } catch (RemoteException e) {
        throw new IllegalStateException(e.getMessage());
    }
}
 
Example 7
Source File: Channel.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a boolean telling if this channel is the basic channel.
 *
 * @return <code>true</code> if this channel is a basic channel. <code>false</code> if
 *         this channel is a logical channel.
 */
public boolean isBasicChannel() {
    if (!mService.isConnected()) {
        throw new IllegalStateException("service not connected to system");
    }
    try {
        return mChannel.isBasicChannel();
    } catch (RemoteException e) {
        throw new IllegalStateException(e.getMessage());
    }
}
 
Example 8
Source File: PurchaseGetter.java    From android-easy-checkout with Apache License 2.0 5 votes vote down vote up
private Bundle getPurchasesBundle(IInAppBillingService service,
                                  String itemType,
                                  String continueToken) throws BillingException {
    try {
        return service.getPurchases(mApiVersion, mPackageName, itemType, continueToken);
    } catch (RemoteException e) {
        throw new BillingException(Constants.ERROR_REMOTE_EXCEPTION, e.getMessage());
    }
}
 
Example 9
Source File: BillingProcessor.java    From android-easy-checkout with Apache License 2.0 5 votes vote down vote up
protected void checkIfBillingIsSupported(PurchaseType purchaseType, IInAppBillingService service) throws BillingException {
    try {
        if (isSupported(purchaseType, service)) {
            return;
        }
    } catch (RemoteException e) {
        throw new BillingException(Constants.ERROR_REMOTE_EXCEPTION, e.getMessage());
    }
    if (purchaseType == PurchaseType.SUBSCRIPTION) {
        throw new BillingException(Constants.ERROR_SUBSCRIPTIONS_NOT_SUPPORTED,
                Constants.ERROR_MSG_SUBSCRIPTIONS_NOT_SUPPORTED);
    }
    throw new BillingException(Constants.ERROR_PURCHASES_NOT_SUPPORTED,
            Constants.ERROR_MSG_PURCHASES_NOT_SUPPORTED);
}
 
Example 10
Source File: ItemGetter.java    From android-easy-checkout with Apache License 2.0 5 votes vote down vote up
/**
 * In your application, you can query the item details from Google Play using the In-app Billing Version 3 API.
 * To pass a request to the In-app Billing service, first create a Bundle that contains
 * a String ArrayList of product IDs with key "ITEM_ID_LIST",
 * where each string is a product ID for an purchasable item.
 * See https://developer.android.com/google/play/billing/billing_integrate.html#QueryDetails
 *
 * @param service  in-app billing service
 * @param itemType "inapp" or "subs"
 * @param itemIds  contains the list of item ids that you want to request
 * @return
 * @throws BillingException
 */
ItemDetails get(IInAppBillingService service,
                String itemType,
                ArrayList<String> itemIds) throws BillingException {

    ItemDetails itemDetails = new ItemDetails();
    List<ArrayList<String>> splitItemIdList = new ArrayList<>();

    // There reason why it splits the item ids per request
    // It's because there is a known bug on Google Api
    // https://code.google.com/archive/p/marketbilling/issues/137
    for (int i = 0; i < itemIds.size(); i += ItemGetter.MAX_SKU_PER_REQUEST) {
        int fromIndex = i;
        int toIndex = Math.min(itemIds.size(), i + ItemGetter.MAX_SKU_PER_REQUEST);

        ArrayList<String> list = new ArrayList<>(itemIds.subList(fromIndex, toIndex));
        splitItemIdList.add(list);
    }

    for (ArrayList<String> splitItemIds : splitItemIdList) {
        try {
            Bundle itemIdsBundle = createBundleItemListFromArray(splitItemIds);
            Bundle skuDetails = service.getSkuDetails(mApiVersion, mPackageName, itemType, itemIdsBundle);
            List<String> detailList = getItemsFromResponse(skuDetails);
            putAll(detailList, itemDetails);

        } catch (RemoteException e) {
            throw new BillingException(Constants.ERROR_REMOTE_EXCEPTION, e.getMessage());
        }
    }
    return itemDetails;
}
 
Example 11
Source File: ZenLog.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private static String subscribeResult(IConditionProvider provider, RemoteException e) {
    return provider == null ? "no provider" : e != null ? e.getMessage() : "ok";
}