use of android.content.Context in project enroscar by stanfy.
the class SharingHelper method createSharingData.
private SharingData createSharingData(final Intent sharingIntent) {
final SharingData data = TextUtils.isEmpty(sharingIntent.getAction()) ? new PickData() : new SharingData();
data.intent = sharingIntent;
final Context context = this.context.get();
if (context instanceof Activity) {
data.callerInfo = ((Activity) context).getCallingActivity();
} else {
final String pkg = sharingIntent.getStringExtra(ShareCompat.EXTRA_CALLING_PACKAGE);
final String act = sharingIntent.getStringExtra(ShareCompat.EXTRA_CALLING_ACTIVITY);
if (!TextUtils.isEmpty(pkg) && !TextUtils.isEmpty(act)) {
data.callerInfo = new ComponentName(pkg, act);
}
}
return data;
}
use of android.content.Context in project enroscar by stanfy.
the class SharingHelper method deliverError.
private void deliverError() {
final SharingActor actor = this.actor;
final Context context = this.context.get();
if (actor == null || context == null) {
return;
}
actor.dispatchResolverError();
}
use of android.content.Context in project platform_frameworks_base by android.
the class BroadcastTest method testRegisteredReceivePermissionDenied.
public void testRegisteredReceivePermissionDenied() throws Exception {
setExpectedReceivers(new String[] { RECEIVER_RESULTS });
registerMyReceiver(new IntentFilter(BROADCAST_REGISTERED), PERMISSION_DENIED);
addIntermediate("after-register");
BroadcastReceiver finish = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
gotReceive(RECEIVER_RESULTS, intent);
}
};
getContext().sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_REGISTERED), null, finish, null, Activity.RESULT_CANCELED, null, null);
waitForResultOrThrow(BROADCAST_TIMEOUT);
}
use of android.content.Context in project platform_frameworks_base by android.
the class NetworkRecommendationProviderTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
// Configuration needed to make mockito/dexcache work.
final Context context = getInstrumentation().getTargetContext();
System.setProperty("dexmaker.dexcache", context.getCacheDir().getPath());
ClassLoader newClassLoader = getInstrumentation().getClass().getClassLoader();
Thread.currentThread().setContextClassLoader(newClassLoader);
MockitoAnnotations.initMocks(this);
HandlerThread thread = new HandlerThread("NetworkRecommendationProviderTest");
thread.start();
mRecRequestLatch = new CountDownLatch(1);
mScoreRequestLatch = new CountDownLatch(1);
mHandler = new Handler(thread.getLooper());
mRecProvider = new NetworkRecProvider(mHandler, mRecRequestLatch, mScoreRequestLatch);
mStub = INetworkRecommendationProvider.Stub.asInterface(mRecProvider.getBinder());
mTestNetworkKeys = new NetworkKey[2];
mTestNetworkKeys[0] = new NetworkKey(new WifiKey("\"ssid_01\"", "00:00:00:00:00:11"));
mTestNetworkKeys[1] = new NetworkKey(new WifiKey("\"ssid_02\"", "00:00:00:00:00:22"));
}
use of android.content.Context in project platform_frameworks_base by android.
the class DatabaseStressTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Context c = getContext();
mDatabaseFile = c.getDatabasePath("database_test.db");
if (mDatabaseFile.exists()) {
mDatabaseFile.delete();
}
mDatabase = c.openOrCreateDatabase("database_test.db", 0, null);
assertNotNull(mDatabase);
mDatabase.setVersion(CURRENT_DATABASE_VERSION);
mDatabase.execSQL("CREATE TABLE IF NOT EXISTS test (_id INTEGER PRIMARY KEY, data TEXT);");
}
Aggregations