Fix NullPointerException in ConnectivityService

[Problem]
NullPointerException occurs in ConnectivityService when boot up.

[Root Cause]
When ConnectivityService starts up, isTetheringSupported may access
UserManager that has not been created yet. Therefore,
NullPointerException occurs.

[Solution]
Changed to create UserManager before makeTethering().

Bug: 134351774
Test: ConnectivityServiceTest
Change-Id: I299ecfa6af7295c1f3922f37d90eb5d3ab0d0286
This commit is contained in:
soma, kawata
2019-05-23 09:30:40 +09:00
committed by Fen Wang
parent 260d998775
commit 90913e9a37

View File

@@ -966,6 +966,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mTethering = makeTethering();
mPermissionMonitor = new PermissionMonitor(mContext, mNetd);
@@ -1013,8 +1015,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
final DataConnectionStats dataConnectionStats = new DataConnectionStats(mContext);
dataConnectionStats.startMonitoring();
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mKeepaliveTracker = new KeepaliveTracker(mContext, mHandler);
mNotifier = new NetworkNotificationManager(mContext, mTelephonyManager,
mContext.getSystemService(NotificationManager.class));