Loading services/core/java/com/android/server/tv/TvRemoteProviderWatcher.java +6 −2 Original line number Diff line number Diff line Loading @@ -59,9 +59,9 @@ final class TvRemoteProviderWatcher { private boolean mRunning; TvRemoteProviderWatcher(Context context, Object lock) { TvRemoteProviderWatcher(Context context, Object lock, Handler handler) { mContext = context; mHandler = new Handler(true); mHandler = handler; mUserId = UserHandle.myUserId(); mPackageManager = context.getPackageManager(); mLock = lock; Loading @@ -79,6 +79,10 @@ final class TvRemoteProviderWatcher { }); } TvRemoteProviderWatcher(Context context, Object lock) { this(context, lock, new Handler(true)); } public void start() { if (DEBUG) Slog.d(TAG, "start()"); if (!mRunning) { Loading services/tests/servicestests/src/com/android/server/tv/TvRemoteProviderWatcherTest.java +15 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import androidx.test.filters.SmallTest; Loading Loading @@ -88,7 +89,12 @@ public class TvRemoteProviderWatcherTest { // Test intentionally includes empty spacing for a more complex test when(mMockResources.getString(com.android.internal.R.string.config_tvRemoteServicePackage)) .thenReturn(",,foo, " + TV_REMOTE_SERVICE_PACKAGE_NAME + ",bar, baz,,"); assertTrue(mTvRemoteProviderWatcher.verifyServiceTrusted(createTvServiceInfo())); // Re-create the object since package name is loaded in the constructor TvRemoteProviderWatcher watcher = new TvRemoteProviderWatcher( mMockContext, new Object(), new Handler(Looper.getMainLooper())); assertTrue(watcher.verifyServiceTrusted(createTvServiceInfo())); } @Test Loading @@ -96,7 +102,12 @@ public class TvRemoteProviderWatcherTest { // Checks include empty strings to validate that processing as well when(mMockResources.getString(com.android.internal.R.string.config_tvRemoteServicePackage)) .thenReturn(",,foo,, ,bar, baz,,"); assertFalse(mTvRemoteProviderWatcher.verifyServiceTrusted(createTvServiceInfo())); // Re-create the object since package name is loaded in the constructor TvRemoteProviderWatcher watcher = new TvRemoteProviderWatcher( mMockContext, new Object(), new Handler(Looper.getMainLooper())); assertFalse(watcher.verifyServiceTrusted(createTvServiceInfo())); } @Test Loading Loading @@ -139,14 +150,9 @@ public class TvRemoteProviderWatcherTest { public void whitelistingPackageNameIsRequired() { reset(mMockResources); when(mMockResources.getString(anyInt())).thenReturn(""); // Create a new watcher, as the resources are read in the constructor of the class if (Looper.myLooper() == null) { Looper.prepare(); } TvRemoteProviderWatcher watcher = new TvRemoteProviderWatcher(mMockContext, new Object()); new TvRemoteProviderWatcher( mMockContext, new Object(), new Handler(Looper.getMainLooper())); assertFalse(watcher.verifyServiceTrusted(createTvServiceInfo())); } Loading Loading
services/core/java/com/android/server/tv/TvRemoteProviderWatcher.java +6 −2 Original line number Diff line number Diff line Loading @@ -59,9 +59,9 @@ final class TvRemoteProviderWatcher { private boolean mRunning; TvRemoteProviderWatcher(Context context, Object lock) { TvRemoteProviderWatcher(Context context, Object lock, Handler handler) { mContext = context; mHandler = new Handler(true); mHandler = handler; mUserId = UserHandle.myUserId(); mPackageManager = context.getPackageManager(); mLock = lock; Loading @@ -79,6 +79,10 @@ final class TvRemoteProviderWatcher { }); } TvRemoteProviderWatcher(Context context, Object lock) { this(context, lock, new Handler(true)); } public void start() { if (DEBUG) Slog.d(TAG, "start()"); if (!mRunning) { Loading
services/tests/servicestests/src/com/android/server/tv/TvRemoteProviderWatcherTest.java +15 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import androidx.test.filters.SmallTest; Loading Loading @@ -88,7 +89,12 @@ public class TvRemoteProviderWatcherTest { // Test intentionally includes empty spacing for a more complex test when(mMockResources.getString(com.android.internal.R.string.config_tvRemoteServicePackage)) .thenReturn(",,foo, " + TV_REMOTE_SERVICE_PACKAGE_NAME + ",bar, baz,,"); assertTrue(mTvRemoteProviderWatcher.verifyServiceTrusted(createTvServiceInfo())); // Re-create the object since package name is loaded in the constructor TvRemoteProviderWatcher watcher = new TvRemoteProviderWatcher( mMockContext, new Object(), new Handler(Looper.getMainLooper())); assertTrue(watcher.verifyServiceTrusted(createTvServiceInfo())); } @Test Loading @@ -96,7 +102,12 @@ public class TvRemoteProviderWatcherTest { // Checks include empty strings to validate that processing as well when(mMockResources.getString(com.android.internal.R.string.config_tvRemoteServicePackage)) .thenReturn(",,foo,, ,bar, baz,,"); assertFalse(mTvRemoteProviderWatcher.verifyServiceTrusted(createTvServiceInfo())); // Re-create the object since package name is loaded in the constructor TvRemoteProviderWatcher watcher = new TvRemoteProviderWatcher( mMockContext, new Object(), new Handler(Looper.getMainLooper())); assertFalse(watcher.verifyServiceTrusted(createTvServiceInfo())); } @Test Loading Loading @@ -139,14 +150,9 @@ public class TvRemoteProviderWatcherTest { public void whitelistingPackageNameIsRequired() { reset(mMockResources); when(mMockResources.getString(anyInt())).thenReturn(""); // Create a new watcher, as the resources are read in the constructor of the class if (Looper.myLooper() == null) { Looper.prepare(); } TvRemoteProviderWatcher watcher = new TvRemoteProviderWatcher(mMockContext, new Object()); new TvRemoteProviderWatcher( mMockContext, new Object(), new Handler(Looper.getMainLooper())); assertFalse(watcher.verifyServiceTrusted(createTvServiceInfo())); } Loading