11c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio/*
21c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * Copyright (C) 2015 The Android Open Source Project
31c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio *
41c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * Licensed under the Apache License, Version 2.0 (the "License");
51c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * you may not use this file except in compliance with the License.
61c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * You may obtain a copy of the License at
71c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio *
81c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio *      http://www.apache.org/licenses/LICENSE-2.0
91c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio *
101c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * Unless required by applicable law or agreed to in writing, software
111c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * distributed under the License is distributed on an "AS IS" BASIS,
121c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * See the License for the specific language governing permissions and
141c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * limitations under the License.
151c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio */
161c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
171c1b47125da018b44240739db75f8898e064a948Fabrice Di Megliopackage com.android.server.pm;
181c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
191c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglioimport java.util.Arrays;
201c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
211c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio/**
221c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * This is the key for the map of {@link android.content.pm.IntentFilterVerificationInfo}s
231c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio * maintained by the  {@link com.android.server.pm.PackageManagerService}
241c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio */
251c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglioclass IntentFilterVerificationKey {
261c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    public String domains;
271c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    public String packageName;
281c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    public String className;
291c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
301c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    public IntentFilterVerificationKey(String[] domains, String packageName, String className) {
311c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        StringBuilder sb = new StringBuilder();
321c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        for (String host : domains) {
331c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio            sb.append(host);
341c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        }
351c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        this.domains = sb.toString();
361c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        this.packageName = packageName;
371c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        this.className = className;
381c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    }
391c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
401c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    @Override
411c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    public boolean equals(Object o) {
421c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        if (this == o) return true;
431c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        if (o == null || getClass() != o.getClass()) return false;
441c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
451c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        IntentFilterVerificationKey that = (IntentFilterVerificationKey) o;
461c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
471c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        if (domains != null ? !domains.equals(that.domains) : that.domains != null) return false;
481c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        if (className != null ? !className.equals(that.className) : that.className != null)
491c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio            return false;
501c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        if (packageName != null ? !packageName.equals(that.packageName) : that.packageName != null)
511c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio            return false;
521c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
531c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        return true;
541c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    }
551c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio
561c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    @Override
571c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    public int hashCode() {
581c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        int result = domains != null ? domains.hashCode() : 0;
591c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        result = 31 * result + (packageName != null ? packageName.hashCode() : 0);
601c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        result = 31 * result + (className != null ? className.hashCode() : 0);
611c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio        return result;
621c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio    }
631c1b47125da018b44240739db75f8898e064a948Fabrice Di Meglio}
64