Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37dcae47 authored by Isaac Katzenelson's avatar Isaac Katzenelson
Browse files

Boiler plate code for SET_TIMER intent support

Bug: 7497400
Change-Id: Id0aa03a3604ce5e48b5e99a9dc07eaf7f917adb8
parent efc4ad3b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@
            </intent-filter>
        </receiver>

        <activity android:name="HandleSetAlarm"
        <activity android:name="HandleApiCalls"
                android:theme="@android:style/Theme.NoDisplay"
                android:excludeFromRecents="true"
                android:permission="com.android.alarm.permission.SET_ALARM">
@@ -115,8 +115,17 @@
                <action android:name="android.intent.action.SET_ALARM" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SET_TIMER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity-alias android:name="HandleSetAlarm"
            android:targetActivity=".HandleApiCalls"
            android:exported="true">
        </activity-alias>

        <!-- This service receives the same intent as AlarmReceiver but it does
             not respond to the same broadcast. The AlarmReceiver will receive
             the alert broadcast and will start this service with the same
+29 −6
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.deskclock;

import static android.provider.AlarmClock.ACTION_SET_ALARM;
import static android.provider.AlarmClock.ACTION_SET_TIMER;
import static android.provider.AlarmClock.EXTRA_HOUR;
import static android.provider.AlarmClock.EXTRA_MESSAGE;
import static android.provider.AlarmClock.EXTRA_MINUTES;
@@ -24,6 +25,7 @@ import static android.provider.AlarmClock.EXTRA_SKIP_UI;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
@@ -33,16 +35,33 @@ import com.android.deskclock.provider.Alarm;

import java.util.Calendar;

public class HandleSetAlarm extends Activity {
public class HandleApiCalls extends Activity {

    @Override
    protected void onCreate(Bundle icicle) {
        try {
            super.onCreate(icicle);
            Intent intent = getIntent();
        if (intent == null || !ACTION_SET_ALARM.equals(intent.getAction())) {
            if (intent != null) {
                if (ACTION_SET_ALARM.equals(intent.getAction())) {
                    handleSetAlarm(intent);
                } else if (ACTION_SET_TIMER.equals(intent.getAction())) {
                    handleSetTimer(intent);
                }
            }
        } finally {
            finish();
            return;
        } else if (!intent.hasExtra(EXTRA_HOUR)) {
        }
    }

    /***
     * Processes the SET_ALARM intent
     * @param intent
     */
    private void handleSetAlarm(Intent intent) {

        // Intent has no time , open the alarm creation UI
        if (!intent.hasExtra(EXTRA_HOUR)) {
            Intent createAlarm = new Intent(this, DeskClock.class);
            createAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            createAlarm.putExtra(Alarms.ALARM_CREATE_NEW, true);
@@ -103,6 +122,10 @@ public class HandleSetAlarm extends Activity {
        finish();
    }

    private void handleSetTimer(Intent intent) {

    }

    private boolean handleCursorResult(Cursor c, boolean enable, boolean skipUi) {
        if (c != null && c.moveToFirst()) {
            Alarm alarm = new Alarm(c);