Fix sending SMS in Android 8
This commit is contained in:
parent
c7ab2ae476
commit
abb1dd956c
5 changed files with 15 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
||||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_MMS" />
|
<uses-permission android:name="android.permission.RECEIVE_MMS" />
|
||||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
<uses-permission android:name="android.permission.SEND_MMS" />
|
<uses-permission android:name="android.permission.SEND_MMS" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
|
@ -326,6 +326,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
case AndroidPermission.CASE_LOCATION:
|
case AndroidPermission.CASE_LOCATION:
|
||||||
case AndroidPermission.CASE_SMS:
|
case AndroidPermission.CASE_SMS:
|
||||||
case AndroidPermission.CASE_BATTERY:
|
case AndroidPermission.CASE_BATTERY:
|
||||||
|
case AndroidPermission.CASE_PHONESTATE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class Notification {
|
||||||
public static final int DEVICENOTPAIRED = 43;
|
public static final int DEVICENOTPAIRED = 43;
|
||||||
public static final int MEDTRONIC_PUMP_ALARM = 44;
|
public static final int MEDTRONIC_PUMP_ALARM = 44;
|
||||||
public static final int RILEYLINK_CONNECTION = 45;
|
public static final int RILEYLINK_CONNECTION = 45;
|
||||||
|
public static final int PERMISSION_PHONESTATE = 46;
|
||||||
|
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class AndroidPermission {
|
||||||
public static final int CASE_SMS = 0x2;
|
public static final int CASE_SMS = 0x2;
|
||||||
public static final int CASE_LOCATION = 0x3;
|
public static final int CASE_LOCATION = 0x3;
|
||||||
public static final int CASE_BATTERY = 0x4;
|
public static final int CASE_BATTERY = 0x4;
|
||||||
|
public static final int CASE_PHONESTATE = 0x5;
|
||||||
|
|
||||||
public static void askForPermission(Activity activity, String[] permission, Integer requestCode) {
|
public static void askForPermission(Activity activity, String[] permission, Integer requestCode) {
|
||||||
boolean test = false;
|
boolean test = false;
|
||||||
|
@ -55,6 +56,16 @@ public class AndroidPermission {
|
||||||
} else
|
} else
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.PERMISSION_SMS));
|
MainApp.bus().post(new EventDismissNotification(Notification.PERMISSION_SMS));
|
||||||
}
|
}
|
||||||
|
// Following is a bug in Android 8
|
||||||
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O) {
|
||||||
|
if (!checkForPermission(activity, Manifest.permission.READ_PHONE_STATE)) {
|
||||||
|
NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_PHONESTATE, MainApp.gs(R.string.smscommunicator_missingphonestatepermission), Notification.URGENT);
|
||||||
|
notification.action(MainApp.gs(R.string.request), () ->
|
||||||
|
AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.READ_PHONE_STATE}, AndroidPermission.CASE_PHONESTATE));
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
} else
|
||||||
|
MainApp.bus().post(new EventDismissNotification(Notification.PERMISSION_PHONESTATE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -610,6 +610,7 @@
|
||||||
<string name="danar_bluetooth_status">Bluetooth status</string>
|
<string name="danar_bluetooth_status">Bluetooth status</string>
|
||||||
<string name="nav_about">About</string>
|
<string name="nav_about">About</string>
|
||||||
<string name="smscommunicator_missingsmspermission">Missing SMS permission</string>
|
<string name="smscommunicator_missingsmspermission">Missing SMS permission</string>
|
||||||
|
<string name="smscommunicator_missingphonestatepermission">Missing phone state permission</string>
|
||||||
<string name="xdripstatus_settings">xDrip Status (watch)</string>
|
<string name="xdripstatus_settings">xDrip Status (watch)</string>
|
||||||
<string name="xdripstatus">xDrip Statusline (watch)</string>
|
<string name="xdripstatus">xDrip Statusline (watch)</string>
|
||||||
<string name="xdripstatus_shortname">xds</string>
|
<string name="xdripstatus_shortname">xds</string>
|
||||||
|
|
Loading…
Reference in a new issue