The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2006 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 com.android.server.am; |
| 18 | |
| 19 | import android.app.IActivityManager.ContentProviderHolder; |
| 20 | import android.content.pm.ApplicationInfo; |
| 21 | import android.content.pm.ProviderInfo; |
| 22 | import android.os.Process; |
| 23 | |
| 24 | import java.io.PrintWriter; |
| 25 | import java.util.HashSet; |
| 26 | |
| 27 | class ContentProviderRecord extends ContentProviderHolder { |
| 28 | // All attached clients |
| 29 | final HashSet<ProcessRecord> clients = new HashSet<ProcessRecord>(); |
| 30 | final int uid; |
| 31 | final ApplicationInfo appInfo; |
| 32 | int externals; // number of non-framework processes supported by this provider |
| 33 | ProcessRecord app; // if non-null, hosting application |
| 34 | ProcessRecord launchingApp; // if non-null, waiting for this app to be launched. |
| 35 | |
| 36 | public ContentProviderRecord(ProviderInfo _info, ApplicationInfo ai) { |
| 37 | super(_info); |
| 38 | uid = ai.uid; |
| 39 | appInfo = ai; |
| 40 | noReleaseNeeded = uid == 0 || uid == Process.SYSTEM_UID; |
| 41 | } |
| 42 | |
| 43 | public ContentProviderRecord(ContentProviderRecord cpr) { |
| 44 | super(cpr.info); |
| 45 | uid = cpr.uid; |
| 46 | appInfo = cpr.appInfo; |
| 47 | noReleaseNeeded = cpr.noReleaseNeeded; |
| 48 | } |
| 49 | |
| 50 | public boolean canRunHere(ProcessRecord app) { |
| 51 | return (info.multiprocess || info.processName.equals(app.processName)) |
| 52 | && (uid == Process.SYSTEM_UID || uid == app.info.uid); |
| 53 | } |
| 54 | |
| 55 | void dump(PrintWriter pw, String prefix) { |
| 56 | pw.println(prefix + this); |
| 57 | pw.println(prefix + "package=" + info.applicationInfo.packageName |
| 58 | + " process=" + info.processName); |
| 59 | pw.println(prefix + "app=" + app); |
| 60 | pw.println(prefix + "launchingApp=" + launchingApp); |
| 61 | pw.println(prefix + "provider=" + provider); |
| 62 | pw.println(prefix + "name=" + info.authority); |
| 63 | pw.println(prefix + "isSyncable=" + info.isSyncable); |
| 64 | pw.println(prefix + "multiprocess=" + info.multiprocess |
| 65 | + " initOrder=" + info.initOrder |
| 66 | + " uid=" + uid); |
| 67 | pw.println(prefix + "clients=" + clients); |
| 68 | pw.println(prefix + "externals=" + externals); |
| 69 | } |
| 70 | |
| 71 | public String toString() { |
| 72 | return "ContentProviderRecord{" |
| 73 | + Integer.toHexString(System.identityHashCode(this)) |
| 74 | + " " + info.name + "}"; |
| 75 | } |
| 76 | } |