OSDN Git Service

Merge "Bluetooth OPP should sanitize Uri data and MIME types before calling startActi...
authorZhihai Xu <zhihaixu@google.com>
Wed, 19 Dec 2012 23:22:18 +0000 (15:22 -0800)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Wed, 19 Dec 2012 23:22:18 +0000 (15:22 -0800)
1  2 
src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java

@@@ -169,43 -161,12 +169,43 @@@ public class BluetoothOppLauncherActivi
              Intent intent1 = new Intent();
              intent1.setAction(action);
              intent1.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
-             intent1.setData(uri);
+             intent1.setDataAndNormalize(uri);
              this.sendBroadcast(intent1);
 +            finish();
 +        } else {
 +            Log.w(TAG, "Unsupported action: " + action);
 +            finish();
          }
 -        finish();
      }
  
 +    /**
 +     * Turns on Bluetooth if not already on, or launches device picker if Bluetooth is on
 +     * @return
 +     */
 +    private final void launchDevicePicker() {
 +        // TODO: In the future, we may send intent to DevicePickerActivity
 +        // directly,
 +        // and let DevicePickerActivity to handle Bluetooth Enable.
 +        if (!BluetoothOppManager.getInstance(this).isEnabled()) {
 +            if (V) Log.v(TAG, "Prepare Enable BT!! ");
 +            Intent in = new Intent(this, BluetoothOppBtEnableActivity.class);
 +            in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 +            startActivity(in);
 +        } else {
 +            if (V) Log.v(TAG, "BT already enabled!! ");
 +            Intent in1 = new Intent(BluetoothDevicePicker.ACTION_LAUNCH);
 +            in1.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
 +            in1.putExtra(BluetoothDevicePicker.EXTRA_NEED_AUTH, false);
 +            in1.putExtra(BluetoothDevicePicker.EXTRA_FILTER_TYPE,
 +                    BluetoothDevicePicker.FILTER_TYPE_TRANSFER);
 +            in1.putExtra(BluetoothDevicePicker.EXTRA_LAUNCH_PACKAGE,
 +                    Constants.THIS_PACKAGE_NAME);
 +            in1.putExtra(BluetoothDevicePicker.EXTRA_LAUNCH_CLASS,
 +                    BluetoothOppReceiver.class.getName());
 +            if (V) {Log.d(TAG,"Launching " +BluetoothDevicePicker.ACTION_LAUNCH );}
 +            startActivity(in1);
 +        }
 +    }
      /* Returns true if Bluetooth is allowed given current airplane mode settings. */
      private final boolean isBluetoothAllowed() {
          final ContentResolver resolver = this.getContentResolver();