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

Commit e5ff3158 authored by Hani Kazmi's avatar Hani Kazmi Committed by Android (Google) Code Review
Browse files

Merge "[AAPM} Catch exceptions thrown by AdvancedProtectionHooks." into main

parents 433c9135 22cd72d8
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -80,13 +80,25 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub

    private void initFeatures(boolean enabled) {
        if (android.security.Flags.aapmFeatureDisableInstallUnknownSources()) {
          try {
            mHooks.add(new DisallowInstallUnknownSourcesAdvancedProtectionHook(mContext, enabled));
          } catch (Exception e) {
            Slog.e(TAG, "Failed to initialize DisallowInstallUnknownSources", e);
          }
        }
        if (android.security.Flags.aapmFeatureMemoryTaggingExtension()) {
          try {
            mHooks.add(new MemoryTaggingExtensionHook(mContext, enabled));
          } catch (Exception e) {
            Slog.e(TAG, "Failed to initialize MemoryTaggingExtension", e);
          }
        }
        if (android.security.Flags.aapmFeatureDisableCellular2g()) {
          try {
            mHooks.add(new DisallowCellular2GAdvancedProtectionHook(mContext, enabled));
          } catch (Exception e) {
            Slog.e(TAG, "Failed to initialize DisallowCellular2g", e);
          }
        }
    }

@@ -278,9 +290,14 @@ public class AdvancedProtectionService extends IAdvancedProtectionService.Stub

            for (int i = 0; i < mHooks.size(); i++) {
                AdvancedProtectionHook feature = mHooks.get(i);
                try {
                    if (feature.isAvailable()) {
                        feature.onAdvancedProtectionChanged(enabled);
                    }
                } catch (Exception e) {
                    Slog.e(TAG, "Failed to call hook for feature "
                            + feature.getFeature().getId(), e);
                }
            }
            synchronized (mCallbacks) {
                for (int i = 0; i < mCallbacks.size(); i++) {