Util.java revision 38e7f88993ece55252165940c471a031f87df55a
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.camera;
18
19import android.app.Activity;
20import android.app.AlertDialog;
21import android.app.admin.DevicePolicyManager;
22import android.content.ActivityNotFoundException;
23import android.content.ContentResolver;
24import android.content.Context;
25import android.content.DialogInterface;
26import android.content.Intent;
27import android.graphics.Bitmap;
28import android.graphics.BitmapFactory;
29import android.graphics.Matrix;
30import android.graphics.Rect;
31import android.graphics.RectF;
32import android.hardware.Camera;
33import android.hardware.Camera.CameraInfo;
34import android.hardware.Camera.Parameters;
35import android.hardware.Camera.Size;
36import android.location.Location;
37import android.net.Uri;
38import android.os.Build;
39import android.os.ParcelFileDescriptor;
40import android.provider.Settings;
41import android.telephony.TelephonyManager;
42import android.util.DisplayMetrics;
43import android.util.Log;
44import android.view.Display;
45import android.view.OrientationEventListener;
46import android.view.Surface;
47import android.view.View;
48import android.view.Window;
49import android.view.WindowManager;
50import android.view.animation.AlphaAnimation;
51import android.view.animation.Animation;
52
53import java.io.Closeable;
54import java.io.IOException;
55import java.lang.reflect.Method;
56import java.text.SimpleDateFormat;
57import java.util.Date;
58import java.util.List;
59import java.util.StringTokenizer;
60
61/**
62 * Collection of utility functions used in this package.
63 */
64public class Util {
65    private static final String TAG = "Util";
66    private static final int DIRECTION_LEFT = 0;
67    private static final int DIRECTION_RIGHT = 1;
68    private static final int DIRECTION_UP = 2;
69    private static final int DIRECTION_DOWN = 3;
70
71    // Orientation hysteresis amount used in rounding, in degrees
72    public static final int ORIENTATION_HYSTERESIS = 5;
73
74    public static final String REVIEW_ACTION = "com.android.camera.action.REVIEW";
75
76    // Private intent extras. Test only.
77    private static final String EXTRAS_CAMERA_FACING =
78            "android.intent.extras.CAMERA_FACING";
79
80    private static boolean sIsTabletUI;
81    private static float sPixelDensity = 1;
82    private static ImageFileNamer sImageFileNamer;
83
84    private Util() {
85    }
86
87    public static void initialize(Context context) {
88        sIsTabletUI = (context.getResources().getConfiguration().smallestScreenWidthDp >= 600);
89
90        DisplayMetrics metrics = new DisplayMetrics();
91        WindowManager wm = (WindowManager)
92                context.getSystemService(Context.WINDOW_SERVICE);
93        wm.getDefaultDisplay().getMetrics(metrics);
94        sPixelDensity = metrics.density;
95        sImageFileNamer = new ImageFileNamer(
96                context.getString(R.string.image_file_name_format));
97    }
98
99    public static boolean isTabletUI() {
100        return sIsTabletUI;
101    }
102
103    public static int dpToPixel(int dp) {
104        return Math.round(sPixelDensity * dp);
105    }
106
107    // Rotates the bitmap by the specified degree.
108    // If a new bitmap is created, the original bitmap is recycled.
109    public static Bitmap rotate(Bitmap b, int degrees) {
110        return rotateAndMirror(b, degrees, false);
111    }
112
113    // Rotates and/or mirrors the bitmap. If a new bitmap is created, the
114    // original bitmap is recycled.
115    public static Bitmap rotateAndMirror(Bitmap b, int degrees, boolean mirror) {
116        if ((degrees != 0 || mirror) && b != null) {
117            Matrix m = new Matrix();
118            // Mirror first.
119            // horizontal flip + rotation = -rotation + horizontal flip
120            if (mirror) {
121                m.postScale(-1, 1);
122                degrees = (degrees + 360) % 360;
123                if (degrees == 0 || degrees == 180) {
124                    m.postTranslate((float) b.getWidth(), 0);
125                } else if (degrees == 90 || degrees == 270) {
126                    m.postTranslate((float) b.getHeight(), 0);
127                } else {
128                    throw new IllegalArgumentException("Invalid degrees=" + degrees);
129                }
130            }
131            if (degrees != 0) {
132                // clockwise
133                m.postRotate(degrees,
134                        (float) b.getWidth() / 2, (float) b.getHeight() / 2);
135            }
136
137            try {
138                Bitmap b2 = Bitmap.createBitmap(
139                        b, 0, 0, b.getWidth(), b.getHeight(), m, true);
140                if (b != b2) {
141                    b.recycle();
142                    b = b2;
143                }
144            } catch (OutOfMemoryError ex) {
145                // We have no memory to rotate. Return the original bitmap.
146            }
147        }
148        return b;
149    }
150
151    /*
152     * Compute the sample size as a function of minSideLength
153     * and maxNumOfPixels.
154     * minSideLength is used to specify that minimal width or height of a
155     * bitmap.
156     * maxNumOfPixels is used to specify the maximal size in pixels that is
157     * tolerable in terms of memory usage.
158     *
159     * The function returns a sample size based on the constraints.
160     * Both size and minSideLength can be passed in as -1
161     * which indicates no care of the corresponding constraint.
162     * The functions prefers returning a sample size that
163     * generates a smaller bitmap, unless minSideLength = -1.
164     *
165     * Also, the function rounds up the sample size to a power of 2 or multiple
166     * of 8 because BitmapFactory only honors sample size this way.
167     * For example, BitmapFactory downsamples an image by 2 even though the
168     * request is 3. So we round up the sample size to avoid OOM.
169     */
170    public static int computeSampleSize(BitmapFactory.Options options,
171            int minSideLength, int maxNumOfPixels) {
172        int initialSize = computeInitialSampleSize(options, minSideLength,
173                maxNumOfPixels);
174
175        int roundedSize;
176        if (initialSize <= 8) {
177            roundedSize = 1;
178            while (roundedSize < initialSize) {
179                roundedSize <<= 1;
180            }
181        } else {
182            roundedSize = (initialSize + 7) / 8 * 8;
183        }
184
185        return roundedSize;
186    }
187
188    private static int computeInitialSampleSize(BitmapFactory.Options options,
189            int minSideLength, int maxNumOfPixels) {
190        double w = options.outWidth;
191        double h = options.outHeight;
192
193        int lowerBound = (maxNumOfPixels < 0) ? 1 :
194                (int) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
195        int upperBound = (minSideLength < 0) ? 128 :
196                (int) Math.min(Math.floor(w / minSideLength),
197                Math.floor(h / minSideLength));
198
199        if (upperBound < lowerBound) {
200            // return the larger one when there is no overlapping zone.
201            return lowerBound;
202        }
203
204        if (maxNumOfPixels < 0 && minSideLength < 0) {
205            return 1;
206        } else if (minSideLength < 0) {
207            return lowerBound;
208        } else {
209            return upperBound;
210        }
211    }
212
213    public static Bitmap makeBitmap(byte[] jpegData, int maxNumOfPixels) {
214        try {
215            BitmapFactory.Options options = new BitmapFactory.Options();
216            options.inJustDecodeBounds = true;
217            BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length,
218                    options);
219            if (options.mCancel || options.outWidth == -1
220                    || options.outHeight == -1) {
221                return null;
222            }
223            options.inSampleSize = computeSampleSize(
224                    options, -1, maxNumOfPixels);
225            options.inJustDecodeBounds = false;
226
227            options.inDither = false;
228            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
229            return BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length,
230                    options);
231        } catch (OutOfMemoryError ex) {
232            Log.e(TAG, "Got oom exception ", ex);
233            return null;
234        }
235    }
236
237    public static void closeSilently(Closeable c) {
238        if (c == null) return;
239        try {
240            c.close();
241        } catch (Throwable t) {
242            // do nothing
243        }
244    }
245
246    public static void Assert(boolean cond) {
247        if (!cond) {
248            throw new AssertionError();
249        }
250    }
251
252    public static android.hardware.Camera openCamera(Activity activity, int cameraId)
253            throws CameraHardwareException, CameraDisabledException {
254        // Check if device policy has disabled the camera.
255        DevicePolicyManager dpm = (DevicePolicyManager) activity.getSystemService(
256                Context.DEVICE_POLICY_SERVICE);
257        if (dpm.getCameraDisabled(null)) {
258            throw new CameraDisabledException();
259        }
260
261        try {
262            return CameraHolder.instance().open(cameraId);
263        } catch (CameraHardwareException e) {
264            // In eng build, we throw the exception so that test tool
265            // can detect it and report it
266            if ("eng".equals(Build.TYPE)) {
267                throw new RuntimeException("openCamera failed", e);
268            } else {
269                throw e;
270            }
271        }
272    }
273
274    public static void showErrorAndFinish(final Activity activity, int msgId) {
275        DialogInterface.OnClickListener buttonListener =
276                new DialogInterface.OnClickListener() {
277            public void onClick(DialogInterface dialog, int which) {
278                activity.finish();
279            }
280        };
281        new AlertDialog.Builder(activity)
282                .setCancelable(false)
283                .setIconAttribute(android.R.attr.alertDialogIcon)
284                .setTitle(R.string.camera_error_title)
285                .setMessage(msgId)
286                .setNeutralButton(R.string.dialog_ok, buttonListener)
287                .show();
288    }
289
290    public static <T> T checkNotNull(T object) {
291        if (object == null) throw new NullPointerException();
292        return object;
293    }
294
295    public static boolean equals(Object a, Object b) {
296        return (a == b) || (a == null ? false : a.equals(b));
297    }
298
299    public static int nextPowerOf2(int n) {
300        n -= 1;
301        n |= n >>> 16;
302        n |= n >>> 8;
303        n |= n >>> 4;
304        n |= n >>> 2;
305        n |= n >>> 1;
306        return n + 1;
307    }
308
309    public static float distance(float x, float y, float sx, float sy) {
310        float dx = x - sx;
311        float dy = y - sy;
312        return (float) Math.sqrt(dx * dx + dy * dy);
313    }
314
315    public static int clamp(int x, int min, int max) {
316        if (x > max) return max;
317        if (x < min) return min;
318        return x;
319    }
320
321    public static int getDisplayRotation(Activity activity) {
322        int rotation = activity.getWindowManager().getDefaultDisplay()
323                .getRotation();
324        switch (rotation) {
325            case Surface.ROTATION_0: return 0;
326            case Surface.ROTATION_90: return 90;
327            case Surface.ROTATION_180: return 180;
328            case Surface.ROTATION_270: return 270;
329        }
330        return 0;
331    }
332
333    public static int getDisplayOrientation(int degrees, int cameraId) {
334        // See android.hardware.Camera.setDisplayOrientation for
335        // documentation.
336        Camera.CameraInfo info = new Camera.CameraInfo();
337        Camera.getCameraInfo(cameraId, info);
338        int result;
339        if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
340            result = (info.orientation + degrees) % 360;
341            result = (360 - result) % 360;  // compensate the mirror
342        } else {  // back-facing
343            result = (info.orientation - degrees + 360) % 360;
344        }
345        return result;
346    }
347
348    public static int getCameraOrientation(int cameraId) {
349        Camera.CameraInfo info = new Camera.CameraInfo();
350        Camera.getCameraInfo(cameraId, info);
351        return info.orientation;
352    }
353
354    public static int roundOrientation(int orientation, int orientationHistory) {
355        boolean changeOrientation = false;
356        if (orientationHistory == OrientationEventListener.ORIENTATION_UNKNOWN) {
357            changeOrientation = true;
358        } else {
359            int dist = Math.abs(orientation - orientationHistory);
360            dist = Math.min( dist, 360 - dist );
361            changeOrientation = ( dist >= 45 + ORIENTATION_HYSTERESIS );
362        }
363        if (changeOrientation) {
364            return ((orientation + 45) / 90 * 90) % 360;
365        }
366        return orientationHistory;
367    }
368
369    public static Size getOptimalPreviewSize(Activity currentActivity,
370            List<Size> sizes, double targetRatio) {
371        // Use a very small tolerance because we want an exact match.
372        final double ASPECT_TOLERANCE = 0.001;
373        if (sizes == null) return null;
374
375        Size optimalSize = null;
376        double minDiff = Double.MAX_VALUE;
377
378        // Because of bugs of overlay and layout, we sometimes will try to
379        // layout the viewfinder in the portrait orientation and thus get the
380        // wrong size of mSurfaceView. When we change the preview size, the
381        // new overlay will be created before the old one closed, which causes
382        // an exception. For now, just get the screen size
383
384        Display display = currentActivity.getWindowManager().getDefaultDisplay();
385        int targetHeight = Math.min(display.getHeight(), display.getWidth());
386
387        if (targetHeight <= 0) {
388            // We don't know the size of SurfaceView, use screen height
389            targetHeight = display.getHeight();
390        }
391
392        // Try to find an size match aspect ratio and size
393        for (Size size : sizes) {
394            double ratio = (double) size.width / size.height;
395            if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
396            if (Math.abs(size.height - targetHeight) < minDiff) {
397                optimalSize = size;
398                minDiff = Math.abs(size.height - targetHeight);
399            }
400        }
401
402        // Cannot find the one match the aspect ratio. This should not happen.
403        // Ignore the requirement.
404        if (optimalSize == null) {
405            Log.w(TAG, "No preview size match the aspect ratio");
406            minDiff = Double.MAX_VALUE;
407            for (Size size : sizes) {
408                if (Math.abs(size.height - targetHeight) < minDiff) {
409                    optimalSize = size;
410                    minDiff = Math.abs(size.height - targetHeight);
411                }
412            }
413        }
414        return optimalSize;
415    }
416
417    // Returns the largest picture size which matches the given aspect ratio.
418    public static Size getOptimalVideoSnapshotPictureSize(
419            List<Size> sizes, double targetRatio) {
420        // Use a very small tolerance because we want an exact match.
421        final double ASPECT_TOLERANCE = 0.001;
422        if (sizes == null) return null;
423
424        Size optimalSize = null;
425
426        // Try to find a size matches aspect ratio and has the largest width
427        for (Size size : sizes) {
428            double ratio = (double) size.width / size.height;
429            if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
430            if (optimalSize == null || size.width > optimalSize.width) {
431                optimalSize = size;
432            }
433        }
434
435        // Cannot find one that matches the aspect ratio. This should not happen.
436        // Ignore the requirement.
437        if (optimalSize == null) {
438            Log.w(TAG, "No picture size match the aspect ratio");
439            for (Size size : sizes) {
440                if (optimalSize == null || size.width > optimalSize.width) {
441                    optimalSize = size;
442                }
443            }
444        }
445        return optimalSize;
446    }
447
448    public static void dumpParameters(Parameters parameters) {
449        String flattened = parameters.flatten();
450        StringTokenizer tokenizer = new StringTokenizer(flattened, ";");
451        Log.d(TAG, "Dump all camera parameters:");
452        while (tokenizer.hasMoreElements()) {
453            Log.d(TAG, tokenizer.nextToken());
454        }
455    }
456
457    /**
458     * Returns whether the device is voice-capable (meaning, it can do MMS).
459     */
460    public static boolean isMmsCapable(Context context) {
461        TelephonyManager telephonyManager = (TelephonyManager)
462                context.getSystemService(Context.TELEPHONY_SERVICE);
463        if (telephonyManager == null) {
464            return false;
465        }
466
467        try {
468            Class partypes[] = new Class[0];
469            Method sIsVoiceCapable = TelephonyManager.class.getMethod(
470                    "isVoiceCapable", partypes);
471
472            Object arglist[] = new Object[0];
473            Object retobj = sIsVoiceCapable.invoke(telephonyManager, arglist);
474            return (Boolean) retobj;
475        } catch (java.lang.reflect.InvocationTargetException ite) {
476            // Failure, must be another device.
477            // Assume that it is voice capable.
478        } catch (IllegalAccessException iae) {
479            // Failure, must be an other device.
480            // Assume that it is voice capable.
481        } catch (NoSuchMethodException nsme) {
482        }
483        return true;
484    }
485
486    // This is for test only. Allow the camera to launch the specific camera.
487    public static int getCameraFacingIntentExtras(Activity currentActivity) {
488        int cameraId = -1;
489
490        int intentCameraId =
491                currentActivity.getIntent().getIntExtra(Util.EXTRAS_CAMERA_FACING, -1);
492
493        if (isFrontCameraIntent(intentCameraId)) {
494            // Check if the front camera exist
495            int frontCameraId = CameraHolder.instance().getFrontCameraId();
496            if (frontCameraId != -1) {
497                cameraId = frontCameraId;
498            }
499        } else if (isBackCameraIntent(intentCameraId)) {
500            // Check if the back camera exist
501            int backCameraId = CameraHolder.instance().getBackCameraId();
502            if (backCameraId != -1) {
503                cameraId = backCameraId;
504            }
505        }
506        return cameraId;
507    }
508
509    private static boolean isFrontCameraIntent(int intentCameraId) {
510        return (intentCameraId == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
511    }
512
513    private static boolean isBackCameraIntent(int intentCameraId) {
514        return (intentCameraId == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
515    }
516
517    private static int mLocation[] = new int[2];
518
519    // This method is not thread-safe.
520    public static boolean pointInView(float x, float y, View v) {
521        v.getLocationInWindow(mLocation);
522        return x >= mLocation[0] && x < (mLocation[0] + v.getWidth())
523                && y >= mLocation[1] && y < (mLocation[1] + v.getHeight());
524    }
525
526    public static boolean isUriValid(Uri uri, ContentResolver resolver) {
527        if (uri == null) return false;
528
529        try {
530            ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r");
531            if (pfd == null) {
532                Log.e(TAG, "Fail to open URI. URI=" + uri);
533                return false;
534            }
535            pfd.close();
536        } catch (IOException ex) {
537            return false;
538        }
539        return true;
540    }
541
542    public static void viewUri(Uri uri, Context context) {
543        if (!isUriValid(uri, context.getContentResolver())) {
544            Log.e(TAG, "Uri invalid. uri=" + uri);
545            return;
546        }
547
548        try {
549            context.startActivity(new Intent(Util.REVIEW_ACTION, uri));
550        } catch (ActivityNotFoundException ex) {
551            try {
552                context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
553            } catch (ActivityNotFoundException e) {
554                Log.e(TAG, "review image fail. uri=" + uri, e);
555            }
556        }
557    }
558
559    public static void dumpRect(RectF rect, String msg) {
560        Log.v(TAG, msg + "=(" + rect.left + "," + rect.top
561                + "," + rect.right + "," + rect.bottom + ")");
562    }
563
564    public static void rectFToRect(RectF rectF, Rect rect) {
565        rect.left = Math.round(rectF.left);
566        rect.top = Math.round(rectF.top);
567        rect.right = Math.round(rectF.right);
568        rect.bottom = Math.round(rectF.bottom);
569    }
570
571    public static void prepareMatrix(Matrix matrix, boolean mirror, int displayOrientation,
572            int viewWidth, int viewHeight) {
573        // Need mirror for front camera.
574        matrix.setScale(mirror ? -1 : 1, 1);
575        // This is the value for android.hardware.Camera.setDisplayOrientation.
576        matrix.postRotate(displayOrientation);
577        // Camera driver coordinates range from (-1000, -1000) to (1000, 1000).
578        // UI coordinates range from (0, 0) to (width, height).
579        matrix.postScale(viewWidth / 2000f, viewHeight / 2000f);
580        matrix.postTranslate(viewWidth / 2f, viewHeight / 2f);
581    }
582
583    public static String createJpegName(long dateTaken) {
584        synchronized (sImageFileNamer) {
585            return sImageFileNamer.generateName(dateTaken);
586        }
587    }
588
589    public static void broadcastNewPicture(Context context, Uri uri) {
590        context.sendBroadcast(new Intent(android.hardware.Camera.ACTION_NEW_PICTURE, uri));
591        // Keep compatibility
592        context.sendBroadcast(new Intent("com.android.camera.NEW_PICTURE", uri));
593    }
594
595    public static void fadeIn(View view) {
596        if (view.getVisibility() == View.VISIBLE) return;
597
598        view.setVisibility(View.VISIBLE);
599        Animation animation = new AlphaAnimation(0F, 1F);
600        animation.setDuration(400);
601        view.startAnimation(animation);
602    }
603
604    public static void fadeOut(View view) {
605        if (view.getVisibility() != View.VISIBLE) return;
606
607        Animation animation = new AlphaAnimation(1F, 0F);
608        animation.setDuration(400);
609        view.startAnimation(animation);
610        view.setVisibility(View.GONE);
611    }
612
613    public static void setRotationParameter(Parameters parameters, int cameraId, int orientation) {
614        // See android.hardware.Camera.Parameters.setRotation for
615        // documentation.
616        int rotation = 0;
617        if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
618            CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId];
619            if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
620                rotation = (info.orientation - orientation + 360) % 360;
621            } else {  // back-facing camera
622                rotation = (info.orientation + orientation) % 360;
623            }
624        }
625        parameters.setRotation(rotation);
626    }
627
628    public static void setGpsParameters(Parameters parameters, Location loc) {
629        // Clear previous GPS location from the parameters.
630        parameters.removeGpsData();
631
632        // We always encode GpsTimeStamp
633        parameters.setGpsTimestamp(System.currentTimeMillis() / 1000);
634
635        // Set GPS location.
636        if (loc != null) {
637            double lat = loc.getLatitude();
638            double lon = loc.getLongitude();
639            boolean hasLatLon = (lat != 0.0d) || (lon != 0.0d);
640
641            if (hasLatLon) {
642                Log.d(TAG, "Set gps location");
643                parameters.setGpsLatitude(lat);
644                parameters.setGpsLongitude(lon);
645                parameters.setGpsProcessingMethod(loc.getProvider().toUpperCase());
646                if (loc.hasAltitude()) {
647                    parameters.setGpsAltitude(loc.getAltitude());
648                } else {
649                    // for NETWORK_PROVIDER location provider, we may have
650                    // no altitude information, but the driver needs it, so
651                    // we fake one.
652                    parameters.setGpsAltitude(0);
653                }
654                if (loc.getTime() != 0) {
655                    // Location.getTime() is UTC in milliseconds.
656                    // gps-timestamp is UTC in seconds.
657                    long utcTimeSeconds = loc.getTime() / 1000;
658                    parameters.setGpsTimestamp(utcTimeSeconds);
659                }
660            } else {
661                loc = null;
662            }
663        }
664    }
665
666    public static void enterLightsOutMode(Window window) {
667        WindowManager.LayoutParams params = window.getAttributes();
668        params.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE;
669        window.setAttributes(params);
670    }
671
672    private static class ImageFileNamer {
673        private SimpleDateFormat mFormat;
674
675        // The date (in milliseconds) used to generate the last name.
676        private long mLastDate;
677
678        // Number of names generated for the same second.
679        private int mSameSecondCount;
680
681        public ImageFileNamer(String format) {
682            mFormat = new SimpleDateFormat(format);
683        }
684
685        public String generateName(long dateTaken) {
686            Date date = new Date(dateTaken);
687            String result = mFormat.format(date);
688
689            // If the last name was generated for the same second,
690            // we append _1, _2, etc to the name.
691            if (dateTaken / 1000 == mLastDate / 1000) {
692                mSameSecondCount++;
693                result += "_" + mSameSecondCount;
694            } else {
695                mLastDate = dateTaken;
696                mSameSecondCount = 0;
697            }
698
699            return result;
700        }
701    }
702}
703