summaryrefslogtreecommitdiff
path: root/java/com/android/voicemail/impl/OmtpService.java
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-08-31 06:57:16 -0700
committerEric Erfanian <erfanian@google.com>2017-08-31 16:13:53 +0000
commit2ca4318cc1ee57dda907ba2069bd61d162b1baef (patch)
treee282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/voicemail/impl/OmtpService.java
parent68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff)
Update Dialer source to latest internal Google revision.
Previously, Android's Dialer app was developed in an internal Google source control system and only exported to public during AOSP drops. The Dialer team is now switching to a public development model similar to the telephony team. This CL represents all internal Google changes that were committed to Dialer between the public O release and today's tip of tree on internal master. This CL squashes those changes into a single commit. In subsequent changes, changes will be exported on a per-commit basis. Test: make, flash install, run Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160 Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8 PiperOrigin-RevId: 167068436
Diffstat (limited to 'java/com/android/voicemail/impl/OmtpService.java')
-rw-r--r--java/com/android/voicemail/impl/OmtpService.java52
1 files changed, 46 insertions, 6 deletions
diff --git a/java/com/android/voicemail/impl/OmtpService.java b/java/com/android/voicemail/impl/OmtpService.java
index b82cc5f68..4db1aeb7e 100644
--- a/java/com/android/voicemail/impl/OmtpService.java
+++ b/java/com/android/voicemail/impl/OmtpService.java
@@ -17,9 +17,13 @@
package com.android.voicemail.impl;
import android.annotation.TargetApi;
+import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION_CODES;
import android.os.UserManager;
+import android.preference.PreferenceManager;
+import android.support.annotation.MainThread;
+import android.support.annotation.NonNull;
import android.telecom.PhoneAccountHandle;
import android.telephony.VisualVoicemailService;
import android.telephony.VisualVoicemailSms;
@@ -40,6 +44,8 @@ public class OmtpService extends VisualVoicemailService {
public static final String EXTRA_VOICEMAIL_SMS = "extra_voicemail_sms";
+ private static final String IS_SHUTTING_DOWN = "com.android.voicemail.impl.is_shutting_down";
+
@Override
public void onCellServiceConnected(
VisualVoicemailTask task, final PhoneAccountHandle phoneAccountHandle) {
@@ -50,7 +56,7 @@ public class OmtpService extends VisualVoicemailService {
return;
}
- if (!isUserUnlocked()) {
+ if (!isUserUnlocked(this)) {
VvmLog.i(TAG, "onCellServiceConnected: user locked");
task.finish();
return;
@@ -75,7 +81,7 @@ public class OmtpService extends VisualVoicemailService {
return;
}
- if (!isUserUnlocked()) {
+ if (!isUserUnlocked(this)) {
LegacyModeSmsHandler.handle(this, sms);
return;
}
@@ -105,12 +111,18 @@ public class OmtpService extends VisualVoicemailService {
return;
}
- if (!isUserUnlocked()) {
+ if (!isUserUnlocked(this)) {
VvmLog.i(TAG, "onSimRemoved: user locked");
task.finish();
return;
}
+ if (isShuttingDown(this)) {
+ VvmLog.i(TAG, "onSimRemoved: system shutting down, ignoring");
+ task.finish();
+ return;
+ }
+
Logger.get(this).logImpression(DialerImpression.Type.VVM_UNBUNDLED_EVENT_RECEIVED);
VvmAccountManager.removeAccount(this, phoneAccountHandle);
task.finish();
@@ -124,7 +136,7 @@ public class OmtpService extends VisualVoicemailService {
task.finish();
return;
}
- if (!isUserUnlocked()) {
+ if (!isUserUnlocked(this)) {
VvmLog.i(TAG, "onStopped: user locked");
task.finish();
return;
@@ -132,6 +144,22 @@ public class OmtpService extends VisualVoicemailService {
Logger.get(this).logImpression(DialerImpression.Type.VVM_UNBUNDLED_EVENT_RECEIVED);
}
+ @MainThread
+ static void onBoot(@NonNull Context context) {
+ VvmLog.i(TAG, "onBoot");
+ Assert.isTrue(isUserUnlocked(context));
+ Assert.isMainThread();
+ setShuttingDown(context, false);
+ }
+
+ @MainThread
+ static void onShutdown(@NonNull Context context) {
+ VvmLog.i(TAG, "onShutdown");
+ Assert.isTrue(isUserUnlocked(context));
+ Assert.isMainThread();
+ setShuttingDown(context, true);
+ }
+
private boolean isModuleEnabled() {
return VoicemailComponent.get(this).getVoicemailClient().isVoicemailModuleEnabled();
}
@@ -150,8 +178,20 @@ public class OmtpService extends VisualVoicemailService {
return true;
}
- private boolean isUserUnlocked() {
- UserManager userManager = getSystemService(UserManager.class);
+ private static boolean isUserUnlocked(@NonNull Context context) {
+ UserManager userManager = context.getSystemService(UserManager.class);
return userManager.isUserUnlocked();
}
+
+ private static void setShuttingDown(Context context, boolean value) {
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .edit()
+ .putBoolean(IS_SHUTTING_DOWN, value)
+ .apply();
+ }
+
+ private static boolean isShuttingDown(Context context) {
+ return PreferenceManager.getDefaultSharedPreferences(context)
+ .getBoolean(IS_SHUTTING_DOWN, false);
+ }
}