PageRenderTime 52ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/android/generated/android/app/ContextImpl.cs

https://bitbucket.org/festevezga/xobotos
C# | 1605 lines | 1365 code | 173 blank | 67 comment | 102 complexity | 4235b33546bcfe567c81a3dec29634ef MD5 | raw file
  1. using Sharpen;
  2. namespace android.app
  3. {
  4. [Sharpen.Sharpened]
  5. internal class ReceiverRestrictedContext : android.content.ContextWrapper
  6. {
  7. internal ReceiverRestrictedContext(android.content.Context @base) : base(@base)
  8. {
  9. }
  10. [Sharpen.OverridesMethod(@"android.content.Context")]
  11. public override android.content.Intent registerReceiver(android.content.BroadcastReceiver
  12. receiver, android.content.IntentFilter filter)
  13. {
  14. return registerReceiver(receiver, filter, null, null);
  15. }
  16. [Sharpen.OverridesMethod(@"android.content.Context")]
  17. public override android.content.Intent registerReceiver(android.content.BroadcastReceiver
  18. receiver, android.content.IntentFilter filter, string broadcastPermission, android.os.Handler
  19. scheduler)
  20. {
  21. throw new android.content.ReceiverCallNotAllowedException("IntentReceiver components are not allowed to register to receive intents"
  22. );
  23. }
  24. //ex.fillInStackTrace();
  25. //Log.e("IntentReceiver", ex.getMessage(), ex);
  26. //return mContext.registerReceiver(receiver, filter, broadcastPermission,
  27. // scheduler);
  28. [Sharpen.OverridesMethod(@"android.content.Context")]
  29. public override bool bindService(android.content.Intent service, android.content.ServiceConnection
  30. conn, int flags)
  31. {
  32. throw new android.content.ReceiverCallNotAllowedException("IntentReceiver components are not allowed to bind to services"
  33. );
  34. }
  35. //ex.fillInStackTrace();
  36. //Log.e("IntentReceiver", ex.getMessage(), ex);
  37. //return mContext.bindService(service, interfaceName, conn, flags);
  38. }
  39. /// <summary>
  40. /// Common implementation of Context API, which provides the base
  41. /// context object for Activity and other application components.
  42. /// </summary>
  43. /// <remarks>
  44. /// Common implementation of Context API, which provides the base
  45. /// context object for Activity and other application components.
  46. /// </remarks>
  47. [Sharpen.Sharpened]
  48. internal partial class ContextImpl : android.content.Context
  49. {
  50. internal const string TAG = "ApplicationContext";
  51. internal const bool DEBUG = false;
  52. private static readonly java.util.HashMap<string, android.app.SharedPreferencesImpl
  53. > sSharedPrefs = new java.util.HashMap<string, android.app.SharedPreferencesImpl
  54. >();
  55. internal android.app.LoadedApk mPackageInfo;
  56. private string mBasePackageName;
  57. private android.content.res.Resources mResources;
  58. internal android.app.ActivityThread mMainThread;
  59. private android.content.Context mOuterContext;
  60. private android.os.IBinder mActivityToken = null;
  61. private android.app.ContextImpl.ApplicationContentResolver mContentResolver;
  62. private int mThemeResource = 0;
  63. private android.content.res.Resources.Theme mTheme = null;
  64. private android.content.pm.PackageManager mPackageManager;
  65. private android.content.Context mReceiverRestrictedContext = null;
  66. private bool mRestricted;
  67. private readonly object mSync = new object();
  68. private java.io.File mDatabasesDir;
  69. private java.io.File mPreferencesDir;
  70. private java.io.File mFilesDir;
  71. private java.io.File mCacheDir;
  72. private java.io.File mObbDir;
  73. private java.io.File mExternalFilesDir;
  74. private java.io.File mExternalCacheDir;
  75. private static readonly string[] EMPTY_FILE_LIST = new string[] { };
  76. /// <summary>
  77. /// Override this class when the system service constructor needs a
  78. /// ContextImpl.
  79. /// </summary>
  80. /// <remarks>
  81. /// Override this class when the system service constructor needs a
  82. /// ContextImpl. Else, use StaticServiceFetcher below.
  83. /// </remarks>
  84. internal class ServiceFetcher
  85. {
  86. internal int mContextCacheIndex = -1;
  87. /// <summary>Main entrypoint; only override if you don't need caching.</summary>
  88. /// <remarks>Main entrypoint; only override if you don't need caching.</remarks>
  89. internal virtual object getService(android.app.ContextImpl ctx)
  90. {
  91. java.util.ArrayList<object> cache = ctx.mServiceCache;
  92. object service;
  93. lock (cache)
  94. {
  95. if (cache.size() == 0)
  96. {
  97. {
  98. // Initialize the cache vector on first access.
  99. // At this point sNextPerContextServiceCacheIndex
  100. // is the number of potential services that are
  101. // cached per-Context.
  102. for (int i = 0; i < sNextPerContextServiceCacheIndex; i++)
  103. {
  104. cache.add(null);
  105. }
  106. }
  107. }
  108. else
  109. {
  110. service = cache.get(mContextCacheIndex);
  111. if (service != null)
  112. {
  113. return service;
  114. }
  115. }
  116. service = createService(ctx);
  117. cache.set(mContextCacheIndex, service);
  118. return service;
  119. }
  120. }
  121. /// <summary>
  122. /// Override this to create a new per-Context instance of the
  123. /// service.
  124. /// </summary>
  125. /// <remarks>
  126. /// Override this to create a new per-Context instance of the
  127. /// service. getService() will handle locking and caching.
  128. /// </remarks>
  129. internal virtual object createService(android.app.ContextImpl ctx)
  130. {
  131. throw new java.lang.RuntimeException("Not implemented");
  132. }
  133. }
  134. /// <summary>Override this class for services to be cached process-wide.</summary>
  135. /// <remarks>Override this class for services to be cached process-wide.</remarks>
  136. internal abstract class StaticServiceFetcher : android.app.ContextImpl.ServiceFetcher
  137. {
  138. private object mCachedInstance;
  139. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  140. internal sealed override object getService(android.app.ContextImpl unused)
  141. {
  142. lock (this)
  143. {
  144. object service = mCachedInstance;
  145. if (service != null)
  146. {
  147. return service;
  148. }
  149. return mCachedInstance = createStaticService();
  150. }
  151. }
  152. public abstract object createStaticService();
  153. }
  154. private static readonly java.util.HashMap<string, android.app.ContextImpl.ServiceFetcher
  155. > SYSTEM_SERVICE_MAP = new java.util.HashMap<string, android.app.ContextImpl.ServiceFetcher
  156. >();
  157. private static int sNextPerContextServiceCacheIndex = 0;
  158. internal static void registerService(string serviceName, android.app.ContextImpl.
  159. ServiceFetcher fetcher)
  160. {
  161. if (!(fetcher is android.app.ContextImpl.StaticServiceFetcher))
  162. {
  163. fetcher.mContextCacheIndex = sNextPerContextServiceCacheIndex++;
  164. }
  165. SYSTEM_SERVICE_MAP.put(serviceName, fetcher);
  166. }
  167. private sealed class _ServiceFetcher_247 : android.app.ContextImpl.ServiceFetcher
  168. {
  169. public _ServiceFetcher_247()
  170. {
  171. }
  172. // This one's defined separately and given a variable name so it
  173. // can be re-used by getWallpaperManager(), avoiding a HashMap
  174. // lookup.
  175. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  176. internal override object createService(android.app.ContextImpl ctx)
  177. {
  178. return new android.app.WallpaperManager(ctx.getOuterContext(), ctx.mMainThread.getHandler
  179. ());
  180. }
  181. }
  182. private static android.app.ContextImpl.ServiceFetcher WALLPAPER_FETCHER = new _ServiceFetcher_247
  183. ();
  184. static ContextImpl()
  185. {
  186. registerService(ACCESSIBILITY_SERVICE, new _ServiceFetcher_254());
  187. registerService(ACCOUNT_SERVICE, new _ServiceFetcher_259());
  188. registerService(ACTIVITY_SERVICE, new _ServiceFetcher_266());
  189. registerService(ALARM_SERVICE, new _StaticServiceFetcher_271());
  190. registerService(AUDIO_SERVICE, new _ServiceFetcher_278());
  191. registerService(CLIPBOARD_SERVICE, new _ServiceFetcher_283());
  192. registerService(CONNECTIVITY_SERVICE, new _StaticServiceFetcher_289());
  193. registerService(COUNTRY_DETECTOR, new _StaticServiceFetcher_295());
  194. registerService(DEVICE_POLICY_SERVICE, new _ServiceFetcher_301());
  195. registerService(DOWNLOAD_SERVICE, new _ServiceFetcher_306());
  196. registerService(NFC_SERVICE, new _ServiceFetcher_311());
  197. registerService(DROPBOX_SERVICE, new _StaticServiceFetcher_316());
  198. registerService(INPUT_METHOD_SERVICE, new _ServiceFetcher_321());
  199. registerService(TEXT_SERVICES_MANAGER_SERVICE, new _ServiceFetcher_326());
  200. registerService(KEYGUARD_SERVICE, new _ServiceFetcher_331());
  201. // TODO: why isn't this caching it? It wasn't
  202. // before, so I'm preserving the old behavior and
  203. // using getService(), instead of createService()
  204. // which would do the caching.
  205. registerService(LAYOUT_INFLATER_SERVICE, new _ServiceFetcher_340());
  206. registerService(LOCATION_SERVICE, new _StaticServiceFetcher_345());
  207. registerService(NETWORK_POLICY_SERVICE, new _ServiceFetcher_351());
  208. registerService(NOTIFICATION_SERVICE, new _ServiceFetcher_359());
  209. // Note: this was previously cached in a static variable, but
  210. // constructed using mMainThread.getHandler(), so converting
  211. // it to be a regular Context-cached service...
  212. registerService(POWER_SERVICE, new _ServiceFetcher_375());
  213. registerService(SEARCH_SERVICE, new _ServiceFetcher_382());
  214. registerService(SENSOR_SERVICE, new _ServiceFetcher_388());
  215. registerService(STATUS_BAR_SERVICE, new _ServiceFetcher_393());
  216. registerService(STORAGE_SERVICE, new _ServiceFetcher_398());
  217. registerService(TELEPHONY_SERVICE, new _ServiceFetcher_408());
  218. registerService(THROTTLE_SERVICE, new _StaticServiceFetcher_413());
  219. registerService(UI_MODE_SERVICE, new _ServiceFetcher_419());
  220. registerService(USB_SERVICE, new _ServiceFetcher_424());
  221. registerService(VIBRATOR_SERVICE, new _ServiceFetcher_430());
  222. registerService(WALLPAPER_SERVICE, WALLPAPER_FETCHER);
  223. registerService(WIFI_SERVICE, new _ServiceFetcher_437());
  224. registerService(WIFI_P2P_SERVICE, new _ServiceFetcher_444());
  225. registerService(WINDOW_SERVICE, new _ServiceFetcher_451());
  226. }
  227. private sealed class _ServiceFetcher_254 : android.app.ContextImpl.ServiceFetcher
  228. {
  229. public _ServiceFetcher_254()
  230. {
  231. }
  232. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  233. internal override object getService(android.app.ContextImpl ctx)
  234. {
  235. return android.view.accessibility.AccessibilityManager.getInstance(ctx);
  236. }
  237. }
  238. private sealed class _ServiceFetcher_259 : android.app.ContextImpl.ServiceFetcher
  239. {
  240. public _ServiceFetcher_259()
  241. {
  242. }
  243. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  244. internal override object createService(android.app.ContextImpl ctx)
  245. {
  246. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  247. .ACCOUNT_SERVICE);
  248. android.accounts.IAccountManager service = android.accounts.IAccountManagerClass.
  249. Stub.asInterface(b);
  250. return new android.accounts.AccountManager(ctx, service);
  251. }
  252. }
  253. private sealed class _ServiceFetcher_266 : android.app.ContextImpl.ServiceFetcher
  254. {
  255. public _ServiceFetcher_266()
  256. {
  257. }
  258. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  259. internal override object createService(android.app.ContextImpl ctx)
  260. {
  261. return new android.app.ActivityManager(ctx.getOuterContext(), ctx.mMainThread.getHandler
  262. ());
  263. }
  264. }
  265. private sealed class _StaticServiceFetcher_271 : android.app.ContextImpl.StaticServiceFetcher
  266. {
  267. public _StaticServiceFetcher_271()
  268. {
  269. }
  270. [Sharpen.OverridesMethod(@"android.app.ContextImpl.StaticServiceFetcher")]
  271. public override object createStaticService()
  272. {
  273. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  274. .ALARM_SERVICE);
  275. android.app.IAlarmManager service = android.app.IAlarmManagerClass.Stub.asInterface
  276. (b);
  277. return new android.app.AlarmManager(service);
  278. }
  279. }
  280. private sealed class _ServiceFetcher_278 : android.app.ContextImpl.ServiceFetcher
  281. {
  282. public _ServiceFetcher_278()
  283. {
  284. }
  285. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  286. internal override object createService(android.app.ContextImpl ctx)
  287. {
  288. return new android.media.AudioManager(ctx);
  289. }
  290. }
  291. private sealed class _ServiceFetcher_283 : android.app.ContextImpl.ServiceFetcher
  292. {
  293. public _ServiceFetcher_283()
  294. {
  295. }
  296. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  297. internal override object createService(android.app.ContextImpl ctx)
  298. {
  299. return new android.content.ClipboardManager(ctx.getOuterContext(), ctx.mMainThread
  300. .getHandler());
  301. }
  302. }
  303. private sealed class _StaticServiceFetcher_289 : android.app.ContextImpl.StaticServiceFetcher
  304. {
  305. public _StaticServiceFetcher_289()
  306. {
  307. }
  308. [Sharpen.OverridesMethod(@"android.app.ContextImpl.StaticServiceFetcher")]
  309. public override object createStaticService()
  310. {
  311. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  312. .CONNECTIVITY_SERVICE);
  313. return new android.net.ConnectivityManager(android.net.IConnectivityManagerClass.
  314. Stub.asInterface(b));
  315. }
  316. }
  317. private sealed class _StaticServiceFetcher_295 : android.app.ContextImpl.StaticServiceFetcher
  318. {
  319. public _StaticServiceFetcher_295()
  320. {
  321. }
  322. [Sharpen.OverridesMethod(@"android.app.ContextImpl.StaticServiceFetcher")]
  323. public override object createStaticService()
  324. {
  325. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  326. .COUNTRY_DETECTOR);
  327. return new android.location.CountryDetector(android.location.ICountryDetectorClass
  328. .Stub.asInterface(b));
  329. }
  330. }
  331. private sealed class _ServiceFetcher_301 : android.app.ContextImpl.ServiceFetcher
  332. {
  333. public _ServiceFetcher_301()
  334. {
  335. }
  336. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  337. internal override object createService(android.app.ContextImpl ctx)
  338. {
  339. return android.app.admin.DevicePolicyManager.create(ctx, ctx.mMainThread.getHandler
  340. ());
  341. }
  342. }
  343. private sealed class _ServiceFetcher_306 : android.app.ContextImpl.ServiceFetcher
  344. {
  345. public _ServiceFetcher_306()
  346. {
  347. }
  348. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  349. internal override object createService(android.app.ContextImpl ctx)
  350. {
  351. return new android.app.DownloadManager(ctx.getContentResolver(), ctx.getPackageName
  352. ());
  353. }
  354. }
  355. private sealed class _ServiceFetcher_311 : android.app.ContextImpl.ServiceFetcher
  356. {
  357. public _ServiceFetcher_311()
  358. {
  359. }
  360. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  361. internal override object createService(android.app.ContextImpl ctx)
  362. {
  363. return new android.nfc.NfcManager(ctx);
  364. }
  365. }
  366. private sealed class _StaticServiceFetcher_316 : android.app.ContextImpl.StaticServiceFetcher
  367. {
  368. public _StaticServiceFetcher_316()
  369. {
  370. }
  371. [Sharpen.OverridesMethod(@"android.app.ContextImpl.StaticServiceFetcher")]
  372. public override object createStaticService()
  373. {
  374. return android.app.ContextImpl.createDropBoxManager();
  375. }
  376. }
  377. private sealed class _ServiceFetcher_321 : android.app.ContextImpl.ServiceFetcher
  378. {
  379. public _ServiceFetcher_321()
  380. {
  381. }
  382. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  383. internal override object createService(android.app.ContextImpl ctx)
  384. {
  385. return android.view.inputmethod.InputMethodManager.getInstance(ctx);
  386. }
  387. }
  388. private sealed class _ServiceFetcher_326 : android.app.ContextImpl.ServiceFetcher
  389. {
  390. public _ServiceFetcher_326()
  391. {
  392. }
  393. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  394. internal override object createService(android.app.ContextImpl ctx)
  395. {
  396. return android.view.textservice.TextServicesManager.getInstance();
  397. }
  398. }
  399. private sealed class _ServiceFetcher_331 : android.app.ContextImpl.ServiceFetcher
  400. {
  401. public _ServiceFetcher_331()
  402. {
  403. }
  404. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  405. internal override object getService(android.app.ContextImpl ctx)
  406. {
  407. return new android.app.KeyguardManager();
  408. }
  409. }
  410. private sealed class _ServiceFetcher_340 : android.app.ContextImpl.ServiceFetcher
  411. {
  412. public _ServiceFetcher_340()
  413. {
  414. }
  415. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  416. internal override object createService(android.app.ContextImpl ctx)
  417. {
  418. return android.policy.@internal.PolicyManager.makeNewLayoutInflater(ctx.getOuterContext
  419. ());
  420. }
  421. }
  422. private sealed class _StaticServiceFetcher_345 : android.app.ContextImpl.StaticServiceFetcher
  423. {
  424. public _StaticServiceFetcher_345()
  425. {
  426. }
  427. [Sharpen.OverridesMethod(@"android.app.ContextImpl.StaticServiceFetcher")]
  428. public override object createStaticService()
  429. {
  430. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  431. .LOCATION_SERVICE);
  432. return new android.location.LocationManager(android.location.ILocationManagerClass
  433. .Stub.asInterface(b));
  434. }
  435. }
  436. private sealed class _ServiceFetcher_351 : android.app.ContextImpl.ServiceFetcher
  437. {
  438. public _ServiceFetcher_351()
  439. {
  440. }
  441. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  442. internal override object createService(android.app.ContextImpl ctx)
  443. {
  444. return new android.net.NetworkPolicyManager(android.net.INetworkPolicyManagerClass
  445. .Stub.asInterface(android.os.ServiceManager.getService(android.content.Context.NETWORK_POLICY_SERVICE
  446. )));
  447. }
  448. }
  449. private sealed class _ServiceFetcher_359 : android.app.ContextImpl.ServiceFetcher
  450. {
  451. public _ServiceFetcher_359()
  452. {
  453. }
  454. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  455. internal override object createService(android.app.ContextImpl ctx)
  456. {
  457. android.content.Context outerContext = ctx.getOuterContext();
  458. return new android.app.NotificationManager(new android.view.ContextThemeWrapper(outerContext
  459. , android.content.res.Resources.selectSystemTheme(0, outerContext.getApplicationInfo
  460. ().targetSdkVersion, android.@internal.R.style.Theme_Dialog, android.@internal.R
  461. .style.Theme_Holo_Dialog, android.@internal.R.style.Theme_DeviceDefault_Dialog))
  462. , ctx.mMainThread.getHandler());
  463. }
  464. }
  465. private sealed class _ServiceFetcher_375 : android.app.ContextImpl.ServiceFetcher
  466. {
  467. public _ServiceFetcher_375()
  468. {
  469. }
  470. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  471. internal override object createService(android.app.ContextImpl ctx)
  472. {
  473. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  474. .POWER_SERVICE);
  475. android.os.IPowerManager service = android.os.IPowerManagerClass.Stub.asInterface
  476. (b);
  477. return new android.os.PowerManager(service, ctx.mMainThread.getHandler());
  478. }
  479. }
  480. private sealed class _ServiceFetcher_382 : android.app.ContextImpl.ServiceFetcher
  481. {
  482. public _ServiceFetcher_382()
  483. {
  484. }
  485. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  486. internal override object createService(android.app.ContextImpl ctx)
  487. {
  488. return new android.app.SearchManager(ctx.getOuterContext(), ctx.mMainThread.getHandler
  489. ());
  490. }
  491. }
  492. private sealed class _ServiceFetcher_388 : android.app.ContextImpl.ServiceFetcher
  493. {
  494. public _ServiceFetcher_388()
  495. {
  496. }
  497. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  498. internal override object createService(android.app.ContextImpl ctx)
  499. {
  500. return new android.hardware.SensorManager(ctx.mMainThread.getHandler().getLooper(
  501. ));
  502. }
  503. }
  504. private sealed class _ServiceFetcher_393 : android.app.ContextImpl.ServiceFetcher
  505. {
  506. public _ServiceFetcher_393()
  507. {
  508. }
  509. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  510. internal override object createService(android.app.ContextImpl ctx)
  511. {
  512. return new android.app.StatusBarManager(ctx.getOuterContext());
  513. }
  514. }
  515. private sealed class _ServiceFetcher_398 : android.app.ContextImpl.ServiceFetcher
  516. {
  517. public _ServiceFetcher_398()
  518. {
  519. }
  520. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  521. internal override object createService(android.app.ContextImpl ctx)
  522. {
  523. try
  524. {
  525. return new android.os.storage.StorageManager(ctx.mMainThread.getHandler().getLooper
  526. ());
  527. }
  528. catch (android.os.RemoteException rex)
  529. {
  530. android.util.Log.e(android.app.ContextImpl.TAG, "Failed to create StorageManager"
  531. , rex);
  532. return null;
  533. }
  534. }
  535. }
  536. private sealed class _ServiceFetcher_408 : android.app.ContextImpl.ServiceFetcher
  537. {
  538. public _ServiceFetcher_408()
  539. {
  540. }
  541. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  542. internal override object createService(android.app.ContextImpl ctx)
  543. {
  544. return new android.telephony.TelephonyManager(ctx.getOuterContext());
  545. }
  546. }
  547. private sealed class _StaticServiceFetcher_413 : android.app.ContextImpl.StaticServiceFetcher
  548. {
  549. public _StaticServiceFetcher_413()
  550. {
  551. }
  552. [Sharpen.OverridesMethod(@"android.app.ContextImpl.StaticServiceFetcher")]
  553. public override object createStaticService()
  554. {
  555. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  556. .THROTTLE_SERVICE);
  557. return new android.net.ThrottleManager(android.net.IThrottleManagerClass.Stub.asInterface
  558. (b));
  559. }
  560. }
  561. private sealed class _ServiceFetcher_419 : android.app.ContextImpl.ServiceFetcher
  562. {
  563. public _ServiceFetcher_419()
  564. {
  565. }
  566. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  567. internal override object createService(android.app.ContextImpl ctx)
  568. {
  569. return new android.app.UiModeManager();
  570. }
  571. }
  572. private sealed class _ServiceFetcher_424 : android.app.ContextImpl.ServiceFetcher
  573. {
  574. public _ServiceFetcher_424()
  575. {
  576. }
  577. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  578. internal override object createService(android.app.ContextImpl ctx)
  579. {
  580. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  581. .USB_SERVICE);
  582. return new android.hardware.usb.UsbManager(ctx, android.hardware.usb.IUsbManagerClass
  583. .Stub.asInterface(b));
  584. }
  585. }
  586. private sealed class _ServiceFetcher_430 : android.app.ContextImpl.ServiceFetcher
  587. {
  588. public _ServiceFetcher_430()
  589. {
  590. }
  591. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  592. internal override object createService(android.app.ContextImpl ctx)
  593. {
  594. return new android.os.Vibrator();
  595. }
  596. }
  597. private sealed class _ServiceFetcher_437 : android.app.ContextImpl.ServiceFetcher
  598. {
  599. public _ServiceFetcher_437()
  600. {
  601. }
  602. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  603. internal override object createService(android.app.ContextImpl ctx)
  604. {
  605. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  606. .WIFI_SERVICE);
  607. android.net.wifi.IWifiManager service = android.net.wifi.IWifiManagerClass.Stub.asInterface
  608. (b);
  609. return new android.net.wifi.WifiManager(service, ctx.mMainThread.getHandler());
  610. }
  611. }
  612. private sealed class _ServiceFetcher_444 : android.app.ContextImpl.ServiceFetcher
  613. {
  614. public _ServiceFetcher_444()
  615. {
  616. }
  617. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  618. internal override object createService(android.app.ContextImpl ctx)
  619. {
  620. android.os.IBinder b = android.os.ServiceManager.getService(android.content.Context
  621. .WIFI_P2P_SERVICE);
  622. android.net.wifi.p2p.IWifiP2pManager service = android.net.wifi.p2p.IWifiP2pManagerClass
  623. .Stub.asInterface(b);
  624. return new android.net.wifi.p2p.WifiP2pManager(service);
  625. }
  626. }
  627. private sealed class _ServiceFetcher_451 : android.app.ContextImpl.ServiceFetcher
  628. {
  629. public _ServiceFetcher_451()
  630. {
  631. }
  632. [Sharpen.OverridesMethod(@"android.app.ContextImpl.ServiceFetcher")]
  633. internal override object getService(android.app.ContextImpl ctx)
  634. {
  635. return android.view.WindowManagerImpl.getDefault(ctx.mPackageInfo.mCompatibilityInfo
  636. );
  637. }
  638. }
  639. internal static android.app.ContextImpl getImpl(android.content.Context context)
  640. {
  641. android.content.Context nextContext;
  642. while ((context is android.content.ContextWrapper) && (nextContext = ((android.content.ContextWrapper
  643. )context).getBaseContext()) != null)
  644. {
  645. context = nextContext;
  646. }
  647. return (android.app.ContextImpl)context;
  648. }
  649. internal readonly java.util.ArrayList<object> mServiceCache = new java.util.ArrayList
  650. <object>();
  651. // The system service cache for the system services that are
  652. // cached per-ContextImpl. Package-scoped to avoid accessor
  653. // methods.
  654. [Sharpen.OverridesMethod(@"android.content.Context")]
  655. public override android.content.res.AssetManager getAssets()
  656. {
  657. return mResources.getAssets();
  658. }
  659. [Sharpen.OverridesMethod(@"android.content.Context")]
  660. public override android.content.res.Resources getResources()
  661. {
  662. return mResources;
  663. }
  664. // Doesn't matter if we make more than one instance.
  665. [Sharpen.OverridesMethod(@"android.content.Context")]
  666. public override android.content.ContentResolver getContentResolver()
  667. {
  668. return mContentResolver;
  669. }
  670. [Sharpen.OverridesMethod(@"android.content.Context")]
  671. public override android.os.Looper getMainLooper()
  672. {
  673. return mMainThread.getLooper();
  674. }
  675. [Sharpen.OverridesMethod(@"android.content.Context")]
  676. public override android.content.Context getApplicationContext()
  677. {
  678. return (mPackageInfo != null) ? mPackageInfo.getApplication() : mMainThread.getApplication
  679. ();
  680. }
  681. [Sharpen.OverridesMethod(@"android.content.Context")]
  682. public override void setTheme(int resid)
  683. {
  684. mThemeResource = resid;
  685. }
  686. [Sharpen.OverridesMethod(@"android.content.Context")]
  687. public override int getThemeResId()
  688. {
  689. return mThemeResource;
  690. }
  691. [Sharpen.OverridesMethod(@"android.content.Context")]
  692. public override android.content.res.Resources.Theme getTheme()
  693. {
  694. if (mTheme == null)
  695. {
  696. mThemeResource = android.content.res.Resources.selectDefaultTheme(mThemeResource,
  697. getOuterContext().getApplicationInfo().targetSdkVersion);
  698. mTheme = mResources.newTheme();
  699. mTheme.applyStyle(mThemeResource, true);
  700. }
  701. return mTheme;
  702. }
  703. [Sharpen.OverridesMethod(@"android.content.Context")]
  704. public override java.lang.ClassLoader getClassLoader()
  705. {
  706. return mPackageInfo != null ? mPackageInfo.getClassLoader() : java.lang.ClassLoader
  707. .getSystemClassLoader();
  708. }
  709. [Sharpen.OverridesMethod(@"android.content.Context")]
  710. public override string getPackageName()
  711. {
  712. if (mPackageInfo != null)
  713. {
  714. return mPackageInfo.getPackageName();
  715. }
  716. throw new java.lang.RuntimeException("Not supported in system context");
  717. }
  718. [Sharpen.OverridesMethod(@"android.content.Context")]
  719. public override android.content.pm.ApplicationInfo getApplicationInfo()
  720. {
  721. if (mPackageInfo != null)
  722. {
  723. return mPackageInfo.getApplicationInfo();
  724. }
  725. throw new java.lang.RuntimeException("Not supported in system context");
  726. }
  727. [Sharpen.OverridesMethod(@"android.content.Context")]
  728. public override string getPackageResourcePath()
  729. {
  730. if (mPackageInfo != null)
  731. {
  732. return mPackageInfo.getResDir();
  733. }
  734. throw new java.lang.RuntimeException("Not supported in system context");
  735. }
  736. [Sharpen.OverridesMethod(@"android.content.Context")]
  737. public override string getPackageCodePath()
  738. {
  739. if (mPackageInfo != null)
  740. {
  741. return mPackageInfo.getAppDir();
  742. }
  743. throw new java.lang.RuntimeException("Not supported in system context");
  744. }
  745. [Sharpen.OverridesMethod(@"android.content.Context")]
  746. public override java.io.File getSharedPrefsFile(string name)
  747. {
  748. return makeFilename(getPreferencesDir(), name + ".xml");
  749. }
  750. [Sharpen.OverridesMethod(@"android.content.Context")]
  751. public override android.content.SharedPreferences getSharedPreferences(string name
  752. , int mode)
  753. {
  754. android.app.SharedPreferencesImpl sp;
  755. lock (sSharedPrefs)
  756. {
  757. sp = sSharedPrefs.get(name);
  758. if (sp == null)
  759. {
  760. java.io.File prefsFile = getSharedPrefsFile(name);
  761. sp = new android.app.SharedPreferencesImpl(prefsFile, mode);
  762. sSharedPrefs.put(name, sp);
  763. return sp;
  764. }
  765. }
  766. if ((mode & android.content.Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo
  767. ().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB)
  768. {
  769. // If somebody else (some other process) changed the prefs
  770. // file behind our back, we reload it. This has been the
  771. // historical (if undocumented) behavior.
  772. sp.startReloadIfChangedUnexpectedly();
  773. }
  774. return sp;
  775. }
  776. private java.io.File getPreferencesDir()
  777. {
  778. lock (mSync)
  779. {
  780. if (mPreferencesDir == null)
  781. {
  782. mPreferencesDir = new java.io.File(getDataDirFile(), "shared_prefs");
  783. }
  784. return mPreferencesDir;
  785. }
  786. }
  787. /// <exception cref="java.io.FileNotFoundException"></exception>
  788. [Sharpen.OverridesMethod(@"android.content.Context")]
  789. public override java.io.FileInputStream openFileInput(string name)
  790. {
  791. java.io.File f = makeFilename(getFilesDir(), name);
  792. return new java.io.FileInputStream(f);
  793. }
  794. /// <exception cref="java.io.FileNotFoundException"></exception>
  795. [Sharpen.OverridesMethod(@"android.content.Context")]
  796. public override java.io.FileOutputStream openFileOutput(string name, int mode)
  797. {
  798. bool append = (mode & MODE_APPEND) != 0;
  799. java.io.File f = makeFilename(getFilesDir(), name);
  800. try
  801. {
  802. java.io.FileOutputStream fos = new java.io.FileOutputStream(f, append);
  803. setFilePermissionsFromMode(f.getPath(), mode, 0);
  804. return fos;
  805. }
  806. catch (java.io.FileNotFoundException)
  807. {
  808. }
  809. java.io.File parent = f.getParentFile();
  810. parent.mkdir();
  811. android.os.FileUtils.setPermissions(parent.getPath(), android.os.FileUtils.S_IRWXU
  812. | android.os.FileUtils.S_IRWXG | android.os.FileUtils.S_IXOTH, -1, -1);
  813. java.io.FileOutputStream fos_1 = new java.io.FileOutputStream(f, append);
  814. setFilePermissionsFromMode(f.getPath(), mode, 0);
  815. return fos_1;
  816. }
  817. [Sharpen.OverridesMethod(@"android.content.Context")]
  818. public override bool deleteFile(string name)
  819. {
  820. java.io.File f = makeFilename(getFilesDir(), name);
  821. return f.delete();
  822. }
  823. [Sharpen.OverridesMethod(@"android.content.Context")]
  824. public override java.io.File getFilesDir()
  825. {
  826. lock (mSync)
  827. {
  828. if (mFilesDir == null)
  829. {
  830. mFilesDir = new java.io.File(getDataDirFile(), "files");
  831. }
  832. if (!mFilesDir.exists())
  833. {
  834. if (!mFilesDir.mkdirs())
  835. {
  836. android.util.Log.w(TAG, "Unable to create files directory " + mFilesDir.getPath()
  837. );
  838. return null;
  839. }
  840. android.os.FileUtils.setPermissions(mFilesDir.getPath(), android.os.FileUtils.S_IRWXU
  841. | android.os.FileUtils.S_IRWXG | android.os.FileUtils.S_IXOTH, -1, -1);
  842. }
  843. return mFilesDir;
  844. }
  845. }
  846. [Sharpen.OverridesMethod(@"android.content.Context")]
  847. public override java.io.File getExternalFilesDir(string type)
  848. {
  849. lock (mSync)
  850. {
  851. if (mExternalFilesDir == null)
  852. {
  853. mExternalFilesDir = android.os.Environment.getExternalStorageAppFilesDirectory(getPackageName
  854. ());
  855. }
  856. if (!mExternalFilesDir.exists())
  857. {
  858. try
  859. {
  860. (new java.io.File(android.os.Environment.getExternalStorageAndroidDataDir(), ".nomedia"
  861. )).createNewFile();
  862. }
  863. catch (System.IO.IOException)
  864. {
  865. }
  866. if (!mExternalFilesDir.mkdirs())
  867. {
  868. android.util.Log.w(TAG, "Unable to create external files directory");
  869. return null;
  870. }
  871. }
  872. if (type == null)
  873. {
  874. return mExternalFilesDir;
  875. }
  876. java.io.File dir = new java.io.File(mExternalFilesDir, type);
  877. if (!dir.exists())
  878. {
  879. if (!dir.mkdirs())
  880. {
  881. android.util.Log.w(TAG, "Unable to create external media directory " + dir);
  882. return null;
  883. }
  884. }
  885. return dir;
  886. }
  887. }
  888. [Sharpen.OverridesMethod(@"android.content.Context")]
  889. public override java.io.File getObbDir()
  890. {
  891. lock (mSync)
  892. {
  893. if (mObbDir == null)
  894. {
  895. mObbDir = android.os.Environment.getExternalStorageAppObbDirectory(getPackageName
  896. ());
  897. }
  898. return mObbDir;
  899. }
  900. }
  901. [Sharpen.OverridesMethod(@"android.content.Context")]
  902. public override java.io.File getCacheDir()
  903. {
  904. lock (mSync)
  905. {
  906. if (mCacheDir == null)
  907. {
  908. mCacheDir = new java.io.File(getDataDirFile(), "cache");
  909. }
  910. if (!mCacheDir.exists())
  911. {
  912. if (!mCacheDir.mkdirs())
  913. {
  914. android.util.Log.w(TAG, "Unable to create cache directory");
  915. return null;
  916. }
  917. android.os.FileUtils.setPermissions(mCacheDir.getPath(), android.os.FileUtils.S_IRWXU
  918. | android.os.FileUtils.S_IRWXG | android.os.FileUtils.S_IXOTH, -1, -1);
  919. }
  920. }
  921. return mCacheDir;
  922. }
  923. [Sharpen.OverridesMethod(@"android.content.Context")]
  924. public override java.io.File getExternalCacheDir()
  925. {
  926. lock (mSync)
  927. {
  928. if (mExternalCacheDir == null)
  929. {
  930. mExternalCacheDir = android.os.Environment.getExternalStorageAppCacheDirectory(getPackageName
  931. ());
  932. }
  933. if (!mExternalCacheDir.exists())
  934. {
  935. try
  936. {
  937. (new java.io.File(android.os.Environment.getExternalStorageAndroidDataDir(), ".nomedia"
  938. )).createNewFile();
  939. }
  940. catch (System.IO.IOException)
  941. {
  942. }
  943. if (!mExternalCacheDir.mkdirs())
  944. {
  945. android.util.Log.w(TAG, "Unable to create external cache directory");
  946. return null;
  947. }
  948. }
  949. return mExternalCacheDir;
  950. }
  951. }
  952. [Sharpen.OverridesMethod(@"android.content.Context")]
  953. public override java.io.File getFileStreamPath(string name)
  954. {
  955. return makeFilename(getFilesDir(), name);
  956. }
  957. [Sharpen.OverridesMethod(@"android.content.Context")]
  958. public override string[] fileList()
  959. {
  960. string[] list = getFilesDir().list();
  961. return (list != null) ? list : EMPTY_FILE_LIST;
  962. }
  963. [Sharpen.OverridesMethod(@"android.content.Context")]
  964. public override android.database.sqlite.SQLiteDatabase openOrCreateDatabase(string
  965. name, int mode, android.database.sqlite.SQLiteDatabase.CursorFactory factory)
  966. {
  967. java.io.File f = validateFilePath(name, true);
  968. android.database.sqlite.SQLiteDatabase db = android.database.sqlite.SQLiteDatabase
  969. .openOrCreateDatabase(f, factory);
  970. setFilePermissionsFromMode(f.getPath(), mode, 0);
  971. return db;
  972. }
  973. [Sharpen.OverridesMethod(@"android.content.Context")]
  974. public override android.database.sqlite.SQLiteDatabase openOrCreateDatabase(string
  975. name, int mode, android.database.sqlite.SQLiteDatabase.CursorFactory factory, android.database.DatabaseErrorHandler
  976. errorHandler)
  977. {
  978. java.io.File f = validateFilePath(name, true);
  979. android.database.sqlite.SQLiteDatabase db = android.database.sqlite.SQLiteDatabase
  980. .openOrCreateDatabase(f.getPath(), factory, errorHandler);
  981. setFilePermissionsFromMode(f.getPath(), mode, 0);
  982. return db;
  983. }
  984. [Sharpen.OverridesMethod(@"android.content.Context")]
  985. public override bool deleteDatabase(string name)
  986. {
  987. try
  988. {
  989. java.io.File f = validateFilePath(name, false);
  990. return f.delete();
  991. }
  992. catch (System.Exception)
  993. {
  994. }
  995. return false;
  996. }
  997. [Sharpen.OverridesMethod(@"android.content.Context")]
  998. public override java.io.File getDatabasePath(string name)
  999. {
  1000. return validateFilePath(name, false);
  1001. }
  1002. [Sharpen.OverridesMethod(@"android.content.Context")]
  1003. public override string[] databaseList()
  1004. {
  1005. string[] list = getDatabasesDir().list();
  1006. return (list != null) ? list : EMPTY_FILE_LIST;
  1007. }
  1008. private java.io.File getDatabasesDir()
  1009. {
  1010. lock (mSync)
  1011. {
  1012. if (mDatabasesDir == null)
  1013. {
  1014. mDatabasesDir = new java.io.File(getDataDirFile(), "databases");
  1015. }
  1016. if (mDatabasesDir.getPath().Equals("databases"))
  1017. {
  1018. mDatabasesDir = new java.io.File("/data/system");
  1019. }
  1020. return mDatabasesDir;
  1021. }
  1022. }
  1023. [Sharpen.OverridesMethod(@"android.content.Context")]
  1024. public override android.graphics.drawable.Drawable getWallpaper()
  1025. {
  1026. return getWallpaperManager().getDrawable();
  1027. }
  1028. [Sharpen.OverridesMethod(@"android.content.Context")]
  1029. public override android.graphics.drawable.Drawable peekWallpaper()
  1030. {
  1031. return getWallpaperManager().peekDrawable();
  1032. }
  1033. [Sharpen.OverridesMethod(@"android.content.Context")]
  1034. public override int getWallpaperDesiredMinimumWidth()
  1035. {
  1036. return getWallpaperManager().getDesiredMinimumWidth();
  1037. }
  1038. [Sharpen.OverridesMethod(@"android.content.Context")]
  1039. public override int getWallpaperDesiredMinimumHeight()
  1040. {
  1041. return getWallpaperManager().getDesiredMinimumHeight();
  1042. }
  1043. /// <exception cref="System.IO.IOException"></exception>
  1044. [Sharpen.OverridesMethod(@"android.content.Context")]
  1045. public override void setWallpaper(android.graphics.Bitmap bitmap)
  1046. {
  1047. getWallpaperManager().setBitmap(bitmap);
  1048. }
  1049. /// <exception cref="System.IO.IOException"></exception>
  1050. [Sharpen.OverridesMethod(@"android.content.Context")]
  1051. public override void setWallpaper(java.io.InputStream data)
  1052. {
  1053. getWallpaperManager().setStream(data);
  1054. }
  1055. /// <exception cref="System.IO.IOException"></exception>
  1056. [Sharpen.OverridesMethod(@"android.content.Context")]
  1057. public override void clearWallpaper()
  1058. {
  1059. getWallpaperManager().clear();
  1060. }
  1061. [Sharpen.OverridesMethod(@"android.content.Context")]
  1062. public override void startActivity(android.content.Intent intent)
  1063. {
  1064. if ((intent.getFlags() & android.content.Intent.FLAG_ACTIVITY_NEW_TASK) == 0)
  1065. {
  1066. throw new android.util.AndroidRuntimeException("Calling startActivity() from outside of an Activity "
  1067. + " context requires the FLAG_ACTIVITY_NEW_TASK flag." + " Is this really what you want?"
  1068. );
  1069. }
  1070. mMainThread.getInstrumentation().execStartActivity(getOuterContext(), mMainThread
  1071. .getApplicationThread(), null, (android.app.Activity)null, intent, -1);
  1072. }
  1073. [Sharpen.OverridesMethod(@"android.content.Context")]
  1074. public override void startActivities(android.content.Intent[] intents)
  1075. {
  1076. if ((intents[0].getFlags() & android.content.Intent.FLAG_ACTIVITY_NEW_TASK) == 0)
  1077. {
  1078. throw new android.util.AndroidRuntimeException("Calling startActivities() from outside of an Activity "
  1079. + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent." + " Is this really what you want?"
  1080. );
  1081. }
  1082. mMainThread.getInstrumentation().execStartActivities(getOuterContext(), mMainThread
  1083. .getApplicationThread(), null, (android.app.Activity)null, intents);
  1084. }
  1085. /// <exception cref="android.content.IntentSender.SendIntentException"></exception>
  1086. [Sharpen.OverridesMethod(@"android.content.Context")]
  1087. public override void startIntentSender(android.content.IntentSender intent, android.content.Intent
  1088. fillInIntent, int flagsMask, int flagsValues, int extraFlags)
  1089. {
  1090. try
  1091. {
  1092. string resolvedType = null;
  1093. if (fillInIntent != null)
  1094. {
  1095. fillInIntent.setAllowFds(false);
  1096. resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
  1097. }
  1098. int result = android.app.ActivityManagerNative.getDefault().startActivityIntentSender
  1099. (mMainThread.getApplicationThread(), intent, fillInIntent, resolvedType, null, null
  1100. , 0, flagsMask, flagsValues);
  1101. if (result == android.app.IActivityManagerClass.START_CANCELED)
  1102. {
  1103. throw new android.content.IntentSender.SendIntentException();
  1104. }
  1105. android.app.Instrumentation.checkStartActivityResult(result, null);
  1106. }
  1107. catch (android.os.RemoteException)
  1108. {
  1109. }
  1110. }
  1111. [Sharpen.OverridesMethod(@"android.content.Context")]
  1112. public override void sendBroadcast(android.content.Intent intent)
  1113. {
  1114. string resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
  1115. try
  1116. {
  1117. intent.setAllowFds(false);
  1118. android.app.ActivityManagerNative.getDefault().broadcastIntent(mMainThread.getApplicationThread
  1119. (), intent, resolvedType, null, android.app.Activity.RESULT_OK, null, null, null
  1120. , false, false);
  1121. }
  1122. catch (android.os.RemoteException)
  1123. {
  1124. }
  1125. }
  1126. [Sharpen.OverridesMethod(@"android.content.Context")]
  1127. public override void sendBroadcast(android.content.Intent intent, string receiverPermission
  1128. )
  1129. {
  1130. string resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
  1131. try
  1132. {
  1133. intent.setAllowFds(false);
  1134. android.app.ActivityManagerNative.getDefault().broadcastIntent(mMainThread.getApplicationThread
  1135. (), intent, resolvedType, null, android.app.Activity.RESULT_OK, null, null, receiverPermission
  1136. , false, false);
  1137. }
  1138. catch (android.os.RemoteException)
  1139. {
  1140. }
  1141. }
  1142. [Sharpen.Stub]
  1143. [Sharpen.OverridesMethod(@"android.content.Context")]
  1144. public override void sendOrderedBroadcast(android.content.Intent intent, string receiverPermission
  1145. )
  1146. {
  1147. throw new System.NotImplementedException();
  1148. }
  1149. [Sharpen.Stub]
  1150. [Sharpen.OverridesMethod(@"android.content.Context")]
  1151. public override void sendOrderedBroadcast(android.content.Intent intent, string receiverPermission
  1152. , android.content.BroadcastReceiver resultReceiver, android.os.Handler scheduler
  1153. , int initialCode, string initialData, android.os.Bundle initialExtras)
  1154. {
  1155. throw new System.NotImplementedException();
  1156. }
  1157. [Sharpen.OverridesMethod(@"android.content.Context")]
  1158. public override void sendStickyBroadcast(android.content.Intent intent)
  1159. {
  1160. string resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
  1161. try
  1162. {
  1163. intent.setAllowFds(false);
  1164. android.app.ActivityManagerNative.getDefault().broadcastIntent(mMainThread.getApplicationThread
  1165. (), intent, resolvedType, null, android.app.Activity.RESULT_OK, null, null, null
  1166. , false, true);
  1167. }
  1168. catch (android.os.RemoteException)
  1169. {
  1170. }
  1171. }
  1172. [Sharpen.Stub]
  1173. [Sharpen.OverridesMethod(@"android.content.Context")]
  1174. public override void sendStickyOrderedBroadcast(android.content.Intent intent, android.content.BroadcastReceiver
  1175. resultReceiver, android.os.Handler scheduler, int initialCode, string initialData
  1176. , android.os.Bundle initialExtras)
  1177. {
  1178. throw new System.NotImplementedException();
  1179. }
  1180. [Sharpen.OverridesMethod(@"android.content.Context")]
  1181. public override void removeStickyBroadcast(android.content.Intent intent)
  1182. {
  1183. string resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
  1184. if (resolvedType != null)
  1185. {
  1186. intent = new android.content.Intent(intent);
  1187. intent.setDataAndType(intent.getData(), resolvedType);
  1188. }
  1189. try
  1190. {
  1191. intent.setAllowFds(false);
  1192. android.app.ActivityManagerNative.getDefault().unbroadcastIntent(mMainThread.getApplicationThread
  1193. (), intent);
  1194. }
  1195. catch (android.os.RemoteException)
  1196. {
  1197. }
  1198. }
  1199. [Sharpen.OverridesMethod(@"android.content.Context")]
  1200. public override android.content.Intent registerReceiver(android.content.BroadcastReceiver
  1201. receiver, android.content.IntentFilter filter)
  1202. {
  1203. return registerReceiver(receiver, filter, null, null);
  1204. }
  1205. [Sharpen.OverridesMethod(@"android.content.Context")]
  1206. public override android.content.Intent registerReceiver(android.content.BroadcastReceiver
  1207. receiver, android.content.IntentFilter filter, string broadcastPermission, android.os.Handler
  1208. scheduler)
  1209. {
  1210. return registerReceiverInternal(receiver, filter, broadcastPermission, scheduler,
  1211. getOuterContext());
  1212. }
  1213. [Sharpen.Stub]
  1214. private android.content.Intent registerReceiverInternal(android.content.BroadcastReceiver
  1215. receiver, android.content.IntentFilter filter, string broadcastPermission, android.os.Handler
  1216. scheduler, android.content.Context context)
  1217. {
  1218. throw new System.NotImplementedException();
  1219. }
  1220. [Sharpen.OverridesMethod(@"android.content.Context")]
  1221. public override void unregisterReceiver(android.content.BroadcastReceiver receiver
  1222. )
  1223. {
  1224. if (mPackageInfo != null)
  1225. {
  1226. android.content.IIntentReceiver rd = mPackageInfo.forgetReceiverDispatcher(getOuterContext
  1227. (), receiver);
  1228. try
  1229. {
  1230. android.app.ActivityManagerNative.getDefault().unregisterReceiver(rd);
  1231. }
  1232. catch (android.os.RemoteException)
  1233. {
  1234. }
  1235. }
  1236. else
  1237. {
  1238. throw new java.lang.RuntimeException("Not supported in system context");
  1239. }
  1240. }
  1241. [Sharpen.OverridesMethod(@"android.content.Context")]
  1242. public override android.content.ComponentName startService(android.content.Intent
  1243. service)
  1244. {
  1245. try
  1246. {
  1247. service.setAllowFds(false);
  1248. android.content.ComponentName cn = android.app.ActivityManagerNative.getDefault()
  1249. .startService(mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded
  1250. (getContentResolver()));
  1251. if (cn != null && cn.getPackageName().Equals("!"))
  1252. {
  1253. throw new System.Security.SecurityException("Not allowed to start service " + service
  1254. + " without permission " + cn.getClassName());
  1255. }
  1256. return cn;
  1257. }
  1258. catch (android.os.RemoteException)
  1259. {
  1260. return null;
  1261. }
  1262. }
  1263. [Sharpen.OverridesMethod(@"android.content.Context")]
  1264. public override bool stopService(android.content.Intent service)
  1265. {
  1266. try
  1267. {
  1268. service.setAllowFds(false);
  1269. int res = android.app.ActivityManagerNative.getDefault().stopService(mMainThread.
  1270. getApplicationThread(), service, service.resolveTypeIfNeeded(getContentResolver(
  1271. )));
  1272. if (res < 0)
  1273. {
  1274. throw new System.Security.SecurityException("Not allowed to stop service " + service
  1275. );
  1276. }
  1277. return res != 0;
  1278. }
  1279. catch (android.os.RemoteException)
  1280. {
  1281. return false;
  1282. }
  1283. }
  1284. [Sharpen.OverridesMethod(@"android.content.Context")]
  1285. public override bool bindService(android.content.Intent service, android.content.ServiceConnection
  1286. conn, int flags)
  1287. {
  1288. android.app.IServiceConnection sd;
  1289. if (mPackageInfo != null)
  1290. {
  1291. sd = mPackageInfo.getServiceDispatcher(conn, getOuterContext(), mMainThread.getHandler
  1292. (), flags);
  1293. }
  1294. else
  1295. {
  1296. throw new java.lang.RuntimeException("Not supported in system context");
  1297. }
  1298. try
  1299. {
  1300. android.os.IBinder token = getActivityToken();
  1301. if (token == null && (flags & BIND_AUTO_CREATE) == 0 && mPackageInfo != null && mPackageInfo
  1302. .getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  1303. {
  1304. flags |= BIND_WAIVE_PRIORITY;
  1305. }
  1306. service.setAllowFds(false);
  1307. int res = android.app.ActivityManagerNative.getDefault().bindService(mMainThread.
  1308. getApplicationThread(), getActivityToken(), service, service.resolveTypeIfNeeded
  1309. (getContentResolver()), sd, flags);
  1310. if (res < 0)
  1311. {
  1312. throw new System.Security.SecurityException("Not allowed to bind to service " + service
  1313. );
  1314. }
  1315. return res != 0;
  1316. }
  1317. catch (android.os.RemoteException)
  1318. {
  1319. return false;
  1320. }
  1321. }
  1322. [Sharpen.OverridesMethod(@"android.content.Context")]
  1323. public override void unbindService(android.content.ServiceConnection conn)
  1324. {
  1325. if (mPackageInfo != null)
  1326. {
  1327. android.app.IServiceConnection sd = mPackageInfo.forgetServiceDispatcher(getOuterContext
  1328. (), conn);
  1329. try
  1330. {
  1331. android.app.ActivityManagerNative.getDefault().unbindService(sd);
  1332. }
  1333. catch (android.os.RemoteException)
  1334. {
  1335. }
  1336. }
  1337. else
  1338. {
  1339. throw new java.lang.RuntimeException("Not supported in system context");
  1340. }
  1341. }
  1342. [Sharpen.OverridesMethod(@"android.content.Context")]
  1343. public override bool startInstrumentation(android.content.ComponentName className
  1344. , string profileFile, android.os.Bundle arguments)
  1345. {
  1346. try
  1347. {
  1348. if (arguments != null)
  1349. {
  1350. arguments.setAllowFds(false);
  1351. }
  1352. return android.app.ActivityManagerNative.getDefault().startInstrumentation(className
  1353. , profileFile, 0, arguments, null);
  1354. }
  1355. catch (android.os.RemoteException)
  1356. {
  1357. }
  1358. // System has crashed, nothing we can do.
  1359. return false;
  1360. }
  1361. [Sharpen.OverridesMethod(@"android.content.Context")]
  1362. public override object getSystemService(string name)
  1363. {
  1364. android.app.ContextImpl.ServiceFetcher fetcher = SYSTEM_SERVICE_MAP.get(name);
  1365. return fetcher == null ? null : fetcher.getService(this);
  1366. }
  1367. private android.app.WallpaperManager getWallpaperManager()
  1368. {
  1369. return (android.app.WallpaperManager)WALLPAPER_FETCHER.getService(this);
  1370. }
  1371. [Sharpen.Stub]
  1372. internal static android.os.DropBoxManager createDropBoxManager()
  1373. {
  1374. throw new System.NotImplementedException();
  1375. }
  1376. // Don't return a DropBoxManager that will NPE upon use.
  1377. // This also avoids caching a broken DropBoxManager in
  1378. // getDropBoxManager during early boot, before the
  1379. // DROPBOX_SERVICE is registered.
  1380. [Sharpen.OverridesMethod(@"android.content.Context")]
  1381. public override int checkPermission(string permission, int pid, int uid)
  1382. {
  1383. if (permission == null)
  1384. {
  1385. throw new System.ArgumentException("permission is null");
  1386. }
  1387. try
  1388. {
  1389. return android.app.ActivityManagerNative.getDefault().checkPermission(permission,
  1390. pid, uid);
  1391. }
  1392. catch (android.os.RemoteException)
  1393. {
  1394. return android.content.pm.PackageManager.PERMISSION_DENIED;
  1395. }
  1396. }
  1397. [Sharpen.OverridesMethod(@"android.content.Context")]
  1398. public override int checkCallingPermission(string permission)
  1399. {
  1400. if (permission == null)
  1401. {
  1402. throw new System.ArgumentException("permission is null");
  1403. }
  1404. int pid = android.os.Binder.getCallingPid();
  1405. if (pid != android.os.Process.myPid())
  1406. {
  1407. return checkPermission(permission, pid, android.os.Binder.getCallingUid());
  1408. }
  1409. return android.content.pm.PackageManager.PERMISSION_DENIED;
  1410. }
  1411. [Sharpen.OverridesMethod(@"android.content.Context")]
  1412. public override int checkCallingOrSelfPermission(string permission)
  1413. {
  1414. if (permission == null)
  1415. {
  1416. throw new System.ArgumentException("permission is null");
  1417. }
  1418. return checkPermission(permission, android.os.Binder.getCallingPid(), android.os.Binder
  1419. .getCallingUid());
  1420. }
  1421. private void enforce(string permission, int resultOfCheck, bool selfToo, int uid,
  1422. string message)
  1423. {
  1424. if (resultOfCheck != android.content.pm.PackageManager.PERMISSION_GRANTED)
  1425. {
  1426. throw new System.Security.SecurityException((message != null ? (message + ": ") :
  1427. string.Empty) + (selfToo ? "Neither user " + uid + " nor current process has " :
  1428. "User " + uid + " does not have ") + permission + ".");
  1429. }
  1430. }
  1431. [Sharpen.OverridesMethod(@"android.content.Context")]
  1432. public override void enforcePermission(string permission, int pid, int