1 package ro
.ieval
.fonbot
;
3 import static ro
.ieval
.fonbot
.R
.string
.*;
5 import static ro
.ieval
.fonbot
.Utils
.toNonNull
;
7 import org
.eclipse
.jdt
.annotation
.Nullable
;
9 import ro
.ieval
.fonbot
.Utils
.MessageType
;
10 import android
.app
.admin
.DeviceAdminReceiver
;
11 import android
.app
.admin
.DevicePolicyManager
;
12 import android
.content
.Context
;
13 import android
.content
.Intent
;
14 import android
.util
.Log
;
17 * Copyright © 2013 Marius Gavrilescu
19 * This file is part of FonBot.
21 * FonBot is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * FonBot is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with FonBot. If not, see <http://www.gnu.org/licenses/>.
36 * The {@link DeviceAdminReceiver} used by FonBot. Sends {@link Utils.MessageType#ADMIN ADMIN} and {@link Utils.MessageType#WATCH_LOGIN WATCH_LOGIN} notifications.
38 * @author Marius Gavrilescu <marius@ieval.ro>
40 public final class FonBotAdminReceiver
extends DeviceAdminReceiver
{
42 public void onDisabled(@Nullable final Context context
, @Nullable final Intent intent
) {
45 Utils
.sendMessage(context
, toNonNull(MessageType
.ADMIN
), "Admin disabled");
49 public @Nullable CharSequence
onDisableRequested(@Nullable final Context context
, @Nullable final Intent intent
) {
51 Log
.wtf(getClass().getName(), "context is null in onDisableRequested");
52 throw new AssertionError("Log.wtf did not terminate the process");
54 Utils
.sendMessage(context
, toNonNull(MessageType
.ADMIN
),
55 toNonNull(context
.getString(admin_disable_requested
)));
56 return null;//TODO: write this
60 public void onEnabled(@Nullable final Context context
, @Nullable final Intent intent
) {
63 Utils
.sendMessage(context
, toNonNull(MessageType
.ADMIN
),
64 toNonNull(context
.getString(admin_enabled
)));
68 public void onPasswordChanged(@Nullable final Context context
, @Nullable final Intent intent
) {
71 Utils
.sendMessage(context
, toNonNull(MessageType
.ADMIN
),
72 toNonNull(context
.getString(device_password_changed
)));
75 @SuppressWarnings("boxing")
77 public void onPasswordFailed(@Nullable final Context context
, @Nullable final Intent intent
) {
80 final DevicePolicyManager dpm
=(DevicePolicyManager
) context
.getSystemService(Context
.DEVICE_POLICY_SERVICE
);
81 Utils
.sendMessage(context
, toNonNull(MessageType
.WATCH_LOGIN
),
82 toNonNull(context
.getString(device_login_failed_fmt
, dpm
.getCurrentFailedPasswordAttempts())));
86 public void onPasswordSucceeded(@Nullable final Context context
, @Nullable final Intent intent
) {
89 Utils
.sendMessage(context
, toNonNull(MessageType
.WATCH_LOGIN
), toNonNull(context
.getString(device_login_succeeded
)));
This page took 0.021789 seconds and 4 git commands to generate.