Skip to content

Commit

Permalink
WIP: ExactAlarmChagedReceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Apr 19, 2024
1 parent c83269b commit fcd0646
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
7 changes: 7 additions & 0 deletions android-refimpl-app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<!--
<receiver android:name=".ExactAlarmChagedReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
</intent-filter>
</receiver>
-->
<receiver android:name=".PowerReceiver"
android:exported="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* [TRIfA], Java part of Tox Reference Implementation for Android
* Copyright (C) 2017 - 2020 Zoff <[email protected]>
* <p>
* 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.
* <p>
* 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.
* <p>
* 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());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fcd0646

Please sign in to comment.