OSDN Git Service

Disable app pinning when emergency call button pressed
authorHall Liu <hallliu@google.com>
Fri, 27 May 2016 20:30:09 +0000 (13:30 -0700)
committerHall Liu <hallliu@google.com>
Fri, 27 May 2016 20:46:27 +0000 (13:46 -0700)
Also disables app pinning when the "return to call" button is pressed
and brings up the in-call screen when app pinning is stopped if there is
an existing call.

Bug: 28558307
Change-Id: I7672123bfa6ba6b5e960bd5166876c50425d3f76

packages/Keyguard/src/com/android/keyguard/EmergencyButton.java
services/core/java/com/android/server/am/ActivityManagerService.java

index 40c11cf..8d41145 100644 (file)
 
 package com.android.keyguard;
 
+import android.app.ActivityManagerNative;
 import android.app.ActivityOptions;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.os.PowerManager;
+import android.os.RemoteException;
 import android.os.SystemClock;
 import android.os.UserHandle;
 import android.telecom.TelecomManager;
 import android.util.AttributeSet;
+import android.util.Slog;
 import android.view.View;
 import android.widget.Button;
 
@@ -47,6 +50,8 @@ public class EmergencyButton extends Button {
                     | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
                     | Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
+    private static final String LOG_TAG = "EmergencyButton";
+
     KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
 
         @Override
@@ -122,6 +127,11 @@ public class EmergencyButton extends Button {
         // TODO: implement a shorter timeout once new PowerManager API is ready.
         // should be the equivalent to the old userActivity(EMERGENCY_CALL_TIMEOUT)
         mPowerManager.userActivity(SystemClock.uptimeMillis(), true);
+        try {
+            ActivityManagerNative.getDefault().stopSystemLockTaskMode();
+        } catch (RemoteException e) {
+            Slog.w(LOG_TAG, "Failed to stop app pinning");
+        }
         if (isInCall()) {
             resumeCall();
             if (mEmergencyButtonCallback != null) {
index eb4391e..1538fa1 100644 (file)
@@ -199,6 +199,7 @@ import android.provider.Settings;
 import android.service.voice.IVoiceInteractionSession;
 import android.service.voice.VoiceInteractionManagerInternal;
 import android.service.voice.VoiceInteractionSession;
+import android.telecom.TelecomManager;
 import android.text.format.DateUtils;
 import android.text.format.Time;
 import android.text.style.SuggestionSpan;
@@ -10129,6 +10130,10 @@ public final class ActivityManagerService extends ActivityManagerNative
                 mStackSupervisor.setLockTaskModeLocked(null, ActivityManager.LOCK_TASK_MODE_NONE,
                         "stopLockTask", true);
             }
+            TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
+            if (tm != null) {
+                tm.showInCallScreen(false);
+            }
         } finally {
             Binder.restoreCallingIdentity(ident);
         }