Permalink
Browse files

add Receiver to receive the broadcast 'com.android.deskclock.ALARM_SE…

…T_NEXT' when shut down

Change-Id: I2205e37676a2c3884ecd4c666c95efae37e7f2f7
  • Loading branch information...
1 parent 9bc33d6 commit 2b23078ba634baee631d06dd38ad37d3eccacb00 @yu88my yu88my committed Nov 22, 2012
View
@@ -1,16 +1,34 @@
-From 0f06370e23e6b0856b66c153760351eec60f4e1f Mon Sep 17 00:00:00 2001
-From: mochangming <mochangming@xiaomi.com>
-Date: Tue, 21 Aug 2012 16:24:12 +0800
-Subject: [PATCH] support the shutdown alarm clock
+From 74c522228d0a35acd35c83a5caedc47a20ff9ede Mon Sep 17 00:00:00 2001
+From: yumingyang <yumingyang@xiaomi.com>
+Date: Wed, 21 Nov 2012 16:53:48 +0800
+Subject: [PATCH] add patch
---
- .../android/deskclock/AlarmInitReceiver$1.smali | 5 -
- DeskClock/smali/com/android/deskclock/Alarms.smali | 211 ++++++++++----------
- 2 files changed, 109 insertions(+), 107 deletions(-)
+ DeskClock/AndroidManifest.xml | 7 +
+ .../android/deskclock/AlarmInitReceiver$1.smali | 8 -
+ DeskClock/smali/com/android/deskclock/Alarms.smali | 41 +-
+ 4 files changed, 978 insertions(+), 25 deletions(-)
+ create mode 100644 DeskClock/smali/com/android/deskclock/AlarmReceiverEx.smali
+--- a/DeskClock/AndroidManifest.xml
++++ b/DeskClock/AndroidManifest.xml
+@@ -41,6 +41,13 @@
+ <action android:name="cancel_snooze" />
+ </intent-filter>
+ </receiver>
++
++ <receiver android:name="AlarmReceiverEx" android:exported="false">
++ <intent-filter>
++ <action android:name="com.android.deskclock.ALARM_SET_NEXT" />
++ </intent-filter>
++ </receiver>
++
+ <activity android:theme="@android:style/Theme.NoDisplay" android:name="HandleSetAlarm" android:permission="com.android.alarm.permission.SET_ALARM" android:excludeFromRecents="true" android:screenOrientation="portrait">
+ <intent-filter>
+ <action android:name="android.intent.action.SET_ALARM" />
--- a/DeskClock/smali/com/android/deskclock/AlarmInitReceiver$1.smali
+++ b/DeskClock/smali/com/android/deskclock/AlarmInitReceiver$1.smali
-@@ -80,10 +80,6 @@
+@@ -82,10 +82,6 @@
invoke-virtual {v0, v11}, Lmiui/net/FirewallManager;->addOneShotFlag(I)V
@@ -34,7 +52,7 @@ Subject: [PATCH] support the shutdown alarm clock
invoke-static {p0, v4}, Lcom/android/deskclock/Alarms;->setStatusBarIcon(Landroid/content/Context;Z)V
const-string v2, ""
-@@ -1134,7 +1138,9 @@
+@@ -1126,7 +1130,9 @@
move-result-object v4
.local v4, sender:Landroid/app/PendingIntent;
@@ -45,6 +63,30 @@ Subject: [PATCH] support the shutdown alarm clock
invoke-static {p0, v11}, Lcom/android/deskclock/Alarms;->setStatusBarIcon(Landroid/content/Context;Z)V
+@@ -1613,6 +1619,23 @@
+ :cond_0
+ invoke-static {p0}, Lcom/android/deskclock/Alarms;->disableAlert(Landroid/content/Context;)V
+
++ const-string v2, "alarm"
++
++ invoke-virtual {p0, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
++
++ move-result-object v1
++
++ check-cast v1, Landroid/app/AlarmManager;
++
++ .local v1, am:Landroid/app/AlarmManager;
++ const/4 v2, 0x4
++
++ invoke-virtual {v1, v2}, Landroid/app/AlarmManager;->clearAlarm(I)V
++
++ const-string v2, "keen setNextAlert clearAlarm "
++
++ invoke-static {v2}, Lcom/android/deskclock/Log;->e(Ljava/lang/String;)V
++
+ goto :goto_0
+ .end method
+
--
-1.7.1
+1.7.5.4
@@ -0,0 +1,86 @@
+.class Lcom/android/deskclock/AlarmReceiverEx$1;
+.super Ljava/lang/Object;
+.source "AlarmReceiverEx.java"
+
+# interfaces
+.implements Ljava/lang/Runnable;
+
+
+# annotations
+.annotation system Ldalvik/annotation/EnclosingMethod;
+ value = Lcom/android/deskclock/AlarmReceiverEx;->onReceive(Landroid/content/Context;Landroid/content/Intent;)V
+.end annotation
+
+.annotation system Ldalvik/annotation/InnerClass;
+ accessFlags = 0x0
+ name = null
+.end annotation
+
+
+# instance fields
+.field final synthetic this$0:Lcom/android/deskclock/AlarmReceiverEx;
+
+.field final synthetic val$context:Landroid/content/Context;
+
+.field final synthetic val$intent:Landroid/content/Intent;
+
+.field final synthetic val$result:Landroid/content/BroadcastReceiver$PendingResult;
+
+.field final synthetic val$wl:Landroid/os/PowerManager$WakeLock;
+
+
+# direct methods
+.method constructor <init>(Lcom/android/deskclock/AlarmReceiverEx;Landroid/os/PowerManager$WakeLock;Landroid/content/Context;Landroid/content/Intent;Landroid/content/BroadcastReceiver$PendingResult;)V
+ .locals 0
+ .parameter
+ .parameter
+ .parameter
+ .parameter
+ .parameter
+
+ .prologue
+ .line 53
+ iput-object p1, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->this$0:Lcom/android/deskclock/AlarmReceiverEx;
+
+ iput-object p2, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$wl:Landroid/os/PowerManager$WakeLock;
+
+ iput-object p3, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$context:Landroid/content/Context;
+
+ iput-object p4, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$intent:Landroid/content/Intent;
+
+ iput-object p5, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$result:Landroid/content/BroadcastReceiver$PendingResult;
+
+ invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V
+
+ return-void
+.end method
+
+
+# virtual methods
+.method public run()V
+ .locals 3
+
+ .prologue
+ .line 55
+ iget-object v0, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$wl:Landroid/os/PowerManager$WakeLock;
+
+ invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->release()V
+
+ .line 56
+ iget-object v0, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->this$0:Lcom/android/deskclock/AlarmReceiverEx;
+
+ iget-object v1, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$context:Landroid/content/Context;
+
+ iget-object v2, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$intent:Landroid/content/Intent;
+
+ #calls: Lcom/android/deskclock/AlarmReceiverEx;->handleIntent(Landroid/content/Context;Landroid/content/Intent;)V
+ invoke-static {v0, v1, v2}, Lcom/android/deskclock/AlarmReceiverEx;->access$000(Lcom/android/deskclock/AlarmReceiverEx;Landroid/content/Context;Landroid/content/Intent;)V
+
+ .line 57
+ iget-object v0, p0, Lcom/android/deskclock/AlarmReceiverEx$1;->val$result:Landroid/content/BroadcastReceiver$PendingResult;
+
+ invoke-virtual {v0}, Landroid/content/BroadcastReceiver$PendingResult;->finish()V
+
+ .line 58
+ return-void
+.end method
@@ -0,0 +1,128 @@
+.class public Lcom/android/deskclock/AlarmReceiverEx;
+.super Landroid/content/BroadcastReceiver;
+.source "AlarmReceiverEx.java"
+
+
+# instance fields
+.field private mTelephonyManager:Landroid/telephony/TelephonyManager;
+
+
+# direct methods
+.method public constructor <init>()V
+ .locals 0
+
+ .prologue
+ invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V
+
+ return-void
+.end method
+
+.method static synthetic access$000(Lcom/android/deskclock/AlarmReceiverEx;Landroid/content/Context;Landroid/content/Intent;)V
+ .locals 0
+ .parameter "x0"
+ .parameter "x1"
+ .parameter "x2"
+
+ .prologue
+ invoke-direct {p0, p1, p2}, Lcom/android/deskclock/AlarmReceiverEx;->handleIntent(Landroid/content/Context;Landroid/content/Intent;)V
+
+ return-void
+.end method
+
+.method private handleIntent(Landroid/content/Context;Landroid/content/Intent;)V
+ .locals 11
+ .parameter
+ .parameter
+
+ .prologue
+ const/4 v0, 0x0
+
+ const/high16 v9, 0x1000
+
+ const/4 v4, -0x1
+
+ const/4 v10, 0x1
+
+ const/4 v1, 0x0
+
+ new-instance v2, Ljava/lang/StringBuilder;
+
+ invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
+
+ const-string v3, "keen AlarmReceiverEx!intent.getAction()= "
+
+ invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+ move-result-object v2
+
+ invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
+
+ move-result-object v3
+
+ invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+ move-result-object v2
+
+ invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
+
+ move-result-object v2
+
+ invoke-static {v2}, Lcom/android/deskclock/Log;->v(Ljava/lang/String;)V
+
+ const-string v2, "com.android.deskclock.ALARM_SET_NEXT"
+
+ invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
+
+ move-result-object v3
+
+ invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
+
+ move-result v2
+
+ #if-eqz v2, :cond_1
+
+ invoke-static {p1}, Lcom/android/deskclock/Alarms;->setNextAlert(Landroid/content/Context;)V
+
+ const-string v0, "young keen setNextAlert end"
+
+ invoke-static {v0}, Lcom/android/deskclock/Log;->v(Ljava/lang/String;)V
+
+ :cond_0
+ :goto_0
+ return-void
+
+ .end method
+
+# virtual methods
+.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
+ .locals 6
+ .parameter "context"
+ .parameter "intent"
+
+ .prologue
+ invoke-virtual {p0}, Lcom/android/deskclock/AlarmReceiverEx;->goAsync()Landroid/content/BroadcastReceiver$PendingResult;
+
+ move-result-object v5
+
+ .local v5, result:Landroid/content/BroadcastReceiver$PendingResult;
+ invoke-static {p1}, Lcom/android/deskclock/AlarmAlertWakeLock;->createPartialWakeLock(Landroid/content/Context;)Landroid/os/PowerManager$WakeLock;
+
+ move-result-object v2
+
+ .local v2, wl:Landroid/os/PowerManager$WakeLock;
+ invoke-virtual {v2}, Landroid/os/PowerManager$WakeLock;->acquire()V
+
+ new-instance v0, Lcom/android/deskclock/AlarmReceiverEx$1;
+
+ move-object v1, p0
+
+ move-object v3, p1
+
+ move-object v4, p2
+
+ invoke-direct/range {v0 .. v5}, Lcom/android/deskclock/AlarmReceiverEx$1;-><init>(Lcom/android/deskclock/AlarmReceiverEx;Landroid/os/PowerManager$WakeLock;Landroid/content/Context;Landroid/content/Intent;Landroid/content/BroadcastReceiver$PendingResult;)V
+
+ invoke-static {v0}, Lcom/android/deskclock/AsyncHandler;->post(Ljava/lang/Runnable;)V
+
+ return-void
+.end method

0 comments on commit 2b23078

Please sign in to comment.