Skip to content

Commit 6931259

Browse files
committed
fix do not disturb bug
1 parent 95016eb commit 6931259

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

android/src/main/java/com/ninty/system/setting/SystemSetting.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,19 @@ public void setVolume(float val, ReadableMap config) {
298298
} catch (SecurityException e) {
299299
if (val == 0) {
300300
Log.w(TAG, "setVolume(0) failed. See https://github.com/c19354837/react-native-system-setting/issues/48");
301-
NotificationManager notificationManager =
302-
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
303-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
304-
&& !notificationManager.isNotificationPolicyAccessGranted()) {
305-
Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
306-
mContext.startActivity(intent);
301+
try {
302+
am.setStreamVolume(volType, (int) (0.1 * am.getStreamMaxVolume(volType)), flags);
303+
Log.w(TAG, "setVolume(0.1)");
304+
} catch (Exception ex) {
305+
Log.e(TAG, "err setting volume to 0.1", ex);
307306
}
307+
// NotificationManager notificationManager =
308+
// (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
309+
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
310+
// && !notificationManager.isNotificationPolicyAccessGranted()) {
311+
// Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
312+
// mContext.startActivity(intent);
313+
// }
308314
}
309315
Log.e(TAG, "err", e);
310316
}

0 commit comments

Comments
 (0)