Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8eecf37a authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Don't return null in the default ActivityManagerService.Injector."

parents 3d13c27d 5269e502
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -2419,7 +2419,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    // handlers to other threads.  So take care to be explicit about the looper.
    public ActivityManagerService(Context systemContext, ActivityTaskManagerService atm) {
        LockGuard.installLock(this, LockGuard.INDEX_ACTIVITY);
        mInjector = new Injector();
        mInjector = new Injector(systemContext);
        mContext = systemContext;
        mFactoryTest = FactoryTest.getMode();
@@ -18898,9 +18898,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    @VisibleForTesting
    public static class Injector {
        private NetworkManagementInternal mNmi;
        private Context mContext;
        public Injector(Context context) {
            mContext = context;
        }
        public Context getContext() {
            return null;
            return mContext;
        }
        public AppOpsService getAppOpsService(File file, Handler handler) {
+8 −6
Original line number Diff line number Diff line
@@ -82,7 +82,9 @@ public final class AppCompactorTest {
                true /* allowIo */);
        mThread.start();

        ActivityManagerService ams = new ActivityManagerService(new TestInjector(), mThread);
        ActivityManagerService ams = new ActivityManagerService(
                new TestInjector(InstrumentationRegistry.getInstrumentation().getContext()),
                mThread);
        mCompactorUnderTest = new AppCompactor(ams,
                new AppCompactor.PropertyChangedCallbackForTest() {
                    @Override
@@ -660,6 +662,11 @@ public final class AppCompactorTest {
    }

    private class TestInjector extends Injector {

        TestInjector(Context context) {
            super(context);
        }

        @Override
        public AppOpsService getAppOpsService(File file, Handler handler) {
            return mAppOpsService;
@@ -669,10 +676,5 @@ public final class AppCompactorTest {
        public Handler getUiHandler(ActivityManagerService service) {
            return mHandler;
        }

        @Override
        public Context getContext() {
            return InstrumentationRegistry.getInstrumentation().getContext();
        }
    }
}
+3 −4
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class ActivityManagerServiceTest {
        mHandlerThread = new HandlerThread(TAG);
        mHandlerThread.start();
        mHandler = new TestHandler(mHandlerThread.getLooper());
        mInjector = new TestInjector();
        mInjector = new TestInjector(mContext);
        mAms = new ActivityManagerService(mInjector, mServiceThreadRule.getThread());
        mAms.mWaitForNetworkTimeoutMs = 2000;
        mAms.mActivityTaskManager = new ActivityTaskManagerService(mContext);
@@ -920,9 +920,8 @@ public class ActivityManagerServiceTest {
    private class TestInjector extends Injector {
        private boolean mRestricted = true;

        @Override
        public Context getContext() {
            return mContext;
        TestInjector(Context context) {
            super(context);
        }

        @Override
+1 −6
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public class AppErrorDialogTest {
    @Before
    public void setUp() throws Exception {
        mContext = getInstrumentation().getTargetContext();
        mService = new ActivityManagerService(new ActivityManagerService.Injector() {
        mService = new ActivityManagerService(new ActivityManagerService.Injector(mContext) {
            @Override
            public AppOpsService getAppOpsService(File file, Handler handler) {
                return null;
@@ -66,11 +66,6 @@ public class AppErrorDialogTest {
            public boolean isNetworkRestrictedForUid(int uid) {
                return false;
            }

            @Override
            public Context getContext() {
                return mContext;
            }
        }, mServiceThreadRule.getThread());
        mService.mActivityTaskManager = new ActivityTaskManagerService(mContext);
        mService.mActivityTaskManager.initialize(null, null, mContext.getMainLooper());
+5 −4
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ public class CoreSettingsObserverTest {
        mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
        when(mContext.getContentResolver()).thenReturn(mContentResolver);

        mAms = new ActivityManagerService(new TestInjector(), mServiceThreadRule.getThread());
        mAms = new ActivityManagerService(new TestInjector(mContext),
                mServiceThreadRule.getThread());
        mCoreSettingsObserver = new CoreSettingsObserver(mAms);
    }

@@ -158,9 +159,9 @@ public class CoreSettingsObserverTest {
    }

    private class TestInjector extends Injector {
        @Override
        public Context getContext() {
            return getInstrumentation().getContext();

        TestInjector(Context context) {
            super(context);
        }

        @Override
Loading