diff --git a/mainActivity/src/main/AndroidManifest.xml b/mainActivity/src/main/AndroidManifest.xml index 4130a84..8ba9fcb 100644 --- a/mainActivity/src/main/AndroidManifest.xml +++ b/mainActivity/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="49"> diff --git a/mainActivity/src/main/java/com/sierrawireless/avphone/activity/MainActivity.kt b/mainActivity/src/main/java/com/sierrawireless/avphone/activity/MainActivity.kt index 2755e0c..901cc0f 100644 --- a/mainActivity/src/main/java/com/sierrawireless/avphone/activity/MainActivity.kt +++ b/mainActivity/src/main/java/com/sierrawireless/avphone/activity/MainActivity.kt @@ -245,7 +245,12 @@ class MainActivity : FragmentActivity(), LoginListener, AuthenticationManager, O if (grantResults[0] != PackageManager.PERMISSION_GRANTED) { Log.w(TAG, "onRequestPermissionsResult: READ_PHONE_STATE answer ko") - longToast("Permission not granted please grant permission") + + alert("Permission not granted. The application will exit now", "Alert") { + positiveButton("OK") { + finish() + } + }.show() } else { Log.d(TAG, " for READ PHONE STATE ok") if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { @@ -264,7 +269,11 @@ class MainActivity : FragmentActivity(), LoginListener, AuthenticationManager, O if (grantResults[0] != PackageManager.PERMISSION_GRANTED) { Log.w(TAG, "onRequestPermissionsResult: ACCESS_COARSE_LOCATION answer ko") - longToast("Permission not granted please grant permission") + alert("Permission not granted. The application will exit now", "Alert") { + positiveButton("OK") { + finish() + } + }.show() } else { Log.d(TAG, " for COARSE LOCATION ok") if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED ) { @@ -279,7 +288,11 @@ class MainActivity : FragmentActivity(), LoginListener, AuthenticationManager, O if (grantResults[0] != PackageManager.PERMISSION_GRANTED) { Log.w(TAG, "onRequestPermissionsResult: answer ACCESS_FINE_LOCATION ko") - longToast("Permission not granted please grant permission") + alert("Permission not granted. The application will exit now", "Alert") { + positiveButton("OK") { + finish() + } + }.show() }else{ Log.d(TAG, "for FINE LOCATION STATE ok") } @@ -330,7 +343,7 @@ class MainActivity : FragmentActivity(), LoginListener, AuthenticationManager, O } override fun onResume() { - Log.d(TAG, "OnResume Called") + super.onResume() left_drawer.requestFocusFromTouch() left_drawer.setItemChecked(lastPosition, true) diff --git a/mainActivity/src/main/java/com/sierrawireless/avphone/tools/DeviceInfo.kt b/mainActivity/src/main/java/com/sierrawireless/avphone/tools/DeviceInfo.kt index 6548f4e..044b18a 100644 --- a/mainActivity/src/main/java/com/sierrawireless/avphone/tools/DeviceInfo.kt +++ b/mainActivity/src/main/java/com/sierrawireless/avphone/tools/DeviceInfo.kt @@ -7,6 +7,7 @@ import android.telephony.SubscriptionManager import android.telephony.TelephonyManager import android.text.TextUtils import com.sierrawireless.avphone.activity.MainActivity +import org.jetbrains.anko.toast object DeviceInfo { @@ -67,23 +68,40 @@ object DeviceInfo { fun getIMEI(context: Context): String? { val telManager: TelephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager - return if (telManager.phoneType == TelephonyManager.PHONE_TYPE_GSM) { - @Suppress("DEPRECATION") - telManager.deviceId - } else null + var rc:String? = null + try { + rc = if (telManager.phoneType == TelephonyManager.PHONE_TYPE_GSM) { + @Suppress("DEPRECATION") + telManager.deviceId + } else null + }catch(e:SecurityException) { + MainActivity.instance.runOnUiThread { + MainActivity.instance.toast("Read Phone Permission not given") + } + } + return rc } fun getICCID(context: Context): String { val sm = SubscriptionManager.from(context) val sis = sm.activeSubscriptionInfoList - return if (sis != null) { - val si = sis[0] - si.iccId - }else{ - "" + var rc = "" + try { + rc = if (sis != null) { + val si = sis[0] + si.iccId + } else { + "" + } + }catch(e:SecurityException) { + MainActivity.instance.runOnUiThread { + MainActivity.instance.toast("Read Phone Permission not given") + } } + return rc + } }