diff options
author | Steve Kondik <steve@cyngn.com> | 2015-10-31 14:10:08 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-31 14:10:08 -0700 |
commit | 669378075a5d60deef97eb3418e168b70c71f402 (patch) | |
tree | 1d75d03ada3972c996ca67807eae653945ff1e9a | |
parent | 2fa3771a508f6a16e54d4276fa27273bb0b18367 (diff) | |
parent | 21a3e3da140c644d7f4ef7743749f23dc63bb217 (diff) | |
download | android_packages_apps_BluetoothExt-669378075a5d60deef97eb3418e168b70c71f402.tar.gz android_packages_apps_BluetoothExt-669378075a5d60deef97eb3418e168b70c71f402.tar.bz2 android_packages_apps_BluetoothExt-669378075a5d60deef97eb3418e168b70c71f402.zip |
Merge branch 'LA.BF.1.1.3_rb1.3' of git://codeaurora.org/platform/vendor/qcom-opensource/bluetooth into cm-13.0
4 files changed, 105 insertions, 48 deletions
diff --git a/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Main.java b/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Main.java index 25c3397..6ab5069 100644 --- a/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Main.java +++ b/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Main.java @@ -46,6 +46,10 @@ import android.view.MenuItem; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; +import android.util.Log; +import android.Manifest; +import android.content.pm.PackageManager; +import android.os.Build; public class Main extends Activity{ @@ -53,11 +57,39 @@ public class Main extends Activity{ public static int log_file_size = 100; public static LinearLayout lv; public static int size_pos = 0; + private static int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; + public static boolean mHasCriticalPermissions = true; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); + checkPermissions(); finish(); } + private void checkPermissions() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + Log.v(TAG, "not running on M, skipping permission checks" + Build.VERSION.SDK_INT); + return; + } + if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); + } else { + Log.d(Main.TAG,"Permission Already granted."); + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + if (MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE == requestCode) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + mHasCriticalPermissions = true; + Log.d(Main.TAG,"Permission granted"); + } else { + mHasCriticalPermissions = false; + Log.d(Main.TAG,"Permission not granted"); + } + } + } + } diff --git a/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Utils.java b/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Utils.java index c5bcb02..c763871 100644 --- a/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Utils.java +++ b/BTLogSave/src/org/codeaurora/bluetooth/btlogsave/Utils.java @@ -65,7 +65,10 @@ import java.lang.Runnable; public class Utils{ static { - new File("/sdcard/BtLogKit").mkdir(); + if (Main.mHasCriticalPermissions) + new File("/sdcard/BtLogKit").mkdir(); + else + Log.d(Main.TAG,"Don't have sdcard permission."); } private static Process process_logcat_start,process_logcat_clear,process_logcat_move; diff --git a/QLogging/src/com/android/qlogging/BTStateReceiver.java b/QLogging/src/com/android/qlogging/BTStateReceiver.java index 8267172..e2edf92 100644 --- a/QLogging/src/com/android/qlogging/BTStateReceiver.java +++ b/QLogging/src/com/android/qlogging/BTStateReceiver.java @@ -87,70 +87,76 @@ public class BTStateReceiver extends BroadcastReceiver{ case BluetoothAdapter.STATE_TURNING_OFF: break; case BluetoothAdapter.STATE_ON: + File file_global = new File(context.getFilesDir(), "GlobalSettings.xml"); + File file_stack = new File(context.getFilesDir(), "StackSettings.xml"); + File file_soc = new File(context.getFilesDir(), "StackSettings.xml"); Map map; int counter = 0; - bt_soc_type = SystemProperties.get("qcom.bluetooth.soc"); - Utils.setGlobalSettings(context); String[] profile_tags = context.getResources().getStringArray(R.array.profile_list_tags); String[] stack_list_names = context.getResources().getStringArray(R.array.stack_list_names); String[] stack_list_tags = context.getResources().getStringArray(R.array.stack_list_tags); String[] soc_list_names = context.getResources().getStringArray(R.array.soc_list_names); String[] soc_list_tags = context.getResources().getStringArray(R.array.soc_list_tags); - map = Utils.getPreviousSettings(context, Main.STACK_MODULE_ID); - if (!map.isEmpty()) { - for (String stack : stack_list_names) { - Object state_obj = map.get(stack); - if (state_obj != null) { - String state = state_obj.toString(); - int presState = Character.getNumericValue(state.charAt(2)); - sendIntent.transmitIntent(context, presState, stack_list_tags[counter], Main.STACK_MODULE_ID); - counter++; - } - } - } - else - Log.d(Main.TAG,"Map empty for Stack"+ bt_soc_type); - - map = Utils.getPreviousSettings(context, Main.SOC_MODULE_ID); - if (!Main.soc_log_enabled) - { - if (bt_soc_type.equals(mRome)) - Log.d(Main.TAG,"soc type is rome dont enable SOC logging"); - else - { - sendIntent.transmitIntent(context, 0, "F", Main.SOC_ALL_MODULE_ID); - Log.d(Main.TAG,"soc type is not rome enable SOC logging"); - } - } - else - { - getSecondoryOptions.SOC_levels=""; - counter = 0; - if (!map.isEmpty()) - { - for (String soc : soc_list_names) - { - Object state_obj = map.get(soc); - if (state_obj != null) - { + bt_soc_type = SystemProperties.get("qcom.bluetooth.soc"); + if (file_global.exists()) { + Utils.setGlobalSettings(context); + } else if (file_stack.exists()) { + map = Utils.getPreviousSettings(context, Main.STACK_MODULE_ID); + if (!map.isEmpty()) { + for (String stack : stack_list_names) { + Object state_obj = map.get(stack); + if (state_obj != null) { String state = state_obj.toString(); int presState = Character.getNumericValue(state.charAt(2)); - getSecondoryOptions.SOC_levels+=String.valueOf(presState); + sendIntent.transmitIntent(context, presState, stack_list_tags[counter], Main.STACK_MODULE_ID); counter++; - }else{ - getSecondoryOptions.SOC_levels+=String.valueOf(0); } } + } + } else if (file_soc.exists()) { + map = Utils.getPreviousSettings(context, Main.SOC_MODULE_ID); + if (!Main.soc_log_enabled) + { if (bt_soc_type.equals(mRome)) Log.d(Main.TAG,"soc type is rome dont enable SOC logging"); else { + sendIntent.transmitIntent(context, 0, "F", Main.SOC_ALL_MODULE_ID); Log.d(Main.TAG,"soc type is not rome enable SOC logging"); - sendIntent.transmitIntent(context, Main.SOC_ALL_MODULE_ID, getSecondoryOptions.SOC_levels, Main.SOC_ALL_MODULE_ID); } } else - Log.d(Main.TAG,"Map empty for SOC"); + { + getSecondoryOptions.SOC_levels=""; + counter = 0; + if (!map.isEmpty()) + { + for (String soc : soc_list_names) + { + Object state_obj = map.get(soc); + if (state_obj != null) + { + String state = state_obj.toString(); + int presState = Character.getNumericValue(state.charAt(2)); + getSecondoryOptions.SOC_levels+=String.valueOf(presState); + counter++; + }else{ + getSecondoryOptions.SOC_levels+=String.valueOf(0); + } + } + if (bt_soc_type.equals(mRome)) + Log.d(Main.TAG,"soc type is rome dont enable SOC logging"); + else + { + Log.d(Main.TAG,"soc type is not rome enable SOC logging"); + sendIntent.transmitIntent(context, Main.SOC_ALL_MODULE_ID, getSecondoryOptions.SOC_levels, Main.SOC_ALL_MODULE_ID); + } + } + else + Log.d(Main.TAG,"Map empty for SOC"); + } + } else { + Log.d(Main.TAG,"File not yet created."); } break; case BluetoothAdapter.STATE_TURNING_ON: diff --git a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java index b602eec..11935c6 100644 --- a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java +++ b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java @@ -63,6 +63,8 @@ import javax.obex.Operation; import javax.obex.HeaderSet; import javax.obex.ObexHelper; import android.os.Environment; +import android.os.storage.StorageManager; +import android.os.storage.StorageVolume; public class BluetoothFtpObexServer extends ServerRequestHandler { @@ -109,6 +111,7 @@ public class BluetoothFtpObexServer extends ServerRequestHandler { public static final String ENV_SECONDARY_EXTERNAL_STORAGE = "SECONDARY_STORAGE"; private String rootPrimaryStoragePath = null; private String rootSecondaryStoragePath = null; + private StorageManager mStorageManager; public static final String PRIMARY_INTERNAL_FOLDERNAME = "PHONE_MEMORY"; public static final String SECONDARY_EXTERNAL_FOLDERNAME = "EXTERNAL_MEMORY"; private static final String FOLDER_NAME_DOT = "."; @@ -209,9 +212,22 @@ public class BluetoothFtpObexServer extends ServerRequestHandler { Message msg = Message.obtain(mCallback); msg.what = BluetoothFtpService.MSG_SESSION_ESTABLISHED; msg.sendToTarget(); - /*Initialize the internal, external storage root paths from Enivronment*/ - rootPrimaryStoragePath = Environment.getExternalStorageDirectory().getPath(); - rootSecondaryStoragePath = System.getenv(ENV_SECONDARY_EXTERNAL_STORAGE); + mStorageManager = StorageManager.from(mContext); + StorageVolume[] volumes = mStorageManager.getVolumeList(); + for (int i = 0; i < volumes.length; i++) { + String path = volumes[i].getPath(); + if(V) Log.v(TAG, "Fetch storageManager volumeList : " + path + " :: isRemovable= " + + volumes[i].isRemovable() + ", getDescription= " + volumes[i] + .getDescription(mContext.getApplicationContext()) + " , isEmulated= " + + volumes[i].isEmulated()+ ", isPrimary=" + volumes[i].isPrimary()); + /*Initialize the internal, external storage root paths from Enivronment*/ + if ( rootPrimaryStoragePath == null && volumes[i].isPrimary()) { + rootPrimaryStoragePath = path; + } else if (rootSecondaryStoragePath == null && volumes[i].isRemovable()) { + //TODO: Support only first external SDCARD in list , in case of multiple + rootSecondaryStoragePath = path; + } + } /*Initialize mCurrentPath to null to show Internal and External memory options*/ mCurrentPath = null; if(D) Log.d(TAG,"ENV: PRIMARY: "+ rootPrimaryStoragePath + |