Revert "Delete outdated tests" and change the assertion.
Eng team now decided to expose NearbyManager to any app
but methods in NearbyManager need system permission to call.
More test cases will added in the following changes to make sure
untrusted app will FAIL to call methods in NearbyManager.
This reverts commit 48e9008783ab2d1e4d5e0e3cefaa398c71e316d8.
Reason for revert: Should change the test assertion condition instead delete the test
Ignore-AOSP-First: nearby_not_in_aosp_yet
Test: atest NearbyIntegrationUntrustedTests
Bug: 229310677
Change-Id: Id6c6523bd0afef14d65b27509583bc42f1925df9
diff --git a/nearby/tests/integration/untrusted/src/android/nearby/integration/untrusted/NearbyManagerTest.kt b/nearby/tests/integration/untrusted/src/android/nearby/integration/untrusted/NearbyManagerTest.kt
new file mode 100644
index 0000000..04c5e30
--- /dev/null
+++ b/nearby/tests/integration/untrusted/src/android/nearby/integration/untrusted/NearbyManagerTest.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.integration.untrusted
+
+import android.content.Context
+import android.nearby.NearbyManager
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class NearbyManagerTest {
+
+ /** Verify untrusted app can get Nearby service. */
+ @Test
+ fun testContextGetNearbyService_fromUnTrustedApp_returnsNotNull() {
+ val appContext = ApplicationProvider.getApplicationContext<Context>()
+ assertThat(appContext.getSystemService(Context.NEARBY_SERVICE)).isNotNull()
+ }
+}