Snap for 7588529 from 3c0824aec6a5d3dcf3da5759c92e10db59a6b74a to sc-v2-release
Change-Id: Id487be228fb32ab9848e9bd234c86dec9481dcd8
diff --git a/Android.bp b/Android.bp
index 3b65737..cd24b24 100644
--- a/Android.bp
+++ b/Android.bp
@@ -32,3 +32,11 @@
name: "telephonyprovider-assets-carrierlist",
srcs: ["assets/latest_carrier_id/carrier_list.*"],
}
+
+// used to share src with unit test app
+filegroup {
+ name: "telephonyprovider-shared-srcs",
+ srcs: [
+ "src/**/*.java",
+ ],
+}
diff --git a/src/com/android/providers/telephony/CarrierIdProvider.java b/src/com/android/providers/telephony/CarrierIdProvider.java
index 3e751aa..9b6c2c0 100644
--- a/src/com/android/providers/telephony/CarrierIdProvider.java
+++ b/src/com/android/providers/telephony/CarrierIdProvider.java
@@ -189,14 +189,17 @@
+ CarrierId.All.MCCMNC + ");";
}
+ static {
+ s_urlMatcher.addURI(AUTHORITY, "all", URL_ALL);
+ s_urlMatcher.addURI(AUTHORITY, "all/update_db", URL_ALL_UPDATE_FROM_PB);
+ s_urlMatcher.addURI(AUTHORITY, "all/get_version", URL_ALL_GET_VERSION);
+ }
+
@Override
public boolean onCreate() {
Log.d(TAG, "onCreate");
mDbHelper = new CarrierIdDatabaseHelper(getContext());
mDbHelper.getReadableDatabase();
- s_urlMatcher.addURI(AUTHORITY, "all", URL_ALL);
- s_urlMatcher.addURI(AUTHORITY, "all/update_db", URL_ALL_UPDATE_FROM_PB);
- s_urlMatcher.addURI(AUTHORITY, "all/get_version", URL_ALL_GET_VERSION);
updateDatabaseFromPb(mDbHelper.getWritableDatabase());
return true;
}
diff --git a/tests/Android.bp b/tests/Android.bp
index dafd7cd..8ecc370 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -23,7 +23,7 @@
"android.test.base",
"android.test.mock",
],
- srcs: ["src/**/*.java"],
+ srcs: ["src/**/*.java", ":telephonyprovider-shared-srcs"],
platform_apis: true,
test_suites: ["device-tests"],
certificate: "platform",
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 59fd8bd..e4e9e69 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -17,12 +17,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.providers.telephony.tests">
+ <!-- Permissions required for reading and logging compat changes -->
+ <uses-permission android:name="android.permission.LOG_COMPAT_CHANGE"/>
+ <uses-permission android:name="android.permission.READ_COMPAT_CHANGE_CONFIG"/>
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
+
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.providers.telephony"
+ android:targetPackage="com.android.providers.telephony.tests"
android:label="Tests for TelephonyProvider">
</instrumentation>
</manifest>
diff --git a/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java b/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java
index f8cc8a6..f6a9c7f 100644
--- a/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java
@@ -43,6 +43,8 @@
import android.util.JsonWriter;
import android.util.SparseArray;
+import com.android.internal.telephony.PhoneFactory;
+
import libcore.io.IoUtils;
import com.google.android.mms.pdu.CharacterSets;
@@ -620,6 +622,7 @@
*/
public void testRestoreSms_WithException() throws Exception {
mTelephonyBackupAgent.initUnknownSender();
+ PhoneFactory.addLocalLog("DeferredSmsMmsRestoreService", 1);
JsonReader jsonReader = new JsonReader(new StringReader(addRandomDataToJson(mAllSmsJson)));
FakeSmsProvider smsProvider = new FakeSmsProvider(mSmsRows, false);
mMockContentResolver.addProvider("sms", smsProvider);
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
index 37ba7ec..1a9b46c 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -45,7 +45,6 @@
import android.telephony.TelephonyManager;
import android.test.mock.MockContentResolver;
import android.test.mock.MockContext;
-import android.test.mock.MockResources;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.TextUtils;
import android.util.Log;
@@ -54,11 +53,14 @@
import junit.framework.TestCase;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
import org.mockito.Mock;
import static org.mockito.Mockito.when;
+import com.android.internal.telephony.PhoneFactory;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -1647,6 +1649,7 @@
assertEquals(1, cursor.getCount());
cursor.moveToFirst();
assertEquals(otherName, cursor.getString(0));
+ PhoneFactory.addLocalLog("TelephonyProvider", 1);
}
/**