abertschi / ad-free

A modularized audio ad blocker for Android
https://abertschi.ch/blog/2022/building-adfree/
Apache License 2.0
272 stars 19 forks source link

Extend AccuradioDetector to bigcontentview #93

Open abertschi opened 7 months ago

abertschi commented 7 months ago

AccuradioDetector only parses contentview, extend it to include (now deprecated) bigcontentview.

https://developer.android.com/reference/android/app/Notification#bigContentView

</android.service.notification.StatusBarNotification><android.service.notification.StatusBarNotification>
  <groupKey>0|com.slipstream.accuradio|101|null|10295</groupKey>
  <id>101</id>
  <initialPid>5166</initialPid>
  <key>0|com.slipstream.accuradio|101|null|10295</key>
  <notification>
    <allPendingIntents>
      <mArray>
        <android.app.PendingIntent>
          <mTarget class="android.content.IIntentSender$Stub$Proxy">
            <mRemote class="android.os.BinderProxy"/>
          </mTarget>
          <mWhitelistToken class="android.os.BinderProxy"/>
        </android.app.PendingIntent>
        <android.app.PendingIntent>
          <mTarget class="android.content.IIntentSender$Stub$Proxy">
            <mRemote class="android.os.BinderProxy"/>
          </mTarget>
          <mWhitelistToken class="android.os.BinderProxy" reference="../../android.app.PendingIntent/mWhitelistToken"/>
        </android.app.PendingIntent>
      </mArray>
      <mHashes>
        <int>98166312</int>
        <int>215441217</int>
      </mHashes>
      <mIdentityHashCode>false</mIdentityHashCode>
      <mSize>2</mSize>
    </allPendingIntents>
    <audioAttributes>
      <mContentType>4</mContentType>
      <mFlags>2048</mFlags>
      <mFormattedTags></mFormattedTags>
      <mSource>-1</mSource>
      <mTags/>
      <mUsage>5</mUsage>
    </audioAttributes>
    <audioStreamType>-1</audioStreamType>
    <bigContentView>
      <mActions>
        <android.widget.RemoteViews_-ReflectionAction>
          <viewId>2131296728</viewId>
          <methodName>setVisibility</methodName>
          <value class="int">8</value>
        </android.widget.RemoteViews_-ReflectionAction>
        <android.widget.RemoteViews_-ReflectionAction>
          <viewId>2131296758</viewId>
          <methodName>setVisibility</methodName>
          <value class="int">8</value>
        </android.widget.RemoteViews_-ReflectionAction>
        <android.widget.RemoteViews_-ReflectionAction>
          <viewId>2131296800</viewId>
          <methodName>setVisibility</methodName>
          <value class="int">8</value>
        </android.widget.RemoteViews_-ReflectionAction>
        <android.widget.RemoteViews_-ReflectionAction>
          <viewId>2131296703</viewId>
          <methodName>setText</methodName>
          <value class="string"></value>
        </android.widget.RemoteViews_-ReflectionAction>
        <android.widget.RemoteViews_-ReflectionAction>
          <viewId>2131296702</viewId>
          <methodName>setText</methodName>
          <value class="string">Music will resume shortly...</value>
        </android.widget.RemoteViews_-ReflectionAction>
        <android.widget.RemoteViews_-ReflectionAction>
          <viewId>2131296399</viewId>
          <methodName>setText</methodName>
          <value class="string">1980s Hits</value>
        </android.widget.RemoteViews_-ReflectionAction>
        <android.widget.RemoteViews_-ReflectionAction>
          <viewId>2131296810</viewId>
          <methodName>setImageResource</methodName>
          <value class="int">2131230805</value>
        </android.widget.RemoteViews_-ReflectionAction>
        <android.widget.RemoteViews_-SetOnClickResponse>
          <viewId>2131296758</viewId>
        </android.widget.RemoteViews_-SetOnClickResponse>
      </mActions>
      <mApplication>
        <banner>0</banner>
        <icon>2131230927</icon>
        <labelRes>2131755044</labelRes>
        <logo>0</logo>
        <name>com.slipstream.accuradio.AccuRadioApplication</name>
        <packageName>com.slipstream.accuradio</packageName>
        <showUserIcon>-10000</showUserIcon>
        <appComponentFactory>androidx.core.app.CoreComponentFactory</appComponentFactory>
        <category>-1</category>
        <className>com.slipstream.accuradio.AccuRadioApplication</className>
        <compatibleWidthLimitDp>0</compatibleWidthLimitDp>
        <compileSdkVersion>31</compileSdkVersion>
        <compileSdkVersionCodename>12</compileSdkVersionCodename>
        <credentialProtectedDataDir>/data/user/0/com.slipstream.accuradio</credentialProtectedDataDir>
        <dataDir>/data/user/0/com.slipstream.accuradio</dataDir>
        <descriptionRes>0</descriptionRes>
        <deviceProtectedDataDir>/data/user_de/0/com.slipstream.accuradio</deviceProtectedDataDir>
        <enabled>true</enabled>
        <enabledSetting>0</enabledSetting>
        <flags>551075396</flags>
        <fullBackupContent>0</fullBackupContent>
        <installLocation>-1</installLocation>
        <largestWidthLimitDp>0</largestWidthLimitDp>
        <longVersionCode>83</longVersionCode>
        <mHiddenApiPolicy>-1</mHiddenApiPolicy>
        <maxAspectRatio>0.0</maxAspectRatio>
        <minSdkVersion>23</minSdkVersion>

83 @unseenlarks

abertschi commented 7 months ago
unseenlarks commented 7 months ago

thank you for looking into this. :)

abertschi commented 7 months ago

Fixed in #94

unseenlarks commented 7 months ago

much appreciated, will grab the .apk ASAP.

abertschi commented 7 months ago

also i use the device in dark mode and the smaller notifications the app gives (for example when enabling developer mode, then a tracer for a specific app), are hard to read.

Can you post a screenshot showing what is hard to read?

abertschi commented 7 months ago

And ideally a screenshot of the notification when the ad occurs (and not being detected). Will look again at the tracing dump file. It's a bit hard to troubleshoot as the issue seems device/ OS specific. I did not have this issue on my phone. What phone do you have?

abertschi commented 7 months ago

The new generic text detector should now be able to detect any text in the notification, supposing the text is text and not an image. Enabling best effort and user defined text detector (with the ad string) does not fix the issue?

abertschi commented 7 months ago

The most recent tracing file does not contain an Ad with the text: "Music will resume shortly..". Did you record the old tracing file with the same version of Android 13? If so we do not need a new tracing file. Otherwise, could you create another tracing file and ensure that you can capture an ad?. many thanks :)

unseenlarks commented 7 months ago

moto g32 running Android 13. the log i originally sent in November had the device still on Android 12.

i set battery optimisation to unrestricted, and always-on notifications to on, but the settings didn't apply until i restarted the device.

after that, the notification appeared, as shown on screenshot, but ad was not muted. maybe this app's developers have managed something, to make the ad not register as one? adfree

text i can't read is shown here. text

sharing the log again, in case it contains something new after the reboot. adfree-accuradio.txt

unseenlarks commented 7 months ago

i don't know if it will help, but for this log i restarted the station three times, so three "Music will resume shortly..." ads would play. adfree-accuradio.txt