类android.os.RemoteException源码实例Demo

下面列出了怎么用android.os.RemoteException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: letv   文件: IApkManagerImpl.java
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;
}
 
源代码2 项目: RePlugin-GameSdk   文件: SdkImpl.java
@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);

}
 
源代码3 项目: android_9.0.0_r45   文件: AuthenticationClient.java
@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);
    }
}
 
@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);
}
 
源代码5 项目: kognitivo   文件: AttributionIdentifiers.java
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;
}
 
源代码6 项目: android_9.0.0_r45   文件: LoadedApk.java
/**
 * 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;
}
 
源代码7 项目: android_9.0.0_r45   文件: TvRemoteProviderProxy.java
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;
}
 
源代码8 项目: android_9.0.0_r45   文件: ContextHubManager.java
/**
 * 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;
}
 
源代码9 项目: Running   文件: WalkingActivity.java
@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;
}
 
@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));
        }
    }
}
 
源代码11 项目: brailleback   文件: LabelProviderClient.java
/**
 * 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();
        }
    }
}
 
源代码12 项目: android_9.0.0_r45   文件: LauncherApps.java
/**
 * 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();
    }
}
 
源代码13 项目: android_9.0.0_r45   文件: BluetoothGatt.java
/**
 * 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;
}
 
/** @hide */
@Override
@SuppressWarnings("unchecked")
public List<PackageInfo> getInstalledPackagesAsUser(int flags, int userId) {
    try {
        ParceledListSlice<PackageInfo> parceledList =
                mPM.getInstalledPackages(flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
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;
    }
}
 
源代码16 项目: odyssey   文件: FilesFragment.java
/**
 * 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();
    }
}
 
源代码17 项目: DetectMagiskHide   文件: DetectMagisk.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detect_magisk);

    Button btnMagisk = findViewById(R.id.button);
    btnMagisk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.button:
                    if(bServiceBound){
                        boolean bIsMagisk = false;
                        try {
                            bIsMagisk = serviceBinder.isMagiskPresent();
                            if(bIsMagisk)
                                Toast.makeText(getApplicationContext(),"Magisk Found", Toast.LENGTH_LONG).show();
                            else
                                Toast.makeText(getApplicationContext(), "Magisk Not Found", Toast.LENGTH_LONG).show();

                            //getApplicationContext().unbindService(mIsolatedServiceConnection);
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                    }else{
                        Toast.makeText(getApplicationContext(), "Isolated Service not bound", Toast.LENGTH_SHORT).show();
                    }

            }
        }
    });
}
 
@Override
public void verifyIntentFilter(int id, int verificationCode, List<String> outFailedDomains) {
    try {
        mPM.verifyIntentFilter(id, verificationCode, outFailedDomains);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
源代码19 项目: external-nfc-api   文件: Acr1252UReader.java
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);
}
 
源代码20 项目: letv   文件: ScanningMediaService.java
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();
        }
    }
}
 
/** @hide */
@Override
public boolean isSignedBy(String packageName, KeySet ks) {
    Preconditions.checkNotNull(packageName);
    Preconditions.checkNotNull(ks);
    try {
        return mPM.isPackageSignedByKeySet(packageName, ks);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码22 项目: brailleback   文件: DisplayService.java
private void broadcastInputEvent(BrailleInputEvent event) {
    int i = mClients.beginBroadcast();
    try {
        while (i-- > 0) {
            try {
                mClients.getBroadcastItem(i).onInput(event);
            } catch (RemoteException ex) {
                // Nothing to do, the callback list will remove the
                // callback later.
            }
        }
    } finally {
        mClients.finishBroadcast();
    }
}
 
@Override
public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
        IPackageDataObserver observer) {
    try {
        mPM.freeStorageAndNotify(volumeUuid, idealStorageSize, 0, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
private void installCommon(Uri packageURI,
        PackageInstallObserver observer, int flags, String installerPackageName,
        int userId) {
    if (!"file".equals(packageURI.getScheme())) {
        throw new UnsupportedOperationException("Only file:// URIs are supported");
    }

    final String originPath = packageURI.getPath();
    try {
        mPM.installPackageAsUser(originPath, observer.getBinder(), flags, installerPackageName,
                userId);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
@Override
@SuppressWarnings("unchecked")
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        ParceledListSlice<PermissionGroupInfo> parceledList =
                mPM.getAllPermissionGroups(flags);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码26 项目: odyssey   文件: GenericActivity.java
public IOdysseyPlaybackService getPlaybackService() throws RemoteException {
    if (mServiceConnection != null) {
        return mServiceConnection.getPBS();
    } else {
        throw new RemoteException();
    }
}
 
源代码27 项目: PUMA   文件: MyInteractionController.java
/**
 * This method simply presses the power button if the screen is ON else
 * it does nothing if the screen is already OFF.
 * @return true if the device was awake else false
 * @throws RemoteException
 */
public boolean sleepDevice() throws RemoteException {
	if (isScreenOn()) {
		this.sendKey(KeyEvent.KEYCODE_POWER, 0);
		return true;
	}
	return false;
}
 
/**
 * Initialize a client record with the dictionary content provider.
 *
 * This merely acquires the content provider and calls
 * #reinitializeClientRecordInDictionaryContentProvider.
 *
 * @param context the context for resources and providers.
 * @param clientId the client ID to use.
 */
public static void initializeClientRecordHelper(final Context context, final String clientId) {
    try {
        final ContentProviderClient client = context.getContentResolver().
                acquireContentProviderClient(getProviderUriBuilder(context, "").build());
        if (null == client) return;
        reinitializeClientRecordInDictionaryContentProvider(context, client, clientId);
    } catch (RemoteException e) {
        Log.e(TAG, "Cannot contact the dictionary content provider", e);
    }
}
 
源代码29 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public void sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions) {
    warnIfCallingFromSystemProcess();
    String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
    try {
        intent.prepareToLeaveProcess(this);
        ActivityManagerNative.getDefault().broadcastIntent(
                mMainThread.getApplicationThread(), intent, resolvedType, null,
                Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
                null, false, false, getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
@Override
public void showAssistDisclosure() {
    if (mBar != null) {
        try {
            mBar.showAssistDisclosure();
        } catch (RemoteException e) {
        }
    }
}
 
 类所在包
 同包方法