Commit 6769b59d authored by Tao Liejun's avatar Tao Liejun Committed by Nick Pelly
Browse files

Make opp compile

Modify to make opp application compliable in new git
-change package name
-change manifest
-modify a few comments
parent 09e9cba2
......@@ -5,7 +5,7 @@ LOCAL_MODULE_TAGS := eng development
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := BluetoothOpp
LOCAL_PACKAGE_NAME := Bluetooth
LOCAL_JAVA_LIBRARIES := javax.obex
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.bluetooth.opp" >
package="com.android.bluetooth" >
<!-- Allows access to the Bluetooth Share Manager -->
<permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE"
android:label="@string/permlab_bluetoothShareManager"
......@@ -16,18 +16,18 @@
<application android:icon="@drawable/stat_sys_data_bt"
android:label="@string/app_name">
<uses-library android:name="javax.obex" />
<provider android:name=".BluetoothOppProvider"
<provider android:name=".opp.BluetoothOppProvider"
android:authorities="com.android.bluetooth.opp"
android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" />
<service android:name=".BluetoothOppService"
<service android:name=".opp.BluetoothOppService"
android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" />
<receiver android:name=".BluetoothOppReceiver">
<receiver android:name=".opp.BluetoothOppReceiver">
<intent-filter>
<action android:name="android.bluetooth.intent.action.BLUETOOTH_STATE_CHANGED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name="BluetoothOppLauncherActivity"
<activity android:name=".opp.BluetoothOppLauncherActivity"
android:theme="@android:style/Theme.Dialog" android:label="@string/bt_share_picker_label">
<intent-filter>
<action android:name="android.intent.action.SEND" />
......@@ -49,26 +49,26 @@
<data android:mimeType="vnd.android.cursor.item/vnd.android.btopp" />
</intent-filter>
</activity>
<activity android:name="BluetoothOppBtEnableActivity">
<activity android:name=".opp.BluetoothOppBtEnableActivity">
</activity>
<activity android:name="BluetoothOppBtErrorActivity">
<activity android:name=".opp.BluetoothOppBtErrorActivity">
</activity>
<activity android:name="BluetoothOppBtEnablingActivity">
<activity android:name=".opp.BluetoothOppBtEnablingActivity">
android:theme="@android:style/Theme.Dialog"> </activity>
<activity android:name="BluetoothOppIncomingFileConfirmActivity">
<activity android:name=".opp.BluetoothOppIncomingFileConfirmActivity">
</activity>
<activity android:name="BluetoothOppTransferActivity">
<activity android:name=".opp.BluetoothOppTransferActivity">
</activity>
<activity android:name="BluetoothDevicePickerActivity">
<activity android:name=".opp.BluetoothDevicePickerActivity">
</activity>
<activity android:name="BluetoothPinDialog" android:label="@string/bluetooth_pin_entry"
<activity android:name=".opp.BluetoothPinDialog" android:label="@string/bluetooth_pin_entry"
android:theme="@*android:style/Theme.Dialog.Alert">
<intent-filter>
<action android:name="android.bluetooth.intent.action.PAIRING_REQUEST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="BluetoothOppLiveFolder"
<activity android:name=".opp.BluetoothOppLiveFolder"
android:label="@string/btopp_live_folder">
<intent-filter>
<action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import java.util.List;
import java.util.WeakHashMap;
......@@ -39,8 +41,6 @@ import android.os.Bundle;
import android.util.Log;
import android.util.Config;
import android.content.Intent;
/* for device picker */
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
......@@ -131,7 +131,7 @@ public class BluetoothDevicePickerActivity extends PreferenceActivity implements
log("the device chosed is paired, send intent to OPP with the BT address and finish this activity.");
String BtAddress = btPreference.getDevice().getAddress();
Intent intent = new Intent(BluetoothShare.BLUETOOTH_DEVICE_SELECTED_ACTION);
intent.setClassName("com.android.bluetooth.opp", BluetoothOppReceiver.class
intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class
.getName());
intent.putExtra("BT_ADDRESS", BtAddress);
this.sendBroadcast(intent);
......@@ -174,9 +174,7 @@ public class BluetoothDevicePickerActivity extends PreferenceActivity implements
log("onBondingStateChanged");
if (created == true) {
Intent intent = new Intent(BluetoothShare.BLUETOOTH_DEVICE_SELECTED_ACTION);
intent
.setClassName("com.android.bluetooth.opp", BluetoothOppReceiver.class
.getName());
intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
intent.putExtra("BT_ADDRESS", address);
this.sendBroadcast(intent);
log("the device bond succeeded, send intent to OPP");
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
/**
* BluetoothDevicePickerBtStatus is a helper class that contains constants for
* various status codes.
......
......@@ -32,12 +32,14 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothClass;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothClass;
import com.android.bluetooth.opp.BluetoothDevicePickerManager.Callback;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.content.Context;
import android.preference.Preference;
import android.util.TypedValue;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.bluetooth.BluetoothDevice;
......
......@@ -81,14 +81,12 @@ public class BluetoothOppBatch {
public interface BluetoothOppBatchListener {
/**
* Called to notify when a share is added into the batch
*
* @param id , BluetoothOppShareInfo.id
*/
public void onShareAdded(int id);
/**
* Called to notify when a share is deleted from the batch
*
* @param id , BluetoothOppShareInfo.id
*/
public void onShareDeleted(int id);
......@@ -101,7 +99,6 @@ public class BluetoothOppBatch {
/**
* A batch is always created with at least one ShareInfo
*
* @param context, Context
* @param info, BluetoothOppShareInfo
*/
......@@ -196,7 +193,6 @@ public class BluetoothOppBatch {
/**
* Get the running status of the batch
*
* @return
*/
public boolean isRunning() {
......@@ -210,8 +206,8 @@ public class BluetoothOppBatch {
/**
* Get the first pending ShareInfo of the batch
*
* @return BluetoothOppShareInfo, for the first pending share, or null if none exists
* @return BluetoothOppShareInfo, for the first pending share, or null if
* none exists
*/
public BluetoothOppShareInfo getPendingShare() {
for (int i = 0; i < mShares.size(); i++) {
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
......@@ -42,8 +44,8 @@ import android.provider.Settings;
/**
* This class is designed to act as the entry point of handling the share intent
* via BT from other APPs. and also make "Bluetooth" available in sharing
* method selection dialog.
* via BT from other APPs. and also make "Bluetooth" available in sharing method
* selection dialog.
*/
public class BluetoothOppLauncherActivity extends Activity {
private static final String TAG = "BluetoothLauncherActivity";
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.util.Log;
import java.util.ArrayList;
import android.net.Uri;
......@@ -207,7 +209,6 @@ public class BluetoothOppManager {
/**
* Get the current status of Bluetooth hardware.
*
* @return true if Bluetooth enabled, false otherwise.
*/
public boolean isEnabled() {
......
......@@ -32,6 +32,8 @@
package com.android.bluetooth.opp;
import com.android.bluetooth.R;
import android.content.Context;
import android.app.Notification;
import android.app.NotificationManager;
......@@ -92,9 +94,7 @@ class BluetoothOppNotification {
/**
* Constructor
*
* @param ctx The context to use to obtain access to the Notification
* Service
* @param ctx The context to use to obtain access to the Notification Service
*/
BluetoothOppNotification(Context ctx) {
mContext = ctx;
......
......@@ -35,7 +35,6 @@ package com.android.bluetooth.opp;
import javax.obex.ClientOperation;
import javax.obex.ClientSession;
import javax.obex.HeaderSet;
import javax.obex.OBEXConstants;
import javax.obex.ObexTransport;
import javax.obex.ResponseCodes;
......@@ -119,13 +118,13 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
private class ClientThread extends Thread {
public ClientThread(Context context, ObexTransport transport) {
super("BtOpp ClientThread");
mContext = context;
mTransport = transport;
mContext1 = context;
mTransport1 = transport;
waitingForShare = true;
mWaitingForRemote = false;
}
private Context mContext;
private Context mContext1;
private BluetoothOppShareInfo mInfo;
......@@ -133,13 +132,13 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
private int mTimeoutRemainingMs = 500;
private ObexTransport mTransport;
private ObexTransport mTransport1;
private ClientSession mCs;
PowerManager.WakeLock wakeLock;
BluetoothOppSendFileInfo mFileInfo = null;
private BluetoothOppSendFileInfo mFileInfo = null;
public void addShare(BluetoothOppShareInfo info) {
mInfo = info;
......@@ -151,7 +150,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
PowerManager pm = (PowerManager)mContext1.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG);
wakeLock.acquire();
try {
......@@ -181,6 +180,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
}
}
disconnect();
if (wakeLock != null) {
wakeLock.release();
wakeLock = null;
......@@ -216,9 +216,9 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
} catch (IOException e) {
Log.e(TAG, "OBEX session close error" + e);
}
if (mTransport != null) {
if (mTransport1 != null) {
try {
mTransport.close();
mTransport1.close();
} catch (IOException e) {
Log.e(TAG, "mTransport.close error");
}
......@@ -229,28 +229,24 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
private void connect() {
if (Constants.LOGV) {
Log.v(TAG, "Create ClientSession with transport " + mTransport.toString());
Log.v(TAG, "Create ClientSession with transport " + mTransport1.toString());
}
try {
mCs = new ClientSession(mTransport1);
} catch (IOException e1) {
Log.e(TAG, "OBEX session create error");
}
mCs = new ClientSession(mTransport);
HeaderSet hs = mCs.createHeaderSet();
HeaderSet hs = new HeaderSet();
synchronized (this) {
mWaitingForRemote = true;
}
try {
if (Constants.LOGV) {
Log.v(TAG, "OBEX session trying to connect");
}
/**
* TODO There is bug for TCP socket when we want to interrupt
* connect
*/
mCs.connect(hs);
if (Constants.LOGV) {
Log.v(TAG, "OBEX session created");
}
} catch (IOException e) {
Log.e(TAG, "OBEX session create error");
Log.e(TAG, "OBEX session connect error");
}
synchronized (this) {
......@@ -302,12 +298,12 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
Log.v(TAG, "Client thread processShareInfo() " + mInfo.mId);
}
BluetoothOppSendFileInfo fileInfo = BluetoothOppSendFileInfo.generateFileInfo(mContext,
mInfo.mUri);
BluetoothOppSendFileInfo fileInfo = BluetoothOppSendFileInfo.generateFileInfo(
mContext1, mInfo.mUri);
if (fileInfo.mFileName == null) {
if (Constants.LOGVV) {
Log.v(TAG, "BluetoothOppSendFileInfo get null filename");
Constants.updateShareStatus(mContext, mInfo.mId, fileInfo.mStatus);
Constants.updateShareStatus(mContext1, mInfo.mId, fileInfo.mStatus);
}
} else {
......@@ -325,7 +321,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
updateValues.put(BluetoothShare.TOTAL_BYTES, fileInfo.mLength);
updateValues.put(BluetoothShare.MIMETYPE, fileInfo.mMimetype);
mContext.getContentResolver().update(contentUri, updateValues, null, null);
mContext1.getContentResolver().update(contentUri, updateValues, null, null);
}
return fileInfo;
......@@ -361,11 +357,11 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + mInfo.mId);
ContentValues updateValues;
HeaderSet request;
request = mCs.createHeaderSet();
request = new HeaderSet();
request.setHeader(HeaderSet.NAME, fileInfo.mFileName);
request.setHeader(HeaderSet.TYPE, fileInfo.mMimetype);
Constants.updateShareStatus(mContext, mInfo.mId, BluetoothShare.STATUS_RUNNING);
Constants.updateShareStatus(mContext1, mInfo.mId, BluetoothShare.STATUS_RUNNING);
request.setHeader(HeaderSet.LENGTH, fileInfo.mLength);
ClientOperation putOperation = null;
......@@ -382,7 +378,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
putOperation = (ClientOperation)mCs.put(request);
} catch (IOException e) {
status = BluetoothShare.STATUS_OBEX_DATA_ERROR;
Constants.updateShareStatus(mContext, mInfo.mId, status);
Constants.updateShareStatus(mContext1, mInfo.mId, status);
Log.e(TAG, "Error when put HeaderSet ");
error = true;
......@@ -400,7 +396,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
inputStream = putOperation.openInputStream();
} catch (IOException e) {
status = BluetoothShare.STATUS_OBEX_DATA_ERROR;
Constants.updateShareStatus(mContext, mInfo.mId, status);
Constants.updateShareStatus(mContext1, mInfo.mId, status);
Log.e(TAG, "Error when openOutputStream");
error = true;
}
......@@ -409,7 +405,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
updateValues = new ContentValues();
updateValues.put(BluetoothShare.CURRENT_BYTES, 0);
updateValues.put(BluetoothShare.STATUS, BluetoothShare.STATUS_RUNNING);
mContext.getContentResolver().update(contentUri, updateValues, null, null);
mContext1.getContentResolver().update(contentUri, updateValues, null, null);
}
if (!error) {
......@@ -447,7 +443,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
}
responseCode = putOperation.getResponseCode();
if (responseCode == OBEXConstants.OBEX_HTTP_CONTINUE
if (responseCode == ResponseCodes.OBEX_HTTP_CONTINUE
|| responseCode == ResponseCodes.OBEX_HTTP_OK) {
if (Constants.LOGVV) {
Log.v(TAG, "OK! Response code is " + responseCode);
......@@ -463,7 +459,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
if (Constants.LOGVV) {
Log.v(TAG, "Response code is " + responseCode);
}
if (responseCode != OBEXConstants.OBEX_HTTP_CONTINUE
if (responseCode != ResponseCodes.OBEX_HTTP_CONTINUE
&& responseCode != ResponseCodes.OBEX_HTTP_OK) {
/* abort happens */
break;
......@@ -490,14 +486,14 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
+ fileInfo.mFileName + " at " + position + " of "
+ position);
}
Constants.updateShareStatus(mContext, mInfo.mId, status);
Constants.updateShareStatus(mContext1, mInfo.mId, status);
}
}
}
updateValues = new ContentValues();
updateValues.put(BluetoothShare.CURRENT_BYTES, position);
mContext.getContentResolver().update(contentUri, updateValues, null, null);
mContext1.getContentResolver().update(contentUri, updateValues, null, null);
}
if (responseCode == ResponseCodes.OBEX_HTTP_FORBIDDEN) {
......@@ -532,7 +528,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
} catch (IOException e) {
status = BluetoothShare.STATUS_OBEX_DATA_ERROR;
Log.e(TAG, "Error when sending file");
Constants.updateShareStatus(mContext, mInfo.mId, status);
Constants.updateShareStatus(mContext1, mInfo.mId, status);
mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
} finally {
try {
......@@ -564,7 +560,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
}
}
Constants.updateShareStatus(mContext, mInfo.mId, status);
Constants.updateShareStatus(mContext1, mInfo.mId, status);
if (inputStream != null) {
inputStream.close();
......@@ -588,7 +584,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
Log.v(TAG, "Interrupted when waitingForRemote");
}
try {
mTransport.close();
mTransport1.close();
} catch (IOException e) {
Log.e(TAG, "mTransport.close error");
}
......
......@@ -124,8 +124,8 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
}
/**
* Called from BluetoothOppTransfer to cancel the "Transfer"
* Otherwise, server should end by itself.
* Called from BluetoothOppTransfer to cancel the "Transfer" Otherwise,
* server should end by itself.
*/
public void stop() {
/*
......@@ -175,7 +175,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
try {
boolean pre_reject = false;
request = op.getReceivedHeaders();
request = op.getReceivedHeader();
if (Constants.LOGVV) {
logHeader(request);
}
......@@ -319,7 +319,9 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
if (Constants.LOGV) {
Log.v(TAG, "Server unblocked ");
}
mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
if (mCallback != null) {
mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
}
/* we should have mInfo now */
......@@ -571,7 +573,6 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
msg.obj = mInfo;
msg.sendToTarget();
}
}
@Override
......
......@@ -40,9 +40,8 @@ import android.content.SharedPreferences.Editor;
import android.util.Log;
/**
* This class cache Bluetooth device name and channel locally
* Its a temp solution which should be replaced by bluetooth_devices in
* SettingsProvider
* This class cache Bluetooth device name and channel locally Its a temp
* solution which should be replaced by bluetooth_devices in SettingsProvider
*/
public class BluetoothOppPreference {
private static final String TAG = "BluetoothOppPreference";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment