/*
 * Copyright 2018, Flávio Keglevich
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.fkeglevich.rawdumper.camera.service.available;

import com.fkeglevich.rawdumper.camera.service.LogPriority;
import com.fkeglevich.rawdumper.camera.service.LogcatFeatureService;
import com.fkeglevich.rawdumper.camera.service.LogcatMatch;

public class SensorGainMeteringService extends LogcatFeatureService<Double>
{
    /*total_gain: 3.480188  digital gain: 1.000000
    @getManualIso - -1
    */
    private static final LogcatMatch LOGCAT_MATCH = new LogcatMatch("Camera_AtomAIQ", LogPriority.D, "total_gain");

    private static final SensorGainMeteringService instance = new SensorGainMeteringService();

    public static SensorGainMeteringService getInstance()
    {
        return instance;
    }

    private SensorGainMeteringService()
    {
        super(LOGCAT_MATCH);
    }

    @Override
    protected Double parseString(String string)
    {
        String[] split = string.split(" ");
        return Double.parseDouble(split[1]);
    }
}

@@ -931,84 +931,65 @@
     
-/*total_gain: 3.480188  digital 
+private static final String FINGERPRINT = %22total_
 gain: 
-1.000000%0A    @getManualIso - -1%0A    */
+%22;
 %0A   
@@ -1090,20 +1090,19 @@
 .D, 
-%22total_gain%22
+FINGERPRINT
 );%0A%0A
@@ -1435,32 +1435,209 @@
 g string)%0A    %7B%0A
+        /*total_gain: 3.480188  digital gain: 1.000000%0A            @getManualIso - -1%0A            */%0A%0A        String firstPiece = string.substring(string.indexOf(FINGERPRINT));%0A
         String%5B%5D
@@ -1645,22 +1645,26 @@
 split = 
-string
+firstPiece
 .split(%22

Make gain metering more robust