android.os.RemoteException Java Examples

The following examples show how to use android.os.RemoteException. 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: BluetoothGatt.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Discovers services offered by a remote device as well as their
 * characteristics and descriptors.
 *
 * <p>This is an asynchronous operation. Once service discovery is completed,
 * the {@link BluetoothGattCallback#onServicesDiscovered} callback is
 * triggered. If the discovery was successful, the remote services can be
 * retrieved using the {@link #getServices} function.
 *
 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
 *
 * @return true, if the remote service discovery has been started
 */
public boolean discoverServices() {
    if (DBG) Log.d(TAG, "discoverServices() - device: " + mDevice.getAddress());
    if (mService == null || mClientIf == 0) return false;

    mServices.clear();

    try {
        mService.discoverServices(mClientIf, mDevice.getAddress());
    } catch (RemoteException e) {
        Log.e(TAG, "", e);
        return false;
    }

    return true;
}
 
Example #2
Source File: IApkManagerImpl.java    From letv with Apache License 2.0 6 votes vote down vote up
public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) throws RemoteException {
    waitForReadyInner();
    try {
        enforcePluginFileExists();
        if (shouldNotBlockOtherInfo()) {
            for (PluginPackageParser pluginPackageParser : this.mPluginCache.values()) {
                for (PermissionGroupInfo permissionGroupInfo : pluginPackageParser.getPermissionGroups()) {
                    if (TextUtils.equals(permissionGroupInfo.name, name)) {
                        return permissionGroupInfo;
                    }
                }
            }
        }
        List<String> pkgs = this.mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
        for (PluginPackageParser pluginPackageParser2 : this.mPluginCache.values()) {
            for (PermissionGroupInfo permissionGroupInfo2 : pluginPackageParser2.getPermissionGroups()) {
                if (TextUtils.equals(permissionGroupInfo2.name, name) && pkgs.contains(permissionGroupInfo2.packageName)) {
                    return permissionGroupInfo2;
                }
            }
        }
    } catch (Exception e) {
        handleException(e);
    }
    return null;
}
 
Example #3
Source File: SdkImpl.java    From RePlugin-GameSdk with Apache License 2.0 6 votes vote down vote up
@Override
public void Init(String hostInfo, IInitCallBack initCallBack, ISessionCallBack sessionCallBack, IPayCallBack payCallBack) throws RemoteException {
    Log.e(TAG,"sdkimpl init");
    Activity _ctx = getHostActivity();
    if(_ctx == null){
        return;
    }
    mIInitCallBack = initCallBack;
    mISessionCallBack = sessionCallBack;
    mIPayCallBack = payCallBack;

    Message msg = mH.obtainMessage();
    msg.what = Constant.H_Init;
    msg.obj = hostInfo;
    mH.sendMessage(msg);

}
 
Example #4
Source File: AuthenticationClient.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onAcquired(int acquiredInfo, int vendorCode) {
    // If the dialog is showing, the client doesn't need to receive onAcquired messages.
    if (mBundle != null) {
        try {
            if (acquiredInfo != FingerprintManager.FINGERPRINT_ACQUIRED_GOOD) {
                mStatusBarService.onFingerprintHelp(
                        mFingerprintManager.getAcquiredString(acquiredInfo, vendorCode));
            }
            return false; // acquisition continues
        } catch (RemoteException e) {
            Slog.e(TAG, "Remote exception when sending acquired message", e);
            return true; // client failed
        } finally {
            // Good scans will keep the device awake
            if (acquiredInfo == FingerprintManager.FINGERPRINT_ACQUIRED_GOOD) {
                notifyUserActivity();
            }
        }
    } else {
        return super.onAcquired(acquiredInfo, vendorCode);
    }
}
 
Example #5
Source File: ConsumePurchaseTest.java    From android-easy-checkout with Apache License 2.0 6 votes vote down vote up
@Test
public void billingNotSupport() throws InterruptedException, RemoteException, BillingException {
    final CountDownLatch latch = new CountDownLatch(1);

    Bundle stubBundle = new Bundle();
    stubBundle.putInt(ServiceStub.IN_APP_BILLING_SUPPORTED, 1);

    mServiceStub.setServiceForBinding(stubBundle);

    mProcessor.consume(DataConverter.TEST_PRODUCT_ID, new ConsumeItemHandler() {
        @Override
        public void onSuccess() {
            throw new IllegalStateException();
        }

        @Override
        public void onError(BillingException e) {
            assertThat(e.getErrorCode()).isEqualTo(Constants.ERROR_PURCHASES_NOT_SUPPORTED);
            assertThat(e.getMessage()).isEqualTo(Constants.ERROR_MSG_PURCHASES_NOT_SUPPORTED);
            latch.countDown();
        }
    });
    shadowOf(mWorkHandler.getLooper()).getScheduler().advanceToNextPostedRunnable();

    latch.await(15, TimeUnit.SECONDS);
}
 
Example #6
Source File: AttributionIdentifiers.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
public String getAdvertiserId() throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    String id;
    try {
        data.writeInterfaceToken(
                "com.google.android.gms.ads.identifier.internal.IAdvertisingIdService");
        binder.transact(FIRST_TRANSACTION_CODE, data, reply, 0);
        reply.readException();
        id = reply.readString();
    } finally {
        reply.recycle();
        data.recycle();
    }
    return id;
}
 
Example #7
Source File: LoadedApk.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the array of shared libraries that are listed as
 * used by the given package.
 *
 * @param packageName the name of the package (note: not its
 * file name)
 * @return null-ok; the array of shared libraries, each one
 * a fully-qualified path
 */
private static String[] getLibrariesFor(String packageName) {
    ApplicationInfo ai = null;
    try {
        ai = ActivityThread.getPackageManager().getApplicationInfo(packageName,
                PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    if (ai == null) {
        return null;
    }

    return ai.sharedLibraryFiles;
}
 
Example #8
Source File: TvRemoteProviderProxy.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public boolean register() {
    if (DEBUG) Slog.d(TAG, "Connection::register()");
    try {
        mTvRemoteProvider.asBinder().linkToDeath(this, 0);
        mTvRemoteProvider.setRemoteServiceInputSink(mServiceInputProvider);
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                onConnectionReady(Connection.this);
            }
        });
        return true;
    } catch (RemoteException ex) {
        binderDied();
    }
    return false;
}
 
Example #9
Source File: ContextHubManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Disables a nanoapp at the specified Context Hub.
 *
 * @param hubInfo the hub to disable the nanoapp on
 * @param nanoAppId the app to disable
 *
 * @return the ContextHubTransaction of the request
 *
 * @throws NullPointerException if hubInfo is null
 */
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
@NonNull public ContextHubTransaction<Void> disableNanoApp(
        @NonNull ContextHubInfo hubInfo, long nanoAppId) {
    Preconditions.checkNotNull(hubInfo, "ContextHubInfo cannot be null");

    ContextHubTransaction<Void> transaction =
            new ContextHubTransaction<>(ContextHubTransaction.TYPE_DISABLE_NANOAPP);
    IContextHubTransactionCallback callback = createTransactionCallback(transaction);

    try {
        mService.disableNanoApp(hubInfo.getId(), callback, nanoAppId);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    return transaction;
}
 
Example #10
Source File: WalkingActivity.java    From Running with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
    switch (msg.what) {

        case Constant.Config.MSG_FROM_SERVER:
            step = Long.valueOf(String.valueOf(msg.getData().get(Constant.Config.stepNum))) - lastStep;
            stepCount.setText(String.valueOf(step));
            calories.setText(String.valueOf(stepToKcal(step)));
            time.setText(String.valueOf(this.timemm));
            delayHandler.sendEmptyMessageDelayed(Constant.Config.REQUEST_SERVER, TIME_INTERVAL);
            break;
        case Constant.Config.REQUEST_SERVER:
            try {
                Message msg1 = Message.obtain(null, Constant.Config.MSG_FROM_CLIENT);
                msg1.replyTo = mGetReplyMessenger;
                messenger.send(msg1);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            break;
        case TIMECOM:
            runnable.run();
            break;
    }
    return false;
}
 
Example #11
Source File: TextClassificationManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void onClassifyText(
        TextClassificationSessionId sessionId,
        TextClassification.Request request, ITextClassificationCallback callback)
        throws RemoteException {
    Preconditions.checkNotNull(request);
    Preconditions.checkNotNull(callback);

    synchronized (mLock) {
        UserState userState = getCallingUserStateLocked();
        if (!userState.bindLocked()) {
            callback.onFailure();
        } else if (userState.isBoundLocked()) {
            userState.mService.onClassifyText(sessionId, request, callback);
        } else {
            userState.mPendingRequests.add(new PendingRequest(
                    () -> onClassifyText(sessionId, request, callback),
                    callback::onFailure, callback.asBinder(), this, userState));
        }
    }
}
 
Example #12
Source File: LabelProviderClient.java    From brailleback with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a summary of label info for each package from the label database.
 * <p>
 * Don't run this method on the UI thread. Use {@link android.os.AsyncTask}.
 *
 * @return An unmodifiable list of {@link PackageLabelInfo} objects, or an
 *         empty map if the query returns no results, or {@code null} if the
 *         query fails.
 */
public List<PackageLabelInfo> getPackageSummary(String locale) {
    LogUtils.log(this, Log.DEBUG, "Querying package summary.");

    if (!checkClient()) {
        return null;
    }

    final String[] whereArgs = { locale };

    Cursor cursor = null;
    try {
        cursor = mClient.query(mPackageSummaryContentUri, null /* projection */,
                PACKAGE_SUMMARY_QUERY_WHERE, whereArgs, null /* sortOrder */);

        return getPackageSummaryFromCursor(cursor);
    } catch (RemoteException e) {
        LogUtils.log(this, Log.ERROR, e.toString());
        return null;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
Example #13
Source File: LauncherApps.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Returns {@link ApplicationInfo} about an application installed for a specific user profile.
 *
 * @param packageName The package name of the application
 * @param flags Additional option flags {@link PackageManager#getApplicationInfo}
 * @param user The UserHandle of the profile.
 *
 * @return {@link ApplicationInfo} containing information about the package. Returns
 *         {@code null} if the package isn't installed for the given profile, or the profile
 *         isn't enabled.
 */
public ApplicationInfo getApplicationInfo(@NonNull String packageName,
        @ApplicationInfoFlags int flags, @NonNull UserHandle user)
        throws PackageManager.NameNotFoundException {
    Preconditions.checkNotNull(packageName, "packageName");
    Preconditions.checkNotNull(user, "user");
    logErrorForInvalidProfileAccess(user);
    try {
        final ApplicationInfo ai = mService
                .getApplicationInfo(mContext.getPackageName(), packageName, flags, user);
        if (ai == null) {
            throw new NameNotFoundException("Package " + packageName + " not found for user "
                    + user.getIdentifier());
        }
        return ai;
    } catch (RemoteException re) {
        throw re.rethrowFromSystemServer();
    }
}
 
Example #14
Source File: MmsServiceBroker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public Uri importMultimediaMessage(String callingPkg, Uri contentUri,
        String messageId, long timestampSecs, boolean seen, boolean read)
                throws RemoteException {
    if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            callingPkg) != AppOpsManager.MODE_ALLOWED) {
        // Silently fail AppOps failure due to not being the default SMS app
        // while writing the TelephonyProvider
        return FAKE_MMS_SENT_URI;
    }
    return getServiceGuarded().importMultimediaMessage(
            callingPkg, contentUri, messageId, timestampSecs, seen, read);
}
 
Example #15
Source File: ConversationListFragment.java    From KlyphMessenger with MIT License 5 votes vote down vote up
private void refreshRoster()
{
	if (mIRemoteService != null)
	{
		try
		{
			roster = mIRemoteService.getRoster();
		}
		catch (RemoteException e)
		{
			e.printStackTrace();
		}
	}
}
 
Example #16
Source File: IMediaSession.java    From letv with Apache License 2.0 5 votes vote down vote up
public long getFlags() throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        this.mRemote.transact(9, _data, _reply, 0);
        _reply.readException();
        long _result = _reply.readLong();
        return _result;
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
Example #17
Source File: FilesFragment.java    From odyssey with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Call the PBS to enqueue all music in the current folder and his children.
 */
private void enqueueCurrentFolderAndSubFolders() {

    try {
        ((GenericActivity) getActivity()).getPlaybackService().enqueueDirectoryAndSubDirectories(mCurrentDirectory.getPath(), mSearchString);
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
Example #18
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceInfo getServiceInfo(ComponentName className, int flags)
        throws NameNotFoundException {
    try {
        ServiceInfo si = mPM.getServiceInfo(className, flags, mContext.getUserId());
        if (si != null) {
            return si;
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(className.toString());
}
 
Example #19
Source File: PackageNameService.java    From FakeGApps with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getPackageName(int uid) throws RemoteException {
    String[] packages = context.getPackageManager().getPackagesForUid(uid);
    if (packages != null) {
        return packages[0];
    }
    return null;
}
 
Example #20
Source File: CastDeviceControllerImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 5 votes vote down vote up
public void onBinaryMessageReceived(String namespace, byte[] data) {
    if (this.listener != null) {
        try {
            this.listener.onBinaryMessageReceived(namespace, data);
        } catch (RemoteException ex) {
            Log.e(TAG, "Error calling onBinaryMessageReceived: " + ex.getMessage());
        }
    }
}
 
Example #21
Source File: IabHelper.java    From pay-me with Apache License 2.0 5 votes vote down vote up
private int querySkuDetails(ItemType itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);
            }
        }
    }
    if (skuList.isEmpty()) {
        logDebug("querySkuDetails: nothing to do because there are no SKUs.");
        return OK.code;
    }

    // TODO: check for 20 SKU limit + add batching ?
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(API_VERSION, mContext.getPackageName(), itemType.toString(), querySkus);
    if (skuDetails == null) return IABHELPER_BAD_RESPONSE.code;

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != OK.code) {
            logWarn("getSkuDetails() failed: " + getDescription(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE.code;
        }
    }
    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);
    for (String json : responseList) {
        inv.addSkuDetails(new SkuDetails(json));
    }
    return OK.code;
}
 
Example #22
Source File: SliceManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Get the list of currently pinned slices for this app.
 * @see SliceProvider#onSlicePinned
 */
public @NonNull List<Uri> getPinnedSlices() {
    try {
        return Arrays.asList(mService.getPinnedSlices(mContext.getPackageName()));
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #23
Source File: ServicePlayerController.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Override
public void queueLast(List<Song> songs) {
    execute(() -> {
        try {
            mBinding.queueLastList(songs);
        } catch (RemoteException exception) {
            Timber.e(exception, "Failed to queue last songs");
        }
        invalidateAll();
    });
}
 
Example #24
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener) {
    synchronized (mPermissionListeners) {
        IOnPermissionsChangeListener delegate = mPermissionListeners.get(listener);
        if (delegate != null) {
            try {
                mPM.removeOnPermissionsChangeListener(delegate);
                mPermissionListeners.remove(listener);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
}
 
Example #25
Source File: StatusBarManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onNotificationDirectReplied(String key) throws RemoteException {
    enforceStatusBarService();
    long identity = Binder.clearCallingIdentity();
    try {
        mNotificationDelegate.onNotificationDirectReplied(key);
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
 
Example #26
Source File: Acr1252UReader.java    From external-nfc-api with Apache License 2.0 5 votes vote down vote up
public boolean setDefaultLEDAndBuzzerBehaviour(AcrDefaultLEDAndBuzzerBehaviour ... types) {
	byte[] response;
	try {
		int operation = serializeBehaviour(types);
		
		response = readerControl.setDefaultLEDAndBuzzerBehaviour(operation);
	} catch (RemoteException e) {
		throw new AcrReaderException(e);
	}
	
	return readBoolean(response);
}
 
Example #27
Source File: ScanningMediaService.java    From letv with Apache License 2.0 5 votes vote down vote up
private void sendData(int cmd) {
    if (this.messenger != null) {
        Message msg = Message.obtain();
        msg.what = cmd;
        try {
            this.messenger.send(msg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
 
Example #28
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void unregisterReceiver(BroadcastReceiver receiver) {
    if (mPackageInfo != null) {
        IIntentReceiver rd = mPackageInfo.forgetReceiverDispatcher(
                getOuterContext(), receiver);
        try {
            ActivityManagerNative.getDefault().unregisterReceiver(rd);
        } catch (RemoteException e) {
        }
    } else {
        throw new RuntimeException("Not supported in system context");
    }
}
 
Example #29
Source File: ActivityManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
int runTask(PrintWriter pw) throws RemoteException {
    String op = getNextArgRequired();
    if (op.equals("lock")) {
        return runTaskLock(pw);
    } else if (op.equals("resizeable")) {
        return runTaskResizeable(pw);
    } else if (op.equals("resize")) {
        return runTaskResize(pw);
    } else if (op.equals("focus")) {
        return runTaskFocus(pw);
    } else {
        getErrPrintWriter().println("Error: unknown command '" + op + "'");
        return -1;
    }
}
 
Example #30
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyIntentFilter(int id, int verificationCode, List<String> outFailedDomains) {
    try {
        mPM.verifyIntentFilter(id, verificationCode, outFailedDomains);
    } catch (RemoteException e) {
        // Should never happen!
    }
}