Loading src/com/android/server/telecom/TelecomSystem.java +194 −188 Original line number Diff line number Diff line Loading @@ -217,6 +217,7 @@ public class TelecomSystem { defaultDialerAdapter, roleManagerAdapter, mLock); Log.startSession("TS.init"); try { mPhoneAccountRegistrar = new PhoneAccountRegistrar(mContext, defaultDialerCache, packageName -> AppLabelProxy.Util.getAppLabel( mContext.getPackageManager(), packageName)); Loading @@ -241,8 +242,8 @@ public class TelecomSystem { SystemStateHelper systemStateHelper = new SystemStateHelper(mContext); mMissedCallNotifier = missedCallNotifierImplFactory .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar, defaultDialerCache, deviceIdleControllerAdapter); .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar, defaultDialerCache, deviceIdleControllerAdapter); DisconnectedCallNotifier.Factory disconnectedCallNotifierFactory = new DisconnectedCallNotifier.Default(); Loading Loading @@ -304,8 +305,8 @@ public class TelecomSystem { ToastFactory toastFactory = new ToastFactory() { @Override public Toast makeText(Context context, int resId, int duration) { return Toast.makeText(context, context.getMainLooper(), context.getString(resId), duration); return Toast.makeText(context, context.getMainLooper(), context.getString(resId), duration); } @Override Loading Loading @@ -378,14 +379,16 @@ public class TelecomSystem { mContext.registerReceiverAsUser(mBootCompletedReceiver, UserHandle.ALL, BOOT_COMPLETE_FILTER, null, null); // Set current user explicitly since USER_SWITCHED_FILTER intent can be missed at startup // Set current user explicitly since USER_SWITCHED_FILTER intent can be missed at // startup synchronized (mLock) { UserHandle currentUserHandle = UserHandle.of(ActivityManager.getCurrentUser()); mPhoneAccountRegistrar.setCurrentUserHandle(currentUserHandle); mCallsManager.onUserSwitch(currentUserHandle); } mCallIntentProcessor = new CallIntentProcessor(mContext, mCallsManager, defaultDialerCache); mCallIntentProcessor = new CallIntentProcessor(mContext, mCallsManager, defaultDialerCache); mTelecomBroadcastIntentProcessor = new TelecomBroadcastIntentProcessor( mContext, mCallsManager); Loading @@ -401,7 +404,8 @@ public class TelecomSystem { new CallIntentProcessor.AdapterImpl(defaultDialerCache), new UserCallIntentProcessorFactory() { @Override public UserCallIntentProcessor create(Context context, UserHandle userHandle) { public UserCallIntentProcessor create(Context context, UserHandle userHandle) { return new UserCallIntentProcessor(context, userHandle); } }, Loading @@ -409,8 +413,10 @@ public class TelecomSystem { new TelecomServiceImpl.SubscriptionManagerAdapterImpl(), new TelecomServiceImpl.SettingsSecureAdapterImpl(), mLock); } finally { Log.endSession(); } } @VisibleForTesting public PhoneAccountRegistrar getPhoneAccountRegistrar() { Loading tests/src/com/android/server/telecom/tests/ComponentContextFixture.java +5 −0 Original line number Diff line number Diff line Loading @@ -359,6 +359,11 @@ public class ComponentContextFixture implements TestFixture<Context> { return PackageManager.PERMISSION_GRANTED; } @Override public int checkSelfPermission(String permission) { return PackageManager.PERMISSION_GRANTED; } @Override public void enforceCallingOrSelfPermission(String permission, String message) { // Don't bother enforcing anything in mock. Loading tests/src/com/android/server/telecom/tests/SessionTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,36 @@ public class SessionTest extends TelecomTestCase { } } /** * Ensure creating two sessions and setting the child as the parent to itself doesn't cause a * crash due to infinite recursion. */ @SmallTest @Test public void testRecursion_toString_childCircDep() { Log.startSession("testParent"); // Running in the same thread, so mark as invisible subsession Session childSession = Log.getSessionManager() .createSubsession(true /*isStartedFromActiveSession*/); Log.continueSession(childSession, "child"); Session parentSession = childSession.getParentSession(); // Create a circular dependency and ensure we do not crash childSession.setParentSession(childSession); // Make sure calling these methods does not result in a crash try { parentSession.toString(); childSession.toString(); } catch (Exception e) { fail("Exception: " + e.getMessage()); } finally { // End child Log.endSession(); // End parent Log.endSession(); } } /** * Ensure creating two sessions that are parent/child of each other does not lead to a crash * or infinite recursion when using Session#getInfo. Loading tests/src/com/android/server/telecom/tests/TelecomSystemTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -365,7 +365,7 @@ public class TelecomSystemTest extends TelecomTestCase { // Next, create the TelecomSystem, our system under test setupTelecomSystem(); // Need to reset teseting tag here // Need to reset testing tag here Log.setTag(TESTING_TAG); // Finally, register the ConnectionServices with the PhoneAccountRegistrar of the Loading Loading @@ -401,11 +401,9 @@ public class TelecomSystemTest extends TelecomTestCase { mConnectionServiceFixtureA.waitForHandlerToClear(); mConnectionServiceFixtureB.waitForHandlerToClear(); // Print out any incomplete sessions for debugging tests String sessions = Log.getSessionManager().printActiveSessions(); if (!TextUtils.isEmpty(sessions)) { Log.w(this, "Active Sessions:\n" + sessions); } // Forcefully clean all sessions at the end of the test, which will also log any stale // sessions for debugging. Log.getSessionManager().cleanupStaleSessions(0); mTelecomSystem = null; super.tearDown(); Loading Loading
src/com/android/server/telecom/TelecomSystem.java +194 −188 Original line number Diff line number Diff line Loading @@ -217,6 +217,7 @@ public class TelecomSystem { defaultDialerAdapter, roleManagerAdapter, mLock); Log.startSession("TS.init"); try { mPhoneAccountRegistrar = new PhoneAccountRegistrar(mContext, defaultDialerCache, packageName -> AppLabelProxy.Util.getAppLabel( mContext.getPackageManager(), packageName)); Loading @@ -241,8 +242,8 @@ public class TelecomSystem { SystemStateHelper systemStateHelper = new SystemStateHelper(mContext); mMissedCallNotifier = missedCallNotifierImplFactory .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar, defaultDialerCache, deviceIdleControllerAdapter); .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar, defaultDialerCache, deviceIdleControllerAdapter); DisconnectedCallNotifier.Factory disconnectedCallNotifierFactory = new DisconnectedCallNotifier.Default(); Loading Loading @@ -304,8 +305,8 @@ public class TelecomSystem { ToastFactory toastFactory = new ToastFactory() { @Override public Toast makeText(Context context, int resId, int duration) { return Toast.makeText(context, context.getMainLooper(), context.getString(resId), duration); return Toast.makeText(context, context.getMainLooper(), context.getString(resId), duration); } @Override Loading Loading @@ -378,14 +379,16 @@ public class TelecomSystem { mContext.registerReceiverAsUser(mBootCompletedReceiver, UserHandle.ALL, BOOT_COMPLETE_FILTER, null, null); // Set current user explicitly since USER_SWITCHED_FILTER intent can be missed at startup // Set current user explicitly since USER_SWITCHED_FILTER intent can be missed at // startup synchronized (mLock) { UserHandle currentUserHandle = UserHandle.of(ActivityManager.getCurrentUser()); mPhoneAccountRegistrar.setCurrentUserHandle(currentUserHandle); mCallsManager.onUserSwitch(currentUserHandle); } mCallIntentProcessor = new CallIntentProcessor(mContext, mCallsManager, defaultDialerCache); mCallIntentProcessor = new CallIntentProcessor(mContext, mCallsManager, defaultDialerCache); mTelecomBroadcastIntentProcessor = new TelecomBroadcastIntentProcessor( mContext, mCallsManager); Loading @@ -401,7 +404,8 @@ public class TelecomSystem { new CallIntentProcessor.AdapterImpl(defaultDialerCache), new UserCallIntentProcessorFactory() { @Override public UserCallIntentProcessor create(Context context, UserHandle userHandle) { public UserCallIntentProcessor create(Context context, UserHandle userHandle) { return new UserCallIntentProcessor(context, userHandle); } }, Loading @@ -409,8 +413,10 @@ public class TelecomSystem { new TelecomServiceImpl.SubscriptionManagerAdapterImpl(), new TelecomServiceImpl.SettingsSecureAdapterImpl(), mLock); } finally { Log.endSession(); } } @VisibleForTesting public PhoneAccountRegistrar getPhoneAccountRegistrar() { Loading
tests/src/com/android/server/telecom/tests/ComponentContextFixture.java +5 −0 Original line number Diff line number Diff line Loading @@ -359,6 +359,11 @@ public class ComponentContextFixture implements TestFixture<Context> { return PackageManager.PERMISSION_GRANTED; } @Override public int checkSelfPermission(String permission) { return PackageManager.PERMISSION_GRANTED; } @Override public void enforceCallingOrSelfPermission(String permission, String message) { // Don't bother enforcing anything in mock. Loading
tests/src/com/android/server/telecom/tests/SessionTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,36 @@ public class SessionTest extends TelecomTestCase { } } /** * Ensure creating two sessions and setting the child as the parent to itself doesn't cause a * crash due to infinite recursion. */ @SmallTest @Test public void testRecursion_toString_childCircDep() { Log.startSession("testParent"); // Running in the same thread, so mark as invisible subsession Session childSession = Log.getSessionManager() .createSubsession(true /*isStartedFromActiveSession*/); Log.continueSession(childSession, "child"); Session parentSession = childSession.getParentSession(); // Create a circular dependency and ensure we do not crash childSession.setParentSession(childSession); // Make sure calling these methods does not result in a crash try { parentSession.toString(); childSession.toString(); } catch (Exception e) { fail("Exception: " + e.getMessage()); } finally { // End child Log.endSession(); // End parent Log.endSession(); } } /** * Ensure creating two sessions that are parent/child of each other does not lead to a crash * or infinite recursion when using Session#getInfo. Loading
tests/src/com/android/server/telecom/tests/TelecomSystemTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -365,7 +365,7 @@ public class TelecomSystemTest extends TelecomTestCase { // Next, create the TelecomSystem, our system under test setupTelecomSystem(); // Need to reset teseting tag here // Need to reset testing tag here Log.setTag(TESTING_TAG); // Finally, register the ConnectionServices with the PhoneAccountRegistrar of the Loading Loading @@ -401,11 +401,9 @@ public class TelecomSystemTest extends TelecomTestCase { mConnectionServiceFixtureA.waitForHandlerToClear(); mConnectionServiceFixtureB.waitForHandlerToClear(); // Print out any incomplete sessions for debugging tests String sessions = Log.getSessionManager().printActiveSessions(); if (!TextUtils.isEmpty(sessions)) { Log.w(this, "Active Sessions:\n" + sessions); } // Forcefully clean all sessions at the end of the test, which will also log any stale // sessions for debugging. Log.getSessionManager().cleanupStaleSessions(0); mTelecomSystem = null; super.tearDown(); Loading