Mehdi Alizadeh | 3277462 | 2018-11-05 17:32:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | package com.android.server.pm; |
| 17 | |
| 18 | import android.text.TextUtils; |
| 19 | |
| 20 | /** |
| 21 | * Represents a Share Target definition, read from the application's manifest (shortcuts.xml) |
| 22 | */ |
| 23 | class ShareTargetInfo { |
| 24 | static class TargetData { |
| 25 | final String mScheme; |
| 26 | final String mHost; |
| 27 | final String mPort; |
| 28 | final String mPath; |
| 29 | final String mPathPattern; |
| 30 | final String mPathPrefix; |
| 31 | final String mMimeType; |
| 32 | |
| 33 | TargetData(String scheme, String host, String port, String path, String pathPattern, |
| 34 | String pathPrefix, String mimeType) { |
| 35 | mScheme = scheme; |
| 36 | mHost = host; |
| 37 | mPort = port; |
| 38 | mPath = path; |
| 39 | mPathPattern = pathPattern; |
| 40 | mPathPrefix = pathPrefix; |
| 41 | mMimeType = mimeType; |
| 42 | } |
| 43 | |
| 44 | public void toStringInner(StringBuilder strBuilder) { |
| 45 | if (!TextUtils.isEmpty(mScheme)) { |
| 46 | strBuilder.append(" scheme=").append(mScheme); |
| 47 | } |
| 48 | if (!TextUtils.isEmpty(mHost)) { |
| 49 | strBuilder.append(" host=").append(mHost); |
| 50 | } |
| 51 | if (!TextUtils.isEmpty(mPort)) { |
| 52 | strBuilder.append(" port=").append(mPort); |
| 53 | } |
| 54 | if (!TextUtils.isEmpty(mPath)) { |
| 55 | strBuilder.append(" path=").append(mPath); |
| 56 | } |
| 57 | if (!TextUtils.isEmpty(mPathPattern)) { |
| 58 | strBuilder.append(" pathPattern=").append(mPathPattern); |
| 59 | } |
| 60 | if (!TextUtils.isEmpty(mPathPrefix)) { |
| 61 | strBuilder.append(" pathPrefix=").append(mPathPrefix); |
| 62 | } |
| 63 | if (!TextUtils.isEmpty(mMimeType)) { |
| 64 | strBuilder.append(" mimeType=").append(mMimeType); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public String toString() { |
| 70 | StringBuilder strBuilder = new StringBuilder(); |
| 71 | toStringInner(strBuilder); |
| 72 | return strBuilder.toString(); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | final TargetData[] mTargetData; |
| 77 | final String mTargetClass; |
| 78 | final String[] mCategories; |
| 79 | |
| 80 | ShareTargetInfo(TargetData[] data, String targetClass, String[] categories) { |
| 81 | mTargetData = data; |
| 82 | mTargetClass = targetClass; |
| 83 | mCategories = categories; |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public String toString() { |
| 88 | StringBuilder strBuilder = new StringBuilder(); |
| 89 | strBuilder.append("targetClass=").append(mTargetClass); |
| 90 | for (int i = 0; i < mTargetData.length; i++) { |
| 91 | strBuilder.append(" data={"); |
| 92 | mTargetData[i].toStringInner(strBuilder); |
| 93 | strBuilder.append("}"); |
| 94 | } |
| 95 | for (int i = 0; i < mCategories.length; i++) { |
| 96 | strBuilder.append(" category=").append(mCategories[i]); |
| 97 | } |
| 98 | |
| 99 | return strBuilder.toString(); |
| 100 | } |
| 101 | } |