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

Commit a991f497 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "SMS service: add feature flag by global settting / config.xml"

parents ec5c04f4 7a2d35e9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3550,4 +3550,7 @@

    <!-- Pre-scale volume at volume step 3 for Absolute Volume -->
    <fraction name="config_prescaleAbsoluteVolume_index3">85%</fraction>

    <!-- Whether or not the "SMS app service" feature is enabled -->
    <bool name="config_useSmsAppService">true</bool>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -3475,4 +3475,6 @@
  <java-symbol type="fraction" name="config_prescaleAbsoluteVolume_index1" />
  <java-symbol type="fraction" name="config_prescaleAbsoluteVolume_index2" />
  <java-symbol type="fraction" name="config_prescaleAbsoluteVolume_index3" />

  <java-symbol type="bool" name="config_useSmsAppService" />
</resources>
+17 −1
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ public class AppBindingConstants {
    private static final String SERVICE_STABLE_CONNECTION_THRESHOLD_SEC_KEY =
            "service_stable_connection_threshold_sec";

    private static final String SMS_SERVICE_ENABLED_KEY =
            "sms_service_enabled";

    private static final String SMS_APP_BIND_FLAGS_KEY =
            "sms_app_bind_flags";

@@ -66,6 +69,11 @@ public class AppBindingConstants {
     */
    public final long SERVICE_STABLE_CONNECTION_THRESHOLD_SEC;

    /**
     * Whether to actually bind to the default SMS app service. (Feature flag)
     */
    public final boolean SMS_SERVICE_ENABLED;

    /**
     * Extra binding flags for SMS service.
     */
@@ -92,6 +100,8 @@ public class AppBindingConstants {
        long serviceReconnectMaxBackoffSec = parser.getLong(
                SERVICE_RECONNECT_MAX_BACKOFF_SEC_KEY, TimeUnit.HOURS.toSeconds(1));

        boolean smsServiceEnabled = parser.getBoolean(SMS_SERVICE_ENABLED_KEY, true);

        int smsAppBindFlags = parser.getInt(
                SMS_APP_BIND_FLAGS_KEY,
                Context.BIND_NOT_VISIBLE | Context.BIND_FOREGROUND_SERVICE);
@@ -114,6 +124,7 @@ public class AppBindingConstants {
        SERVICE_RECONNECT_BACKOFF_INCREASE = serviceReconnectBackoffIncrease;
        SERVICE_RECONNECT_MAX_BACKOFF_SEC = serviceReconnectMaxBackoffSec;
        SERVICE_STABLE_CONNECTION_THRESHOLD_SEC = serviceStableConnectionThresholdSec;
        SMS_SERVICE_ENABLED = smsServiceEnabled;
        SMS_APP_BIND_FLAGS = smsAppBindFlags;
    }

@@ -129,7 +140,8 @@ public class AppBindingConstants {
     */
    public void dump(String prefix, PrintWriter pw) {
        pw.print(prefix);
        pw.println("Constants:");
        pw.print("Constants: ");
        pw.println(sourceSettings);

        pw.print(prefix);
        pw.print("  SERVICE_RECONNECT_BACKOFF_SEC: ");
@@ -147,6 +159,10 @@ public class AppBindingConstants {
        pw.print("  SERVICE_STABLE_CONNECTION_THRESHOLD_SEC: ");
        pw.println(SERVICE_STABLE_CONNECTION_THRESHOLD_SEC);

        pw.print(prefix);
        pw.print("  SMS_SERVICE_ENABLED: ");
        pw.println(SMS_SERVICE_ENABLED);

        pw.print(prefix);
        pw.print("  SMS_APP_BIND_FLAGS: 0x");
        pw.println(Integer.toHexString(SMS_APP_BIND_FLAGS));
+1 −1
Original line number Diff line number Diff line
@@ -422,7 +422,7 @@ public class AppBindingService extends Binder {
                unbindServicesLocked(userId, target, reasonForLog);
            }

            final ServiceInfo service = app.findService(userId, mIPackageManager);
            final ServiceInfo service = app.findService(userId, mIPackageManager, mConstants);
            if (service == null) {
                continue;
            }
+14 −1
Original line number Diff line number Diff line
@@ -69,6 +69,11 @@ public abstract class AppServiceFinder<TServiceType, TServiceInterfaceType exten
        mHandler = callbackHandler;
    }

    /** Whether this service should really be enabled. */
    protected boolean isEnabled(AppBindingConstants constants) {
        return true;
    }

    /** Human readable description of the type of apps; e.g. [Default SMS app] */
    @NonNull
    public abstract String getAppDescription();
@@ -90,12 +95,20 @@ public abstract class AppServiceFinder<TServiceType, TServiceInterfaceType exten
     * Find the target service from the target app on a given user.
     */
    @Nullable
    public final ServiceInfo findService(int userId, IPackageManager ipm) {
    public final ServiceInfo findService(int userId, IPackageManager ipm,
            AppBindingConstants constants) {
        synchronized (mLock) {
            mTargetPackages.put(userId, null);
            mTargetServices.put(userId, null);
            mLastMessages.put(userId, null);

            if (!isEnabled(constants)) {
                final String message = "feature disabled";
                mLastMessages.put(userId, message);
                Slog.i(TAG, getAppDescription() + " " + message);
                return null;
            }

            final String targetPackage = getTargetPackage(userId);
            if (DEBUG) {
                Slog.d(TAG, getAppDescription() + " package=" + targetPackage);
Loading