日期:2014-05-16 浏览次数:20780 次
/* * Copyright (C) 2011 The Rexsee Open Source Project * * Licensed under the Rexsee License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.rexsee.com/CN/legal/license.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rexsee.core.alarm; import rexsee.core.browser.JavascriptInterface; import rexsee.core.browser.RexseeBrowser; import rexsee.core.device.NotificationArgumentsSheet; import rexsee.core.device.RexseeNotification; import rexsee.core.receiver._Receiver; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class RexseeAlarm implements JavascriptInterface { private static final String INTERFACE_NAME = "Alarm"; @Override public String getInterfaceName() { return mBrowser.application.resources.prefix + INTERFACE_NAME; } @Override public JavascriptInterface getInheritInterface(RexseeBrowser childBrowser) { return this; } @Override public JavascriptInterface getNewInterface(RexseeBrowser childBrowser) { return new RexseeAlarm(childBrowser); } public static final String ALARM_ACTION = "action.alarm.id_"; public static final String ALARM_EXTRA_ARGU = "argu"; public static final String DATABASE_ALARM = "alarm.db"; public static final String TABLE_ALARM = "alarm"; private final Context mContext; private final RexseeBrowser mBrowser; public RexseeAlarm(RexseeBrowser browser) { mBrowser = browser; mContext = browser.getContext(); } public RexseeAlarm(Context context) { mBrowser = null; mContext = context; } private static void _setAlarm(Context context, AlarmManager mgr, String body, boolean save) { NotificationArgumentsSheet argu = (new NotificationArgumentsSheet()).parseArguments(body); if (argu.notificationimmedi