ServiceStateTracker notifies via ContentProvider
Jordan Liu [Tue, 7 Mar 2017 23:51:23 +0000 (15:51 -0800)]
ServiceStateTracker inserts updated ServiceStates into the provider.
Telephony.ServiceStateTable contains helper functions and constants for
interfacing with the ServiceStateProvider.

Also update ContextFixture so the unit tests doesn't fail when trying to
use the service-state authority

Bug: 33756364
Test: runtest --path ServiceStateTrackerTest
Change-Id: I6b07b54f803765bba4c014474926a825113ac952
Merged-In: I6b07b54f803765bba4c014474926a825113ac952

src/java/com/android/internal/telephony/ServiceStateTracker.java
tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java

index 1c6cfae..3445cf0 100644 (file)
@@ -16,6 +16,9 @@
 
 package com.android.internal.telephony;
 
+import static android.provider.Telephony.ServiceStateTable.getContentValuesForServiceState;
+import static android.provider.Telephony.ServiceStateTable.getUriForSubId;
+
 import static com.android.internal.telephony.CarrierActionAgent.CARRIER_ACTION_SET_RADIO_ENABLED;
 
 import android.app.AlarmManager;
@@ -2842,8 +2845,13 @@ public class ServiceStateTracker extends Handler {
 
             setRoamingType(mSS);
             log("Broadcasting ServiceState : " + mSS);
+            // notify using PhoneStateListener and the legacy intent ACTION_SERVICE_STATE_CHANGED
             mPhone.notifyServiceStateChanged(mSS);
 
+            // insert into ServiceStateProvider. This will trigger apps to wake through JobScheduler
+            mPhone.getContext().getContentResolver().insert(getUriForSubId(mPhone.getSubId()),
+                    getContentValuesForServiceState(mSS));
+
             TelephonyMetrics.getInstance().writeServiceStateChanged(mPhone.getPhoneId(), mSS);
         }
 
index d18da52..419e61b 100644 (file)
@@ -58,6 +58,7 @@ import android.os.UserHandle;
 import android.os.UserManager;
 import android.preference.PreferenceManager;
 import android.provider.Settings;
+import android.provider.Telephony.ServiceStateTable;
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
@@ -529,6 +530,7 @@ public class ContextFixture implements TestFixture<Context> {
         doReturn(mConfiguration).when(mResources).getConfiguration();
 
         mContentResolver.addProvider(Settings.AUTHORITY, mContentProvider);
+        mContentResolver.addProvider(ServiceStateTable.AUTHORITY, mContentProvider);
         mPermissionTable.add(PERMISSION_ENABLE_ALL);
     }