I honestly haven't been able to come up with a way to do this without modifying the sdk. If you're the OEM, it's easy (I'm on 4.3):
In packages/apps/Settings/AndroidManifest.xml, comment the intent filter for the pairing dialog:
<activity android:name=".bluetooth.BluetoothPairingDialog"
android:label="@string/bluetooth_pairing_request"
android:excludeFromRecents="true"
android:theme="@*android:style/Theme.Holo.Dialog.Alert">
<!-- <intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter> -->
</activity>
In frameworks/base/core/java/android/bluetooth/BluetoothDevice.java remove the @hide javadoc annotation from this constant
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_PAIRING_REQUEST =
"android.bluetooth.device.action.PAIRING_REQUEST";
and this method
public boolean setPairingConfirmation(boolean confirm)
Then register your own activity or broadcast receiver for the BluetoothDevice.PAIRING_REQUEST action. This broadcast receiver allows pairing to continue without user input (only if no pin is required):
@Override
public void onReceive(Context context, Intent intent) {
if( intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST) ) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
device.setPairingConfirmation( true );
}
}
You'll need to rebuild the sdk and compile your code against the new version to get access to the constant and methods, and replace Settings.apk on the /system partition to disable the dialog. You may possibly also need to be running as a system app but I think likely not.