Loading android/app/src/com/android/bluetooth/opp/BluetoothOppBatch.java +0 −19 Original line number Diff line number Diff line Loading @@ -129,25 +129,6 @@ public class BluetoothOppBatch { } } /** * Delete one share from the batch. Not used now. */ /*It should only be called under requirement that cancel one single share, but not to * cancel the whole batch. Currently we assume "cancel" is to cancel whole batch. */ public void deleteShare(BluetoothOppShareInfo info) { if (info.mStatus == BluetoothShare.STATUS_RUNNING) { info.mStatus = BluetoothShare.STATUS_CANCELED; if (info.mDirection == BluetoothShare.DIRECTION_INBOUND && info.mFilename != null) { new File(info.mFilename).delete(); } } if (mListener != null) { mListener.onShareDeleted(info.mId); } } /** * Cancel the whole batch. */ Loading android/app/src/com/android/bluetooth/opp/BluetoothOppHandoverReceiver.java +7 −9 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import java.util.ArrayList; public class BluetoothOppHandoverReceiver extends BroadcastReceiver { public static final String TAG ="BluetoothOppHandoverReceiver"; private static final boolean D = Constants.DEBUG; private static final boolean V = Constants.VERBOSE; @Override public void onReceive(Context context, Intent intent) { Loading @@ -36,15 +35,14 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver { if (action.equals(Constants.ACTION_HANDOVER_SEND) || action.equals(Constants.ACTION_HANDOVER_SEND_MULTIPLE)) { BluetoothDevice device = final BluetoothDevice device = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (device == null) { if (D) Log.d(TAG, "No device attached to handover intent."); return; } String mimeType = intent.getType(); final String mimeType = intent.getType(); ArrayList<Uri> uris = new ArrayList<Uri>(); if (action.equals(Constants.ACTION_HANDOVER_SEND)) { Uri stream = (Uri)intent.getParcelableExtra(Intent.EXTRA_STREAM); Loading @@ -54,13 +52,13 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver { } if (mimeType != null && uris != null && !uris.isEmpty()) { final String finalType = mimeType; final Context finalContext = context; final ArrayList<Uri> finalUris = uris; Thread t = new Thread(new Runnable() { public void run() { BluetoothOppManager.getInstance(context).saveSendingFileInfo(finalType, finalUris, true); BluetoothOppManager.getInstance(context).startTransfer(device); BluetoothOppManager.getInstance(finalContext) .saveSendingFileInfo(mimeType, finalUris, true); BluetoothOppManager.getInstance(finalContext).startTransfer(device); } }); t.start(); Loading android/app/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java +9 −8 Original line number Diff line number Diff line Loading @@ -215,15 +215,15 @@ public class BluetoothOppLauncherActivity extends Activity { final ContentResolver resolver = this.getContentResolver(); // Check if airplane mode is on final boolean isAirplaneModeOn = Settings.System.getInt(resolver, Settings.System.AIRPLANE_MODE_ON, 0) == 1; final boolean isAirplaneModeOn = Settings.System.getInt(resolver, Settings.Global.AIRPLANE_MODE_ON, 0) == 1; if (!isAirplaneModeOn) { return true; } // Check if airplane mode matters final String airplaneModeRadios = Settings.System.getString(resolver, Settings.System.AIRPLANE_MODE_RADIOS); final String airplaneModeRadios = Settings.System.getString(resolver, Settings.Global.AIRPLANE_MODE_RADIOS); final boolean isAirplaneSensitive = airplaneModeRadios == null ? true : airplaneModeRadios.contains(Settings.System.RADIO_BLUETOOTH); if (!isAirplaneSensitive) { Loading @@ -231,10 +231,11 @@ public class BluetoothOppLauncherActivity extends Activity { } // Check if Bluetooth may be enabled in airplane mode final String airplaneModeToggleableRadios = Settings.System.getString(resolver, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS); final boolean isAirplaneToggleable = airplaneModeToggleableRadios == null ? false : airplaneModeToggleableRadios.contains(Settings.System.RADIO_BLUETOOTH); final String airplaneModeToggleableRadios = Settings.System.getString( resolver, Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS); final boolean isAirplaneToggleable = airplaneModeToggleableRadios == null ? false : airplaneModeToggleableRadios.contains(Settings.Global.RADIO_BLUETOOTH); if (isAirplaneToggleable) { return true; } Loading android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +62 −41 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ package com.android.bluetooth.opp; import com.android.bluetooth.R; import android.content.ContentResolver; import android.content.Context; import android.app.Notification; import android.app.Notification.Action; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; Loading Loading @@ -105,6 +107,7 @@ class BluetoothOppNotification { private int mActiveNotificationId = 0; private ContentResolver mContentResolver = null; /** * This inner class is used to describe some properties for one transfer. */ Loading Loading @@ -137,6 +140,8 @@ class BluetoothOppNotification { mNotificationMgr = (NotificationManager)mContext .getSystemService(Context.NOTIFICATION_SERVICE); mNotifications = new HashMap<String, NotificationItem>(); // Get Content Resolver object one time mContentResolver = mContext.getContentResolver(); } /** Loading Loading @@ -212,8 +217,8 @@ class BluetoothOppNotification { private void updateActiveNotification() { // Active transfers Cursor cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, WHERE_RUNNING, null, BluetoothShare._ID); Cursor cursor = mContentResolver.query( BluetoothShare.CONTENT_URI, null, WHERE_RUNNING, null, BluetoothShare._ID); if (cursor == null) { return; } Loading Loading @@ -317,9 +322,10 @@ class BluetoothOppNotification { // TODO: split description into two rows with filename in second row Notification.Builder b = new Notification.Builder(mContext); b.setColor(mContext.getResources().getColor( com.android.internal.R.color.system_notification_accent_color)); com.android.internal.R.color.system_notification_accent_color, mContext.getTheme())); b.setContentTitle(item.description); b.setContentInfo( b.setSubText( BluetoothOppUtility.formatProgressText(item.totalTotal, item.totalCurrent)); if (item.totalTotal != 0) { if (V) Log.v(TAG, "mCurrentBytes: " + item.totalCurrent + Loading @@ -345,7 +351,7 @@ class BluetoothOppNotification { intent.setDataAndNormalize(Uri.parse(BluetoothShare.CONTENT_URI + "/" + item.id)); b.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent, 0)); mNotificationMgr.notify(item.id, b.getNotification()); mNotificationMgr.notify(item.id, b.build()); mActiveNotificationId = item.id; } Loading Loading @@ -377,7 +383,7 @@ class BluetoothOppNotification { } // Creating outbound notification Cursor cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, Cursor cursor = mContentResolver.query(BluetoothShare.CONTENT_URI, null, WHERE_COMPLETED_OUTBOUND, null, BluetoothShare.TIMESTAMP + " DESC"); if (cursor == null) { return; Loading Loading @@ -436,8 +442,8 @@ class BluetoothOppNotification { } // Creating inbound notification cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, WHERE_COMPLETED_INBOUND, null, BluetoothShare.TIMESTAMP + " DESC"); cursor = mContentResolver.query(BluetoothShare.CONTENT_URI, null, WHERE_COMPLETED_INBOUND, null, BluetoothShare.TIMESTAMP + " DESC"); if (cursor == null) { return; } Loading Loading @@ -493,8 +499,8 @@ class BluetoothOppNotification { } private void updateIncomingFileConfirmNotification() { Cursor cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, WHERE_CONFIRM_PENDING, null, BluetoothShare._ID); Cursor cursor = mContentResolver.query( BluetoothShare.CONTENT_URI, null, WHERE_CONFIRM_PENDING, null, BluetoothShare._ID); if (cursor == null) { return; Loading @@ -506,29 +512,44 @@ class BluetoothOppNotification { Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + info.mID); Intent baseIntent = new Intent().setDataAndNormalize(contentUri) .setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); Notification n = new Notification.Builder(mContext) Notification.Action actionDecline = new Notification.Action .Builder(R.drawable.ic_decline, mContext.getText(R.string.incoming_file_confirm_cancel), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent) .setAction(Constants.ACTION_DECLINE), 0)) .build(); Notification.Action actionAccept = new Notification.Action .Builder(R.drawable.ic_accept, mContext.getText(R.string.incoming_file_confirm_ok), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_ACCEPT), 0)) .build(); Notification n = new Notification.Builder(mContext) .setOnlyAlertOnce(true) .setOngoing(true) .setVibrate(new long[] {200}) .setWhen(info.mTimeStamp) .setDefaults(Notification.DEFAULT_SOUND) .setPriority(Notification.PRIORITY_HIGH) .addAction(R.drawable.ic_decline, mContext.getText(R.string.incoming_file_confirm_cancel), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_DECLINE), 0)) .addAction(R.drawable.ic_accept, mContext.getText(R.string.incoming_file_confirm_ok), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_ACCEPT), 0)) .addAction(actionDecline) .addAction(actionAccept) .setContentIntent(PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_INCOMING_FILE_CONFIRM), 0)) new Intent(baseIntent) .setAction(Constants.ACTION_INCOMING_FILE_CONFIRM), 0)) .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_HIDE), 0)) .setColor(mContext.getResources().getColor( com.android.internal.R.color.system_notification_accent_color)) .setContentTitle(mContext.getText(R.string.incoming_file_confirm_Notification_title)) com.android.internal.R.color.system_notification_accent_color, mContext.getTheme())) .setContentTitle(mContext.getText( R.string.incoming_file_confirm_Notification_title)) .setContentText(info.mFileName) .setStyle(new Notification.BigTextStyle().bigText(mContext.getString( R.string.incoming_file_confirm_Notification_content, Loading android/app/src/com/android/bluetooth/opp/BluetoothOppProvider.java +0 −1 Original line number Diff line number Diff line Loading @@ -240,7 +240,6 @@ public final class BluetoothOppProvider extends ContentProvider { } Integer dir = values.getAsInteger(BluetoothShare.DIRECTION); Integer con = values.getAsInteger(BluetoothShare.USER_CONFIRMATION); String address = values.getAsString(BluetoothShare.DESTINATION); if (values.getAsInteger(BluetoothShare.DIRECTION) == null) { dir = BluetoothShare.DIRECTION_OUTBOUND; Loading Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppBatch.java +0 −19 Original line number Diff line number Diff line Loading @@ -129,25 +129,6 @@ public class BluetoothOppBatch { } } /** * Delete one share from the batch. Not used now. */ /*It should only be called under requirement that cancel one single share, but not to * cancel the whole batch. Currently we assume "cancel" is to cancel whole batch. */ public void deleteShare(BluetoothOppShareInfo info) { if (info.mStatus == BluetoothShare.STATUS_RUNNING) { info.mStatus = BluetoothShare.STATUS_CANCELED; if (info.mDirection == BluetoothShare.DIRECTION_INBOUND && info.mFilename != null) { new File(info.mFilename).delete(); } } if (mListener != null) { mListener.onShareDeleted(info.mId); } } /** * Cancel the whole batch. */ Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppHandoverReceiver.java +7 −9 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import java.util.ArrayList; public class BluetoothOppHandoverReceiver extends BroadcastReceiver { public static final String TAG ="BluetoothOppHandoverReceiver"; private static final boolean D = Constants.DEBUG; private static final boolean V = Constants.VERBOSE; @Override public void onReceive(Context context, Intent intent) { Loading @@ -36,15 +35,14 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver { if (action.equals(Constants.ACTION_HANDOVER_SEND) || action.equals(Constants.ACTION_HANDOVER_SEND_MULTIPLE)) { BluetoothDevice device = final BluetoothDevice device = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (device == null) { if (D) Log.d(TAG, "No device attached to handover intent."); return; } String mimeType = intent.getType(); final String mimeType = intent.getType(); ArrayList<Uri> uris = new ArrayList<Uri>(); if (action.equals(Constants.ACTION_HANDOVER_SEND)) { Uri stream = (Uri)intent.getParcelableExtra(Intent.EXTRA_STREAM); Loading @@ -54,13 +52,13 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver { } if (mimeType != null && uris != null && !uris.isEmpty()) { final String finalType = mimeType; final Context finalContext = context; final ArrayList<Uri> finalUris = uris; Thread t = new Thread(new Runnable() { public void run() { BluetoothOppManager.getInstance(context).saveSendingFileInfo(finalType, finalUris, true); BluetoothOppManager.getInstance(context).startTransfer(device); BluetoothOppManager.getInstance(finalContext) .saveSendingFileInfo(mimeType, finalUris, true); BluetoothOppManager.getInstance(finalContext).startTransfer(device); } }); t.start(); Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java +9 −8 Original line number Diff line number Diff line Loading @@ -215,15 +215,15 @@ public class BluetoothOppLauncherActivity extends Activity { final ContentResolver resolver = this.getContentResolver(); // Check if airplane mode is on final boolean isAirplaneModeOn = Settings.System.getInt(resolver, Settings.System.AIRPLANE_MODE_ON, 0) == 1; final boolean isAirplaneModeOn = Settings.System.getInt(resolver, Settings.Global.AIRPLANE_MODE_ON, 0) == 1; if (!isAirplaneModeOn) { return true; } // Check if airplane mode matters final String airplaneModeRadios = Settings.System.getString(resolver, Settings.System.AIRPLANE_MODE_RADIOS); final String airplaneModeRadios = Settings.System.getString(resolver, Settings.Global.AIRPLANE_MODE_RADIOS); final boolean isAirplaneSensitive = airplaneModeRadios == null ? true : airplaneModeRadios.contains(Settings.System.RADIO_BLUETOOTH); if (!isAirplaneSensitive) { Loading @@ -231,10 +231,11 @@ public class BluetoothOppLauncherActivity extends Activity { } // Check if Bluetooth may be enabled in airplane mode final String airplaneModeToggleableRadios = Settings.System.getString(resolver, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS); final boolean isAirplaneToggleable = airplaneModeToggleableRadios == null ? false : airplaneModeToggleableRadios.contains(Settings.System.RADIO_BLUETOOTH); final String airplaneModeToggleableRadios = Settings.System.getString( resolver, Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS); final boolean isAirplaneToggleable = airplaneModeToggleableRadios == null ? false : airplaneModeToggleableRadios.contains(Settings.Global.RADIO_BLUETOOTH); if (isAirplaneToggleable) { return true; } Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +62 −41 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ package com.android.bluetooth.opp; import com.android.bluetooth.R; import android.content.ContentResolver; import android.content.Context; import android.app.Notification; import android.app.Notification.Action; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; Loading Loading @@ -105,6 +107,7 @@ class BluetoothOppNotification { private int mActiveNotificationId = 0; private ContentResolver mContentResolver = null; /** * This inner class is used to describe some properties for one transfer. */ Loading Loading @@ -137,6 +140,8 @@ class BluetoothOppNotification { mNotificationMgr = (NotificationManager)mContext .getSystemService(Context.NOTIFICATION_SERVICE); mNotifications = new HashMap<String, NotificationItem>(); // Get Content Resolver object one time mContentResolver = mContext.getContentResolver(); } /** Loading Loading @@ -212,8 +217,8 @@ class BluetoothOppNotification { private void updateActiveNotification() { // Active transfers Cursor cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, WHERE_RUNNING, null, BluetoothShare._ID); Cursor cursor = mContentResolver.query( BluetoothShare.CONTENT_URI, null, WHERE_RUNNING, null, BluetoothShare._ID); if (cursor == null) { return; } Loading Loading @@ -317,9 +322,10 @@ class BluetoothOppNotification { // TODO: split description into two rows with filename in second row Notification.Builder b = new Notification.Builder(mContext); b.setColor(mContext.getResources().getColor( com.android.internal.R.color.system_notification_accent_color)); com.android.internal.R.color.system_notification_accent_color, mContext.getTheme())); b.setContentTitle(item.description); b.setContentInfo( b.setSubText( BluetoothOppUtility.formatProgressText(item.totalTotal, item.totalCurrent)); if (item.totalTotal != 0) { if (V) Log.v(TAG, "mCurrentBytes: " + item.totalCurrent + Loading @@ -345,7 +351,7 @@ class BluetoothOppNotification { intent.setDataAndNormalize(Uri.parse(BluetoothShare.CONTENT_URI + "/" + item.id)); b.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent, 0)); mNotificationMgr.notify(item.id, b.getNotification()); mNotificationMgr.notify(item.id, b.build()); mActiveNotificationId = item.id; } Loading Loading @@ -377,7 +383,7 @@ class BluetoothOppNotification { } // Creating outbound notification Cursor cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, Cursor cursor = mContentResolver.query(BluetoothShare.CONTENT_URI, null, WHERE_COMPLETED_OUTBOUND, null, BluetoothShare.TIMESTAMP + " DESC"); if (cursor == null) { return; Loading Loading @@ -436,8 +442,8 @@ class BluetoothOppNotification { } // Creating inbound notification cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, WHERE_COMPLETED_INBOUND, null, BluetoothShare.TIMESTAMP + " DESC"); cursor = mContentResolver.query(BluetoothShare.CONTENT_URI, null, WHERE_COMPLETED_INBOUND, null, BluetoothShare.TIMESTAMP + " DESC"); if (cursor == null) { return; } Loading Loading @@ -493,8 +499,8 @@ class BluetoothOppNotification { } private void updateIncomingFileConfirmNotification() { Cursor cursor = mContext.getContentResolver().query(BluetoothShare.CONTENT_URI, null, WHERE_CONFIRM_PENDING, null, BluetoothShare._ID); Cursor cursor = mContentResolver.query( BluetoothShare.CONTENT_URI, null, WHERE_CONFIRM_PENDING, null, BluetoothShare._ID); if (cursor == null) { return; Loading @@ -506,29 +512,44 @@ class BluetoothOppNotification { Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + info.mID); Intent baseIntent = new Intent().setDataAndNormalize(contentUri) .setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); Notification n = new Notification.Builder(mContext) Notification.Action actionDecline = new Notification.Action .Builder(R.drawable.ic_decline, mContext.getText(R.string.incoming_file_confirm_cancel), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent) .setAction(Constants.ACTION_DECLINE), 0)) .build(); Notification.Action actionAccept = new Notification.Action .Builder(R.drawable.ic_accept, mContext.getText(R.string.incoming_file_confirm_ok), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_ACCEPT), 0)) .build(); Notification n = new Notification.Builder(mContext) .setOnlyAlertOnce(true) .setOngoing(true) .setVibrate(new long[] {200}) .setWhen(info.mTimeStamp) .setDefaults(Notification.DEFAULT_SOUND) .setPriority(Notification.PRIORITY_HIGH) .addAction(R.drawable.ic_decline, mContext.getText(R.string.incoming_file_confirm_cancel), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_DECLINE), 0)) .addAction(R.drawable.ic_accept, mContext.getText(R.string.incoming_file_confirm_ok), PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_ACCEPT), 0)) .addAction(actionDecline) .addAction(actionAccept) .setContentIntent(PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_INCOMING_FILE_CONFIRM), 0)) new Intent(baseIntent) .setAction(Constants.ACTION_INCOMING_FILE_CONFIRM), 0)) .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0, new Intent(baseIntent).setAction(Constants.ACTION_HIDE), 0)) .setColor(mContext.getResources().getColor( com.android.internal.R.color.system_notification_accent_color)) .setContentTitle(mContext.getText(R.string.incoming_file_confirm_Notification_title)) com.android.internal.R.color.system_notification_accent_color, mContext.getTheme())) .setContentTitle(mContext.getText( R.string.incoming_file_confirm_Notification_title)) .setContentText(info.mFileName) .setStyle(new Notification.BigTextStyle().bigText(mContext.getString( R.string.incoming_file_confirm_Notification_content, Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppProvider.java +0 −1 Original line number Diff line number Diff line Loading @@ -240,7 +240,6 @@ public final class BluetoothOppProvider extends ContentProvider { } Integer dir = values.getAsInteger(BluetoothShare.DIRECTION); Integer con = values.getAsInteger(BluetoothShare.USER_CONFIRMATION); String address = values.getAsString(BluetoothShare.DESTINATION); if (values.getAsInteger(BluetoothShare.DIRECTION) == null) { dir = BluetoothShare.DIRECTION_OUTBOUND; Loading