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

Commit b675e556 authored by Jordan Liu's avatar Jordan Liu
Browse files

ServiceStateTracker notifies via ContentProvider

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
parent 35bbf2ba
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@


package com.android.internal.telephony;
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 static com.android.internal.telephony.CarrierActionAgent.CARRIER_ACTION_SET_RADIO_ENABLED;


import android.app.AlarmManager;
import android.app.AlarmManager;
@@ -2842,8 +2845,13 @@ public class ServiceStateTracker extends Handler {


            setRoamingType(mSS);
            setRoamingType(mSS);
            log("Broadcasting ServiceState : " + mSS);
            log("Broadcasting ServiceState : " + mSS);
            // notify using PhoneStateListener and the legacy intent ACTION_SERVICE_STATE_CHANGED
            mPhone.notifyServiceStateChanged(mSS);
            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);
            TelephonyMetrics.getInstance().writeServiceStateChanged(mPhone.getPhoneId(), mSS);
        }
        }


+2 −0
Original line number Original line Diff line number Diff line
@@ -58,6 +58,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
import android.preference.PreferenceManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Settings;
import android.provider.Telephony.ServiceStateTable;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
@@ -529,6 +530,7 @@ public class ContextFixture implements TestFixture<Context> {
        doReturn(mConfiguration).when(mResources).getConfiguration();
        doReturn(mConfiguration).when(mResources).getConfiguration();


        mContentResolver.addProvider(Settings.AUTHORITY, mContentProvider);
        mContentResolver.addProvider(Settings.AUTHORITY, mContentProvider);
        mContentResolver.addProvider(ServiceStateTable.AUTHORITY, mContentProvider);
        mPermissionTable.add(PERMISSION_ENABLE_ALL);
        mPermissionTable.add(PERMISSION_ENABLE_ALL);
    }
    }