Loading android/app/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ LOCAL_CERTIFICATE := platform LOCAL_JNI_SHARED_LIBRARIES := libbluetooth_jni LOCAL_JAVA_LIBRARIES := javax.obex telephony-common libprotobuf-java-micro LOCAL_STATIC_JAVA_LIBRARIES := com.android.vcard bluetooth.mapsapi sap-api-java-static LOCAL_STATIC_JAVA_LIBRARIES := com.android.vcard bluetooth.mapsapi sap-api-java-static android-support-v4 LOCAL_REQUIRED_MODULES := bluetooth.default LOCAL_MULTILIB := 32 Loading android/app/AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ <uses-permission android:name="android.permission.BLUETOOTH_MAP" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- WRITE_CONTACTS is used for test cases only --> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> Loading Loading @@ -80,6 +81,14 @@ android:pathPrefix="/btopp" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" /> </provider> <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.google.android.bluetooth.fileprovider" android:grantUriPermissions="true" android:exported="false"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider> <service android:process="@string/process" android:name = ".btservice.AdapterService"> Loading android/app/res/xml/file_paths.xml 0 → 100644 +3 −0 Original line number Diff line number Diff line <paths xmlns:android="https://schemas.android.com/apk/res/android"> <external-path name="bluetooth" path="/" /> </paths> android/app/src/com/android/bluetooth/opp/BluetoothOppUtility.java +18 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import android.support.v4.content.FileProvider; /** * This class has some utilities for Opp application; */ Loading Loading @@ -186,7 +187,8 @@ public class BluetoothOppUtility { return; } Uri path = Uri.parse(fileName); Uri path = FileProvider.getUriForFile(context, "com.google.android.bluetooth.fileprovider", f); // If there is no scheme, then it must be a file if (path.getScheme() == null) { path = Uri.fromFile(new File(fileName)); Loading @@ -196,7 +198,22 @@ public class BluetoothOppUtility { Intent activityIntent = new Intent(Intent.ACTION_VIEW); activityIntent.setDataAndTypeAndNormalize(path, mimetype); List<ResolveInfo> resInfoList = context.getPackageManager() .queryIntentActivities(activityIntent, PackageManager.MATCH_DEFAULT_ONLY); // Grant permissions for any app that can handle a file to access it for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, path, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); activityIntent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); try { if (V) Log.d(TAG, "ACTION_VIEW intent sent out: " + path + " / " + mimetype); context.startActivity(activityIntent); Loading Loading
android/app/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ LOCAL_CERTIFICATE := platform LOCAL_JNI_SHARED_LIBRARIES := libbluetooth_jni LOCAL_JAVA_LIBRARIES := javax.obex telephony-common libprotobuf-java-micro LOCAL_STATIC_JAVA_LIBRARIES := com.android.vcard bluetooth.mapsapi sap-api-java-static LOCAL_STATIC_JAVA_LIBRARIES := com.android.vcard bluetooth.mapsapi sap-api-java-static android-support-v4 LOCAL_REQUIRED_MODULES := bluetooth.default LOCAL_MULTILIB := 32 Loading
android/app/AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ <uses-permission android:name="android.permission.BLUETOOTH_MAP" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- WRITE_CONTACTS is used for test cases only --> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> Loading Loading @@ -80,6 +81,14 @@ android:pathPrefix="/btopp" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" /> </provider> <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.google.android.bluetooth.fileprovider" android:grantUriPermissions="true" android:exported="false"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider> <service android:process="@string/process" android:name = ".btservice.AdapterService"> Loading
android/app/res/xml/file_paths.xml 0 → 100644 +3 −0 Original line number Diff line number Diff line <paths xmlns:android="https://schemas.android.com/apk/res/android"> <external-path name="bluetooth" path="/" /> </paths>
android/app/src/com/android/bluetooth/opp/BluetoothOppUtility.java +18 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import android.support.v4.content.FileProvider; /** * This class has some utilities for Opp application; */ Loading Loading @@ -186,7 +187,8 @@ public class BluetoothOppUtility { return; } Uri path = Uri.parse(fileName); Uri path = FileProvider.getUriForFile(context, "com.google.android.bluetooth.fileprovider", f); // If there is no scheme, then it must be a file if (path.getScheme() == null) { path = Uri.fromFile(new File(fileName)); Loading @@ -196,7 +198,22 @@ public class BluetoothOppUtility { Intent activityIntent = new Intent(Intent.ACTION_VIEW); activityIntent.setDataAndTypeAndNormalize(path, mimetype); List<ResolveInfo> resInfoList = context.getPackageManager() .queryIntentActivities(activityIntent, PackageManager.MATCH_DEFAULT_ONLY); // Grant permissions for any app that can handle a file to access it for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, path, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); activityIntent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); try { if (V) Log.d(TAG, "ACTION_VIEW intent sent out: " + path + " / " + mimetype); context.startActivity(activityIntent); Loading