diff --git a/android-refimpl-app/app/src/main/AndroidManifest.xml b/android-refimpl-app/app/src/main/AndroidManifest.xml index 6f985b092..34f6c058b 100644 --- a/android-refimpl-app/app/src/main/AndroidManifest.xml +++ b/android-refimpl-app/app/src/main/AndroidManifest.xml @@ -303,6 +303,13 @@ + diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ExactAlarmChagedReceiver.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ExactAlarmChagedReceiver.java new file mode 100644 index 000000000..37218b6dc --- /dev/null +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ExactAlarmChagedReceiver.java @@ -0,0 +1,67 @@ +/** + * [TRIfA], Java part of Tox Reference Implementation for Android + * Copyright (C) 2017 - 2020 Zoff + *

+ * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +package com.zoffcc.applications.trifa; + +import android.app.AlarmManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Build; +import android.preference.PreferenceManager; +import android.util.Log; + +import static android.content.Context.ALARM_SERVICE; + +public class ExactAlarmChagedReceiver extends BroadcastReceiver +{ + private static final String TAG = "trifa.ExAlrmRecvr"; + + @Override + public void onReceive(Context context, Intent intent) + { + Log.i(TAG, "-- ON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGE -- :000:" + intent.getAction()); + if (intent.getAction().equals("android.intent.action.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED")) + { + Log.i(TAG, "-- ON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGE -- :" + intent.getAction()); + try + { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + { + Log.i(TAG, "-- ON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGE -- :001"); + AlarmManager alarmManager = (AlarmManager)context.getSystemService(ALARM_SERVICE); + if (alarmManager.canScheduleExactAlarms()) + { + Log.i(TAG, "canScheduleExactAlarms:true"); + } + else + { + Log.i(TAG, "canScheduleExactAlarms:**FALSE**"); + } + } + Log.i(TAG, "-- ON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGE -- :099"); + } + catch (Exception e) + { + Log.i(TAG, "-- ON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGE -- :EE01:" + e.getMessage()); + } + } + } +} diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java index 5e34badc4..0f1b393d1 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java @@ -51,6 +51,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.os.PowerManager; import android.preference.PreferenceManager; import android.provider.Settings; import android.util.DisplayMetrics; @@ -638,6 +639,29 @@ protected void onCreate(Bundle savedInstanceState) return; } + /* + try + { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + { + ExactAlarmChagedReceiver ar = new ExactAlarmChagedReceiver(); + IntentFilter filter = new IntentFilter(); + filter.addAction("android.intent.action.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED"); + this.registerReceiver(ar, filter); + Log.i(TAG, "ExactAlarmChagedReceiver registered"); + } + else + { + Log.i(TAG, "ExactAlarmChagedReceiver:below API S"); + } + } + catch(Exception e22) + { + Log.i(TAG, "ExactAlarmChagedReceiver:EE:" + e22.getMessage()); + e22.printStackTrace(); + } + */ + Log.i(TAG, "M:STARTUP:toolbar"); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);