Friday, October 3, 2025

Android Pixel 6 phone not all photos show up when connected via USB to computer

Introduction

I usually manually make copies of important photos on my Pixel 6 Android mobile phone via the USB-C cable. Just connect it to your computer and select in USB preferences (really strange location for these options, why is it not in USB settings...) File transfer / Android Auto.
Then the file explorer would open up and I can go to the DCIM/Camera folder and find all my photos on that phone.

But suddenly, it started around May 2025, I could only see pictures in that directory from May 2025 and newer! I could not see my pictures from before that time anymore in that directory.
On the phone itself I could still these older photos.

Solution

I found a few possible reasons, like this one, but that didn't work for me. Still couldn't find the photos from before May 2025 when connected via USB.
I did have for some vague reason Google Backup on for a few hours somewhere before that time. But switched it off again.

So what does it turn out to be: all photos from before May 2025 had moved to another directory! I for sure didn't do that - it would have taken quite a long time to move all these photos on my phone, hundreds of them.
So here's the difference I found out:

Where the photos usually are located:

So in the DCIM/Camera directory, as already mentioned in the introduction.
But all before May 2025 are now in this directory:




So in Music/DCIM/Camera! So they moved! But only those earlier than May 1 2025!

Luckily that directory is also accessible in the file explorer when connected via USB. My suspicion is that while I had the backup on, it moved those pictures to that other directory...

You can find the exact location of a picture in the Pixel Photos app by selecting the picture on your phone and swiping up. Then you see what you see in the above pictures, including the directory where it is stored on the device.




Monday, April 7, 2025

Spring Boot 3 serverside forwarding

Introduction

Sometimes you want to forward to another URL on the serverside in Spring Boot 3. 


The example in this blogpost is for forwarding to the Swagger JSON open-api-specification OAS /api-docs resource listing. You might need this when you want to protect that URL via Spring authentication, so it has to first come in to a controller, and only then forward it.

Solution

Below a new controller ApiController is created, with as endpoint GET /open-api. That has bearer authentication on it. And redirects to /apidocs/api-definition. For details on what api-definitions i.e grouped Open API definitions are, see here.

ModelAndView

Using a ModelAndView from Spring MVC:

  @RestController
  @SecurityRequirement(name = "bearerAuth")
  public class ApiController() {
    @Operation(
      summary = "Gets the OpenApi specification of the API",
    )
    @GetMapping("/open-api", produces = ["application/json"])
    @SecurityRequirement(name = AUTHORIZATION)
    fun getOpenApiSpecification(): ModelAndView {
      return ModelAndView("forward:/api-docs/api-definition")
    }

To have this show up in Swagger, also set in application.yml:

  springdoc:
    model-and-view-allowed: true

Servlet context

Using the servlet context, so you don't need a ModelAndView:

  @GetMapping("/open-api", produces = ["application/json"])
  @ResponseStatus(HttpStatus.OK)
  @SecurityRequirement(name = AUTHORIZATION)
  fun getOpenApiSpecification(request: HttpServletRequest, response: HttpServletResponse) {
    request.session.servletContext.getRequestDispatcher("/api-docs/api-definition").forward(request, response)
  }

This dependency is then also needed: 
  <dependency>
    <groupId>jakarta.servlet</groupId>
    <artifactId>jakarta.servlet-api</artifactId>
    <version>6.1.0</version>
  </dependency










Wednesday, April 2, 2025

How to mock Retrofit2 response Call in a unittest

Introduction

To mock a Retrofit2 call which returns Call<Void?> in the interface client like this:

    @POST("/events")

    fun registerEvent(@Body requestDto: EventRequestDto): Call<Void?>

is not super-obvious, since it can show this error when invoked:

    Cannot invoke "retrofit2.Call.request()" because "call$iv" is null

    java.lang.NullPointerException: Cannot invoke "retrofit2.Call.request()" because "call$iv" is null

Solution

    val mockedResponseRegisterEvent: Call<Void?> = retrofit2.mock.Calls.response(null)
    every { retrofitEventServiceClient.registerEvent(any()) } returns mockedResponseRegisterEvent