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

Commit 9b206fc7 authored by Megha Patil's avatar Megha Patil
Browse files

Adding Test API to send Memory Status Event For CTS

- Send memory status to SmsStorageMonitor
- Bug: b/255881498

Test: atest CtsTelephonyTestCases:ImsServiceTest
Change-Id: Ifc32053af59c81193b8a47a1ef7d4a839ecfcbf7
(cherry picked from commit 4700b7e73d03cd4fcb29a1956ec453c1af79184a)
parent ed43afff
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2633,6 +2633,8 @@ package android.telephony {

  public final class SmsManager {
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int checkSmsShortCodeDestination(String, String);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void clearStorageMonitorMemoryStatusOverride();
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setStorageMonitorMemoryStatusOverride(boolean);
    field public static final int SMS_CATEGORY_FREE_SHORT_CODE = 1; // 0x1
    field public static final int SMS_CATEGORY_NOT_SHORT_CODE = 0; // 0x0
    field public static final int SMS_CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE = 3; // 0x3
+37 −0
Original line number Diff line number Diff line
@@ -3125,6 +3125,43 @@ public final class SmsManager {
        }
    }

    /**
     * Set Storage Availability in SmsStorageMonitor
     * @param storageAvailable storage availability to be set true or false
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    @TestApi
    public void setStorageMonitorMemoryStatusOverride(boolean storageAvailable) {
        try {
            ISms iccISms = getISmsServiceOrThrow();
            if (iccISms != null) {
                iccISms.setStorageMonitorMemoryStatusOverride(getSubscriptionId(),
                                                                storageAvailable);
            }
        } catch (RemoteException ex) {
            ex.rethrowFromSystemServer();
        }
    }

    /**
     * Clear the memory status override set by
     * {@link #setStorageMonitorMemoryStatusOverride(boolean)}
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    @TestApi
    public void clearStorageMonitorMemoryStatusOverride() {
        try {
            ISms iccISms = getISmsServiceOrThrow();
            if (iccISms != null) {
                iccISms.clearStorageMonitorMemoryStatusOverride(getSubscriptionId());
            }
        } catch (RemoteException ex) {
            ex.rethrowFromSystemServer();
        }
    }

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"SMS_CATEGORY_"},
+19 −0
Original line number Diff line number Diff line
@@ -529,6 +529,25 @@ interface ISms {
    String createAppSpecificSmsTokenWithPackageInfo(
            int subId, String callingPkg, String prefixes, in PendingIntent intent);

    /**
     * set Memory Status in SmsStorageMonitor
     *
     * @param subId the subscription Id.
     * @param callingPackage the package name of the calling app.
     * @param isStorageAvailable sets StorageAvailable to false or true
     *   for testing behaviour of SmsStorageMonitor
     */
    void setStorageMonitorMemoryStatusOverride(int subId, boolean isStorageAvailable);

     /**
     * reset Memory Status change made by TestApi setStorageMonitorMemoryStatusOverride
     * in SmsStorageMonitor
     *
     * @param subId the subscription Id.
     * @param callingPackage the package name of the calling app.
     */
    void clearStorageMonitorMemoryStatusOverride(int subId);

    /**
     * Check if the destination is a possible premium short code.
     *
+10 −0
Original line number Diff line number Diff line
@@ -191,6 +191,16 @@ public class ISmsImplBase extends ISms.Stub {
        throw new UnsupportedOperationException();
    }

    @Override
    public void setStorageMonitorMemoryStatusOverride(int subId, boolean storageAvailable) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void clearStorageMonitorMemoryStatusOverride(int subId) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int checkSmsShortCodeDestination(int subid, String callingPackage,
            String callingFeatureId, String destAddress, String countryIso) {