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
), admin_disable_requested
);
55 return null;//TODO: write this
59 public void onEnabled(@Nullable final Context context
, @Nullable final Intent intent
) {
62 Utils
.sendMessage(context
, toNonNull(MessageType
.ADMIN
), admin_enabled
);
66 public void onPasswordChanged(@Nullable final Context context
, @Nullable final Intent intent
) {
69 Utils
.sendMessage(context
, toNonNull(MessageType
.ADMIN
), device_password_changed
);
72 @SuppressWarnings("boxing")
74 public void onPasswordFailed(@Nullable final Context context
, @Nullable final Intent intent
) {
77 final DevicePolicyManager dpm
=(DevicePolicyManager
) context
.getSystemService(Context
.DEVICE_POLICY_SERVICE
);
78 Utils
.sendMessage(context
, toNonNull(MessageType
.WATCH_LOGIN
), device_login_failed_fmt
, dpm
.getCurrentFailedPasswordAttempts());
82 public void onPasswordSucceeded(@Nullable final Context context
, @Nullable final Intent intent
) {
85 Utils
.sendMessage(context
, toNonNull(MessageType
.WATCH_LOGIN
), device_login_succeeded
);
This page took 0.023288 seconds and 4 git commands to generate.