Skip to content
Snippets Groups Projects
Commit 1702a9da authored by Xin Li's avatar Xin Li
Browse files

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

Bug: 139369544
Change-Id: I835905a51836e7218f0be8c25335b9548ae6b2d3
parents 4204a601 823838e9
No related branches found
No related tags found
No related merge requests found
......@@ -752,6 +752,8 @@ public class Binder implements IBinder {
Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e);
}
} else {
// Clear the parcel before writing the exception
reply.setDataSize(0);
reply.setDataPosition(0);
reply.writeException(e);
}
......
......@@ -22,6 +22,7 @@
<uses-permission android:name="android.permission.CONTROL_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.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"/>
<application android:label="VpnDialogs"
android:allowBackup="false">
......
......@@ -16,6 +16,10 @@
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.DialogInterface;
import android.content.Intent;
......@@ -31,7 +35,6 @@ import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import com.android.internal.app.AlertActivity;
......@@ -74,8 +77,9 @@ public class AlwaysOnDisconnectedDialog extends AlertActivity
setupAlert();
getWindow().setCloseOnTouchOutside(false);
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
getWindow().setType(TYPE_SYSTEM_ALERT);
getWindow().addFlags(FLAG_ALT_FOCUSABLE_IM);
getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
}
@Override
......
......@@ -16,6 +16,8 @@
package com.android.vpndialogs;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
......@@ -78,6 +80,7 @@ public class ConfirmDialog extends AlertActivity
setupAlert();
getWindow().setCloseOnTouchOutside(false);
getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
Button button = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
button.setFilterTouchesWhenObscured(true);
}
......
......@@ -4202,6 +4202,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
checkTime(startTime, "startProcess: done removing from pids map");
app.setPid(0);
app.startSeq = 0;
}
 
if (DEBUG_PROCESSES && mProcessesOnHold.contains(app)) Slog.v(TAG_PROCESSES,
......@@ -4393,6 +4394,14 @@ public class ActivityManagerService extends IActivityManager.Stub
app.killedByAm = false;
app.removed = 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;
app.setStartParams(uid, hostingType, hostingNameStr, seInfo, startTime);
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 (oldApp != null && !app.isolated) {
// Clean up anything relating to this pid first
Slog.w(TAG, "Reusing pid " + pid
+ " while app is still mapped to it");
Slog.wtf(TAG, "handleProcessStartedLocked process:" + app.processName
+ " startSeq:" + app.startSeq
+ " pid:" + pid
+ " belongs to another existing app:" + oldApp.processName
+ " startSeq:" + oldApp.startSeq);
cleanUpApplicationRecordLocked(oldApp, false, false, -1,
true /*replacingPid*/);
}
......@@ -7435,6 +7447,26 @@ public class ActivityManagerService extends IActivityManager.Stub
synchronized (mPidsSelfLocked) {
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 {
app = null;
}
......@@ -7443,7 +7475,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// update the internal state.
if (app == null && startSeq > 0) {
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,
startSeq, true)) {
app = pending;
......@@ -777,18 +777,24 @@ public class LockTaskController {
* leaves the pinned mode.
*/
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 {
boolean shouldLockKeyguard = Settings.Secure.getIntForUser(
return Settings.Secure.getIntForUser(
mContext.getContentResolver(),
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED,
USER_CURRENT) != 0;
if (shouldLockKeyguard) {
mWindowManager.lockNow(null);
mWindowManager.dismissKeyguard(null /* callback */, null /* message */);
getLockPatternUtils().requireCredentialEntry(USER_ALL);
}
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, USER_CURRENT) != 0;
} 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);
}
}
......
......@@ -8900,10 +8900,10 @@ public class PackageManagerService extends IPackageManager.Stub
+ " better than this " + pkg.getLongVersionCode());
}
 
// Verify certificates against what was last scanned. If it is an updated priv app, we will
// force re-collecting certificate.
final boolean forceCollect = PackageManagerServiceUtils.isApkVerificationForced(
disabledPkgSetting);
// Verify certificates against what was last scanned. If there was an upgrade or this is an
// updated priv app, we will force re-collecting certificate.
final boolean forceCollect = mIsUpgrade ||
PackageManagerServiceUtils.isApkVerificationForced(disabledPkgSetting);
// 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
// cases, only data in Signing Block is verified instead of the whole file.
......@@ -390,7 +390,7 @@ public class LockTaskControllerTest {
mLockTaskController.startLockTaskMode(tr1, 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");
// THEN the lock task mode should be inactive
......@@ -404,7 +404,81 @@ public class LockTaskControllerTest {
}
@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[] whitelist2 = {TEST_PACKAGE_NAME};
......
......@@ -1442,6 +1442,9 @@ public class TelecomManager {
* foreground call is ended.
* <p>
* 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}
* otherwise.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment