Home | History | Annotate | Download | only in autofill
      1 /*
      2  * Copyright (C) 2016 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 
     17 package android.view.autofill;
     18 
     19 import android.os.Bundle;
     20 
     21 import java.util.Arrays;
     22 import java.util.Objects;
     23 import java.util.Set;
     24 
     25 /** @hide */
     26 public final class Helper {
     27 
     28     // Debug-level flags are defined when service is bound.
     29     public static boolean sDebug = false;
     30     public static boolean sVerbose = false;
     31 
     32     public static final String REDACTED = "[REDACTED]";
     33 
     34     static StringBuilder append(StringBuilder builder, Bundle bundle) {
     35         if (bundle == null || !sDebug) {
     36             builder.append("N/A");
     37         } else if (!sVerbose) {
     38             builder.append(REDACTED);
     39         } else {
     40             final Set<String> keySet = bundle.keySet();
     41             builder.append("[Bundle with ").append(keySet.size()).append(" extras:");
     42             for (String key : keySet) {
     43                 final Object value = bundle.get(key);
     44                 builder.append(' ').append(key).append('=');
     45                 builder.append((value instanceof Object[])
     46                         ? Arrays.toString((Objects[]) value) : value);
     47             }
     48             builder.append(']');
     49         }
     50         return builder;
     51     }
     52 
     53     private Helper() {
     54         throw new UnsupportedOperationException("contains static members only");
     55     }
     56 }
     57