Java Code Examples for android.content.Intent#resolveSystemService()

The following examples show how to use android.content.Intent#resolveSystemService() . 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: KeyChainSystemService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(final Context context, final Intent broadcastIntent) {
    if (broadcastIntent.getPackage() != null) {
        return;
    }

    try {
        final Intent intent = new Intent(IKeyChainService.class.getName());
        ComponentName service =
                intent.resolveSystemService(getContext().getPackageManager(), 0 /*flags*/);
        if (service == null) {
            return;
        }
        intent.setComponent(service);
        intent.setAction(broadcastIntent.getAction());
        startServiceInBackgroundAsUser(intent, UserHandle.of(getSendingUserId()));
    } catch (RuntimeException e) {
        Slog.e(TAG, "Unable to forward package removed broadcast to KeyChain", e);
    }
}
 
Example 2
Source File: BluetoothManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind(Intent intent, ServiceConnection conn, int flags, UserHandle user) {
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, conn, flags, user)) {
        Slog.e(TAG, "Fail to bind to: " + intent);
        return false;
    }
    return true;
}
 
Example 3
Source File: BluetoothA2dp.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothA2dp.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            UserHandle.CURRENT_OR_SELF)) {
        Log.e(TAG, "Could not bind to Bluetooth A2DP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 4
Source File: BluetoothA2dpSink.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothA2dpSink.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth A2DP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 5
Source File: BluetoothPbapClient.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private boolean doBind() {
    Intent intent = new Intent(IBluetoothPbapClient.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth PBAP Client Service with " + intent);
        return false;
    }
    return true;
}
 
Example 6
Source File: BluetoothMapClient.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothMapClient.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth MAP MCE Service with " + intent);
        return false;
    }
    return true;
}
 
Example 7
Source File: BluetoothMap.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothMap.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth MAP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 8
Source File: BluetoothSap.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothSap.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth SAP Service with " + intent);
        return false;
    }
    return true;
}
 
Example 9
Source File: BluetoothHealth.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothHealth.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Health Service with " + intent);
        return false;
    }
    return true;
}
 
Example 10
Source File: BluetoothPbap.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothPbap.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Pbap Service with " + intent);
        return false;
    }
    return true;
}
 
Example 11
Source File: BluetoothAvrcpController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothAvrcpController.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth AVRCP Controller Service with " + intent);
        return false;
    }
    return true;
}
 
Example 12
Source File: BluetoothHeadsetClient.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothHeadsetClient.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Headset Client Service with " + intent);
        return false;
    }
    return true;
}
 
Example 13
Source File: BluetoothHidDevice.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothHidDevice.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth HID Device Service with " + intent);
        return false;
    }
    Log.d(TAG, "Bound to HID Device Service");
    return true;
}
 
Example 14
Source File: BluetoothPan.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothPan.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth Pan Service with " + intent);
        return false;
    }
    return true;
}
 
Example 15
Source File: BluetoothHearingAid.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void doBind() {
    Intent intent = new Intent(IBluetoothHearingAid.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            android.os.Process.myUserHandle())) {
        Log.e(TAG, "Could not bind to Bluetooth Hearing Aid Service with " + intent);
        return;
    }
}
 
Example 16
Source File: BluetoothHidHost.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
boolean doBind() {
    Intent intent = new Intent(IBluetoothHidHost.class.getName());
    ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
            mContext.getUser())) {
        Log.e(TAG, "Could not bind to Bluetooth HID Service with " + intent);
        return false;
    }
    return true;
}