DO NOT MERGE - Merge pie-platform-release (PPRL.190801.002) into master

Bug: 139369544
Change-Id: I835905a51836e7218f0be8c25335b9548ae6b2d3
This commit is contained in:
Xin Li
2019-08-13 16:36:37 -07:00
9 changed files with 146 additions and 21 deletions

View File

@@ -752,6 +752,8 @@ public class Binder implements IBinder {
Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e); Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e);
} }
} else { } else {
// Clear the parcel before writing the exception
reply.setDataSize(0);
reply.setDataPosition(0); reply.setDataPosition(0);
reply.writeException(e); reply.writeException(e);
} }

View File

@@ -22,6 +22,7 @@
<uses-permission android:name="android.permission.CONTROL_VPN" /> <uses-permission android:name="android.permission.CONTROL_VPN" />
<uses-permission android:name="android.permission.CONTROL_ALWAYS_ON_VPN" /> <uses-permission android:name="android.permission.CONTROL_ALWAYS_ON_VPN" />
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
<uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"/>
<application android:label="VpnDialogs" <application android:label="VpnDialogs"
android:allowBackup="false"> android:allowBackup="false">

View File

@@ -16,6 +16,10 @@
package com.android.vpndialogs; package com.android.vpndialogs;
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@@ -31,7 +35,6 @@ import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.widget.TextView; import android.widget.TextView;
import com.android.internal.app.AlertActivity; import com.android.internal.app.AlertActivity;
@@ -74,8 +77,9 @@ public class AlwaysOnDisconnectedDialog extends AlertActivity
setupAlert(); setupAlert();
getWindow().setCloseOnTouchOutside(false); getWindow().setCloseOnTouchOutside(false);
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); getWindow().setType(TYPE_SYSTEM_ALERT);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); getWindow().addFlags(FLAG_ALT_FOCUSABLE_IM);
getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
} }
@Override @Override

View File

@@ -16,6 +16,8 @@
package com.android.vpndialogs; package com.android.vpndialogs;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@@ -78,6 +80,7 @@ public class ConfirmDialog extends AlertActivity
setupAlert(); setupAlert();
getWindow().setCloseOnTouchOutside(false); getWindow().setCloseOnTouchOutside(false);
getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
Button button = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); Button button = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
button.setFilterTouchesWhenObscured(true); button.setFilterTouchesWhenObscured(true);
} }

View File

@@ -4202,6 +4202,7 @@ public class ActivityManagerService extends IActivityManager.Stub
} }
checkTime(startTime, "startProcess: done removing from pids map"); checkTime(startTime, "startProcess: done removing from pids map");
app.setPid(0); app.setPid(0);
app.startSeq = 0;
} }
if (DEBUG_PROCESSES && mProcessesOnHold.contains(app)) Slog.v(TAG_PROCESSES, if (DEBUG_PROCESSES && mProcessesOnHold.contains(app)) Slog.v(TAG_PROCESSES,
@@ -4393,6 +4394,14 @@ public class ActivityManagerService extends IActivityManager.Stub
app.killedByAm = false; app.killedByAm = false;
app.removed = false; app.removed = false;
app.killed = false; app.killed = false;
if (app.startSeq != 0) {
Slog.wtf(TAG, "startProcessLocked processName:" + app.processName
+ " with non-zero startSeq:" + app.startSeq);
}
if (app.pid != 0) {
Slog.wtf(TAG, "startProcessLocked processName:" + app.processName
+ " with non-zero pid:" + app.pid);
}
final long startSeq = app.startSeq = ++mProcStartSeqCounter; final long startSeq = app.startSeq = ++mProcStartSeqCounter;
app.setStartParams(uid, hostingType, hostingNameStr, seInfo, startTime); app.setStartParams(uid, hostingType, hostingNameStr, seInfo, startTime);
if (mConstants.FLAG_PROCESS_START_ASYNC) { if (mConstants.FLAG_PROCESS_START_ASYNC) {
@@ -4578,8 +4587,11 @@ public class ActivityManagerService extends IActivityManager.Stub
// If there is already an app occupying that pid that hasn't been cleaned up // If there is already an app occupying that pid that hasn't been cleaned up
if (oldApp != null && !app.isolated) { if (oldApp != null && !app.isolated) {
// Clean up anything relating to this pid first // Clean up anything relating to this pid first
Slog.w(TAG, "Reusing pid " + pid Slog.wtf(TAG, "handleProcessStartedLocked process:" + app.processName
+ " while app is still mapped to it"); + " startSeq:" + app.startSeq
+ " pid:" + pid
+ " belongs to another existing app:" + oldApp.processName
+ " startSeq:" + oldApp.startSeq);
cleanUpApplicationRecordLocked(oldApp, false, false, -1, cleanUpApplicationRecordLocked(oldApp, false, false, -1,
true /*replacingPid*/); true /*replacingPid*/);
} }
@@ -7435,6 +7447,26 @@ public class ActivityManagerService extends IActivityManager.Stub
synchronized (mPidsSelfLocked) { synchronized (mPidsSelfLocked) {
app = mPidsSelfLocked.get(pid); app = mPidsSelfLocked.get(pid);
} }
if (app != null && (app.startUid != callingUid || app.startSeq != startSeq)) {
String processName = null;
final ProcessRecord pending = mPendingStarts.get(startSeq);
if (pending != null) {
processName = pending.processName;
}
final String msg = "attachApplicationLocked process:" + processName
+ " startSeq:" + startSeq
+ " pid:" + pid
+ " belongs to another existing app:" + app.processName
+ " startSeq:" + app.startSeq;
Slog.wtf(TAG, msg);
// SafetyNet logging for b/131105245.
EventLog.writeEvent(0x534e4554, "131105245", app.startUid, msg);
// If there is already an app occupying that pid that hasn't been cleaned up
cleanUpApplicationRecordLocked(app, false, false, -1,
true /*replacingPid*/);
mPidsSelfLocked.remove(pid);
app = null;
}
} else { } else {
app = null; app = null;
} }
@@ -7443,7 +7475,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// update the internal state. // update the internal state.
if (app == null && startSeq > 0) { if (app == null && startSeq > 0) {
final ProcessRecord pending = mPendingStarts.get(startSeq); final ProcessRecord pending = mPendingStarts.get(startSeq);
if (pending != null && pending.startUid == callingUid if (pending != null && pending.startUid == callingUid && pending.startSeq == startSeq
&& handleProcessStartedLocked(pending, pid, pending.usingWrapper, && handleProcessStartedLocked(pending, pid, pending.usingWrapper,
startSeq, true)) { startSeq, true)) {
app = pending; app = pending;

View File

@@ -777,18 +777,24 @@ public class LockTaskController {
* leaves the pinned mode. * leaves the pinned mode.
*/ */
private void lockKeyguardIfNeeded() { private void lockKeyguardIfNeeded() {
if (shouldLockKeyguard()) {
mWindowManager.lockNow(null);
mWindowManager.dismissKeyguard(null /* callback */, null /* message */);
getLockPatternUtils().requireCredentialEntry(USER_ALL);
}
}
private boolean shouldLockKeyguard() {
// This functionality should be kept consistent with
// com.android.settings.security.ScreenPinningSettings (see b/127605586)
try { try {
boolean shouldLockKeyguard = Settings.Secure.getIntForUser( return Settings.Secure.getIntForUser(
mContext.getContentResolver(), mContext.getContentResolver(),
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, USER_CURRENT) != 0;
USER_CURRENT) != 0;
if (shouldLockKeyguard) {
mWindowManager.lockNow(null);
mWindowManager.dismissKeyguard(null /* callback */, null /* message */);
getLockPatternUtils().requireCredentialEntry(USER_ALL);
}
} catch (Settings.SettingNotFoundException e) { } catch (Settings.SettingNotFoundException e) {
// No setting, don't lock. // Log to SafetyNet for b/127605586
android.util.EventLog.writeEvent(0x534e4554, "127605586", -1, "");
return getLockPatternUtils().isSecure(USER_CURRENT);
} }
} }

View File

@@ -8900,10 +8900,10 @@ public class PackageManagerService extends IPackageManager.Stub
+ " better than this " + pkg.getLongVersionCode()); + " better than this " + pkg.getLongVersionCode());
} }
// Verify certificates against what was last scanned. If it is an updated priv app, we will // Verify certificates against what was last scanned. If there was an upgrade or this is an
// force re-collecting certificate. // updated priv app, we will force re-collecting certificate.
final boolean forceCollect = PackageManagerServiceUtils.isApkVerificationForced( final boolean forceCollect = mIsUpgrade ||
disabledPkgSetting); PackageManagerServiceUtils.isApkVerificationForced(disabledPkgSetting);
// Full APK verification can be skipped during certificate collection, only if the file is // Full APK verification can be skipped during certificate collection, only if the file is
// in verified partition, or can be verified on access (when apk verity is enabled). In both // in verified partition, or can be verified on access (when apk verity is enabled). In both
// cases, only data in Signing Block is verified instead of the whole file. // cases, only data in Signing Block is verified instead of the whole file.

View File

@@ -390,7 +390,7 @@ public class LockTaskControllerTest {
mLockTaskController.startLockTaskMode(tr1, false, TEST_UID); mLockTaskController.startLockTaskMode(tr1, false, TEST_UID);
mLockTaskController.startLockTaskMode(tr2, false, TEST_UID); mLockTaskController.startLockTaskMode(tr2, false, TEST_UID);
// WHEN calling stopLockTaskMode on the root task // WHEN calling clearLockedTasks on the root task
mLockTaskController.clearLockedTasks("testClearLockedTasks"); mLockTaskController.clearLockedTasks("testClearLockedTasks");
// THEN the lock task mode should be inactive // THEN the lock task mode should be inactive
@@ -404,7 +404,81 @@ public class LockTaskControllerTest {
} }
@Test @Test
public void testUpdateLockTaskPackages() throws Exception { public void testClearLockedTasks_noLockSetting_noPassword_deviceIsUnlocked() throws Exception {
// GIVEN There is no setting set for LOCK_TO_APP_EXIT_LOCKED
Settings.Secure.clearProviderForTest();
// AND no password is set
when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
.thenReturn(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
// AND there is a task record
TaskRecord tr1 = getTaskRecord(TaskRecord.LOCK_TASK_AUTH_WHITELISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
mLockTaskController.clearLockedTasks("testClearLockedTasks");
// THEN the device should not be locked
verify(mWindowManager, never()).lockNow(any());
}
@Test
public void testClearLockedTasks_noLockSetting_password_deviceIsLocked() throws Exception {
// GIVEN There is no setting set for LOCK_TO_APP_EXIT_LOCKED
Settings.Secure.clearProviderForTest();
// AND a password is set
when(mLockPatternUtils.isSecure(anyInt()))
.thenReturn(true);
// AND there is a task record
TaskRecord tr1 = getTaskRecord(TaskRecord.LOCK_TASK_AUTH_WHITELISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
mLockTaskController.clearLockedTasks("testClearLockedTasks");
// THEN the device should be locked
verify(mWindowManager, times(1)).lockNow(any());
}
@Test
public void testClearLockedTasks_lockSettingTrue_deviceIsLocked() throws Exception {
// GIVEN LOCK_TO_APP_EXIT_LOCKED is set to 1
Settings.Secure.putIntForUser(mContext.getContentResolver(),
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, 1, mContext.getUserId());
// AND there is a task record
TaskRecord tr1 = getTaskRecord(TaskRecord.LOCK_TASK_AUTH_WHITELISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
mLockTaskController.clearLockedTasks("testClearLockedTasks");
// THEN the device should be locked
verify(mWindowManager, times(1)).lockNow(any());
}
@Test
public void testClearLockedTasks_lockSettingFalse_doesNotRequirePassword() throws Exception {
// GIVEN LOCK_TO_APP_EXIT_LOCKED is set to 1
Settings.Secure.putIntForUser(mContext.getContentResolver(),
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, 0, mContext.getUserId());
// AND there is a task record
TaskRecord tr1 = getTaskRecord(TaskRecord.LOCK_TASK_AUTH_WHITELISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
mLockTaskController.clearLockedTasks("testClearLockedTasks");
// THEN the device should be unlocked
verify(mWindowManager, never()).lockNow(any());
}
@Test
public void testUpdateLockTaskPackages() {
String[] whitelist1 = {TEST_PACKAGE_NAME, TEST_PACKAGE_NAME_2}; String[] whitelist1 = {TEST_PACKAGE_NAME, TEST_PACKAGE_NAME_2};
String[] whitelist2 = {TEST_PACKAGE_NAME}; String[] whitelist2 = {TEST_PACKAGE_NAME};

View File

@@ -1442,6 +1442,9 @@ public class TelecomManager {
* foreground call is ended. * foreground call is ended.
* <p> * <p>
* Requires permission {@link android.Manifest.permission#ANSWER_PHONE_CALLS}. * Requires permission {@link android.Manifest.permission#ANSWER_PHONE_CALLS}.
* <p>
* Note: this method CANNOT be used to end ongoing emergency calls and will return {@code false}
* if an attempt is made to end an emergency call.
* *
* @return {@code true} if there is a call which will be rejected or terminated, {@code false} * @return {@code true} if there is a call which will be rejected or terminated, {@code false}
* otherwise. * otherwise.