Merge "Added check for user info is not null"
This commit is contained in:
@@ -3920,6 +3920,12 @@ public class Intent implements Parcelable, Cloneable {
|
|||||||
* that has been started. This is sent as a foreground
|
* that has been started. This is sent as a foreground
|
||||||
* broadcast, since it is part of a visible user interaction; be as quick
|
* broadcast, since it is part of a visible user interaction; be as quick
|
||||||
* as possible when handling it.
|
* as possible when handling it.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Note:</b> The user's actual state might have changed by the time the broadcast is
|
||||||
|
* received. For example, the user could have been removed, started or stopped already,
|
||||||
|
* regardless of which broadcast you receive. Because of that, receivers should always check
|
||||||
|
* the current state of the user.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String ACTION_USER_STARTED =
|
public static final String ACTION_USER_STARTED =
|
||||||
@@ -3937,6 +3943,12 @@ public class Intent implements Parcelable, Cloneable {
|
|||||||
* {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
|
* {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
|
||||||
* other user state broadcasts since those are foreground broadcasts so can
|
* other user state broadcasts since those are foreground broadcasts so can
|
||||||
* execute in a different order.
|
* execute in a different order.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Note:</b> The user's actual state might have changed by the time the broadcast is
|
||||||
|
* received. For example, the user could have been removed, started or stopped already,
|
||||||
|
* regardless of which broadcast you receive. Because of that, receivers should always check
|
||||||
|
* the current state of the user.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String ACTION_USER_STARTING =
|
public static final String ACTION_USER_STARTING =
|
||||||
@@ -3955,6 +3967,11 @@ public class Intent implements Parcelable, Cloneable {
|
|||||||
* {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
|
* {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
|
||||||
* other user state broadcasts since those are foreground broadcasts so can
|
* other user state broadcasts since those are foreground broadcasts so can
|
||||||
* execute in a different order.
|
* execute in a different order.
|
||||||
|
* <p>
|
||||||
|
* <b>Note:</b> The user's actual state might have changed by the time the broadcast is
|
||||||
|
* received. For example, the user could have been removed, started or stopped already,
|
||||||
|
* regardless of which broadcast you receive. Because of that, receivers should always check
|
||||||
|
* the current state of the user.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String ACTION_USER_STOPPING =
|
public static final String ACTION_USER_STOPPING =
|
||||||
@@ -3967,6 +3984,12 @@ public class Intent implements Parcelable, Cloneable {
|
|||||||
* specific package. This is only sent to registered receivers, not manifest
|
* specific package. This is only sent to registered receivers, not manifest
|
||||||
* receivers. It is sent to all running users <em>except</em> the one that
|
* receivers. It is sent to all running users <em>except</em> the one that
|
||||||
* has just been stopped (which is no longer running).
|
* has just been stopped (which is no longer running).
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Note:</b> The user's actual state might have changed by the time the broadcast is
|
||||||
|
* received. For example, the user could have been removed, started or stopped already,
|
||||||
|
* regardless of which broadcast you receive. Because of that, receivers should always check
|
||||||
|
* the current state of the user.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
@@ -3999,6 +4022,12 @@ public class Intent implements Parcelable, Cloneable {
|
|||||||
* It is sent to all running users.
|
* It is sent to all running users.
|
||||||
* You must hold
|
* You must hold
|
||||||
* {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
|
* {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Note:</b> The user's actual state might have changed by the time the broadcast is
|
||||||
|
* received. For example, the user could have been removed, started or stopped already,
|
||||||
|
* regardless of which broadcast you receive. Because of that, receivers should always check
|
||||||
|
* the current state of the user.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@@ -4009,6 +4038,12 @@ public class Intent implements Parcelable, Cloneable {
|
|||||||
* Broadcast Action: Sent when the credential-encrypted private storage has
|
* Broadcast Action: Sent when the credential-encrypted private storage has
|
||||||
* become unlocked for the target user. This is only sent to registered
|
* become unlocked for the target user. This is only sent to registered
|
||||||
* receivers, not manifest receivers.
|
* receivers, not manifest receivers.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Note:</b> The user's actual state might have changed by the time the broadcast is
|
||||||
|
* received. For example, the user could have been removed, started or stopped already,
|
||||||
|
* regardless of which broadcast you receive. Because of that, receivers should always check
|
||||||
|
* the current state of the user.
|
||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||||
public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
|
public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.content.pm.UserInfo;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.INetd;
|
import android.net.INetd;
|
||||||
import android.net.IVpnManager;
|
import android.net.IVpnManager;
|
||||||
@@ -775,6 +776,12 @@ public class VpnManagerService extends IVpnManager.Stub {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void onUserStarted(int userId) {
|
private void onUserStarted(int userId) {
|
||||||
|
UserInfo user = mUserManager.getUserInfo(userId);
|
||||||
|
if (user == null) {
|
||||||
|
logw("Started user doesn't exist. UserId: " + userId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (mVpns) {
|
synchronized (mVpns) {
|
||||||
Vpn userVpn = mVpns.get(userId);
|
Vpn userVpn = mVpns.get(userId);
|
||||||
if (userVpn != null) {
|
if (userVpn != null) {
|
||||||
@@ -783,7 +790,8 @@ public class VpnManagerService extends IVpnManager.Stub {
|
|||||||
}
|
}
|
||||||
userVpn = mDeps.createVpn(mHandler.getLooper(), mContext, mNMS, mNetd, userId);
|
userVpn = mDeps.createVpn(mHandler.getLooper(), mContext, mNMS, mNetd, userId);
|
||||||
mVpns.put(userId, userVpn);
|
mVpns.put(userId, userVpn);
|
||||||
if (mUserManager.getUserInfo(userId).isPrimary() && isLockdownVpnEnabled()) {
|
|
||||||
|
if (user.isPrimary() && isLockdownVpnEnabled()) {
|
||||||
updateLockdownVpn();
|
updateLockdownVpn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -898,9 +906,15 @@ public class VpnManagerService extends IVpnManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onUserUnlocked(int userId) {
|
private void onUserUnlocked(int userId) {
|
||||||
|
UserInfo user = mUserManager.getUserInfo(userId);
|
||||||
|
if (user == null) {
|
||||||
|
logw("Unlocked user doesn't exist. UserId: " + userId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (mVpns) {
|
synchronized (mVpns) {
|
||||||
// User present may be sent because of an unlock, which might mean an unlocked keystore.
|
// User present may be sent because of an unlock, which might mean an unlocked keystore.
|
||||||
if (mUserManager.getUserInfo(userId).isPrimary() && isLockdownVpnEnabled()) {
|
if (user.isPrimary() && isLockdownVpnEnabled()) {
|
||||||
updateLockdownVpn();
|
updateLockdownVpn();
|
||||||
} else {
|
} else {
|
||||||
startAlwaysOnVpn(userId);
|
startAlwaysOnVpn(userId);
|
||||||
|
|||||||
Reference in New Issue
Block a user