use of android.content.IContentProvider in project XobotOS by xamarin.
the class ActivityThread method acquireExistingProvider.
public final IContentProvider acquireExistingProvider(Context c, String name) {
IContentProvider provider = getExistingProvider(c, name);
if (provider == null)
return null;
IBinder jBinder = provider.asBinder();
synchronized (mProviderMap) {
ProviderRefCount prc = mProviderRefCountMap.get(jBinder);
if (prc == null) {
mProviderRefCountMap.put(jBinder, new ProviderRefCount(1));
} else {
prc.count++;
}
//end else
}
//end synchronized
return provider;
}
use of android.content.IContentProvider in project XobotOS by xamarin.
the class ActivityThread method installContentProviders.
private void installContentProviders(Context context, List<ProviderInfo> providers) {
final ArrayList<IActivityManager.ContentProviderHolder> results = new ArrayList<IActivityManager.ContentProviderHolder>();
Iterator<ProviderInfo> i = providers.iterator();
while (i.hasNext()) {
ProviderInfo cpi = i.next();
StringBuilder buf = new StringBuilder(128);
buf.append("Pub ");
buf.append(cpi.authority);
buf.append(": ");
buf.append(cpi.name);
Log.i(TAG, buf.toString());
IContentProvider cp = installProvider(context, null, cpi, false);
if (cp != null) {
IActivityManager.ContentProviderHolder cph = new IActivityManager.ContentProviderHolder(cpi);
cph.provider = cp;
results.add(cph);
// Don't ever unload this provider from the process.
synchronized (mProviderMap) {
mProviderRefCountMap.put(cp.asBinder(), new ProviderRefCount(10000));
}
}
}
try {
ActivityManagerNative.getDefault().publishContentProviders(getApplicationThread(), results);
} catch (RemoteException ex) {
}
}
use of android.content.IContentProvider in project XobotOS by xamarin.
the class ActivityThread method getProvider.
private IContentProvider getProvider(Context context, String name) {
IContentProvider existing = getExistingProvider(context, name);
if (existing != null) {
return existing;
}
IActivityManager.ContentProviderHolder holder = null;
try {
holder = ActivityManagerNative.getDefault().getContentProvider(getApplicationThread(), name);
} catch (RemoteException ex) {
}
if (holder == null) {
Slog.e(TAG, "Failed to find provider info for " + name);
return null;
}
IContentProvider prov = installProvider(context, holder.provider, holder.info, true);
//Slog.i(TAG, "noReleaseNeeded=" + holder.noReleaseNeeded);
if (holder.noReleaseNeeded || holder.provider == null) {
//Slog.i(TAG, "*** NO RELEASE NEEDED");
synchronized (mProviderMap) {
mProviderRefCountMap.put(prov.asBinder(), new ProviderRefCount(10000));
}
}
return prov;
}
use of android.content.IContentProvider in project android_frameworks_base by DirtyUnicorns.
the class ShellUiAutomatorBridge method getSystemLongPressTime.
public long getSystemLongPressTime() {
// Read the long press timeout setting.
long longPressTimeout = 0;
try {
IContentProvider provider = null;
Cursor cursor = null;
IActivityManager activityManager = ActivityManagerNative.getDefault();
String providerName = Settings.Secure.CONTENT_URI.getAuthority();
IBinder token = new Binder();
try {
ContentProviderHolder holder = activityManager.getContentProviderExternal(providerName, UserHandle.USER_SYSTEM, token);
if (holder == null) {
throw new IllegalStateException("Could not find provider: " + providerName);
}
provider = holder.provider;
cursor = provider.query(null, Settings.Secure.CONTENT_URI, new String[] { Settings.Secure.VALUE }, "name=?", new String[] { Settings.Secure.LONG_PRESS_TIMEOUT }, null, null);
if (cursor.moveToFirst()) {
longPressTimeout = cursor.getInt(0);
}
} finally {
if (cursor != null) {
cursor.close();
}
if (provider != null) {
activityManager.removeContentProviderExternal(providerName, token);
}
}
} catch (RemoteException e) {
String message = "Error reading long press timeout setting.";
Log.e(LOG_TAG, message, e);
throw new RuntimeException(message, e);
}
return longPressTimeout;
}
use of android.content.IContentProvider in project android_frameworks_base by DirtyUnicorns.
the class ActivityManagerService method unstableProviderDied.
public void unstableProviderDied(IBinder connection) {
ContentProviderConnection conn;
try {
conn = (ContentProviderConnection) connection;
} catch (ClassCastException e) {
String msg = "refContentProvider: " + connection + " not a ContentProviderConnection";
Slog.w(TAG, msg);
throw new IllegalArgumentException(msg);
}
if (conn == null) {
throw new NullPointerException("connection is null");
}
// Safely retrieve the content provider associated with the connection.
IContentProvider provider;
synchronized (this) {
provider = conn.provider.provider;
}
if (provider == null) {
// Um, yeah, we're way ahead of you.
return;
}
// Make sure the caller is being honest with us.
if (provider.asBinder().pingBinder()) {
// Er, no, still looks good to us.
synchronized (this) {
Slog.w(TAG, "unstableProviderDied: caller " + Binder.getCallingUid() + " says " + conn + " died, but we don't agree");
return;
}
}
// Well look at that! It's dead!
synchronized (this) {
if (conn.provider.provider != provider) {
// But something changed... good enough.
return;
}
ProcessRecord proc = conn.provider.proc;
if (proc == null || proc.thread == null) {
// Seems like the process is already cleaned up.
return;
}
// As far as we're concerned, this is just like receiving a
// death notification... just a bit prematurely.
Slog.i(TAG, "Process " + proc.processName + " (pid " + proc.pid + ") early provider death");
final long ident = Binder.clearCallingIdentity();
try {
appDiedLocked(proc);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
}
Aggregations