Java Code Examples for android.content.Context#BIND_ABOVE_CLIENT
The following examples show how to use
android.content.Context#BIND_ABOVE_CLIENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServersActivity.java From Atomic with GNU General Public License v3.0 | 6 votes |
/** * On resume */ @Override public void onResume() { super.onResume(); // Start and connect to service Intent intent = new Intent(this, IRCService.class); intent.setAction(IRCService.ACTION_BACKGROUND); startService(intent); int flags = 0; if( android.os.Build.VERSION.SDK_INT >= 14 ) { flags |= Context.BIND_ABOVE_CLIENT; } bindService(intent, this, flags); receiver = new ServerReceiver(this); registerReceiver(receiver, new IntentFilter(Broadcast.SERVER_UPDATE)); adapter.loadServers(); }
Example 2
Source File: ProcessRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void updateHasAboveClientLocked() { hasAboveClient = false; for (int i=connections.size()-1; i>=0; i--) { ConnectionRecord cr = connections.valueAt(i); if ((cr.flags&Context.BIND_ABOVE_CLIENT) != 0) { hasAboveClient = true; break; } } }
Example 3
Source File: ActiveServices.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
void removeConnectionLocked( ConnectionRecord c, ProcessRecord skipApp, ActivityRecord skipAct) { IBinder binder = c.conn.asBinder(); AppBindRecord b = c.binding; ServiceRecord s = b.service; ArrayList<ConnectionRecord> clist = s.connections.get(binder); if (clist != null) { clist.remove(c); if (clist.size() == 0) { s.connections.remove(binder); } } b.connections.remove(c); if (c.activity != null && c.activity != skipAct) { if (c.activity.connections != null) { c.activity.connections.remove(c); } } if (b.client != skipApp) { b.client.connections.remove(c); if ((c.flags&Context.BIND_ABOVE_CLIENT) != 0) { b.client.updateHasAboveClientLocked(); } // If this connection requested whitelist management, see if we should // now clear that state. if ((c.flags&Context.BIND_ALLOW_WHITELIST_MANAGEMENT) != 0) { s.updateWhitelistManager(); if (!s.whitelistManager && s.app != null) { updateWhitelistManagerLocked(s.app); } } if (s.app != null) { updateServiceClientActivitiesLocked(s.app, c, true); } } clist = mServiceConnections.get(binder); if (clist != null) { clist.remove(c); if (clist.size() == 0) { mServiceConnections.remove(binder); } } mAm.stopAssociationLocked(b.client.uid, b.client.processName, s.appInfo.uid, s.name); if (b.connections.size() == 0) { b.intent.apps.remove(b.client); } if (!c.serviceDead) { if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Disconnecting binding " + b.intent + ": shouldUnbind=" + b.intent.hasBound); if (s.app != null && s.app.thread != null && b.intent.apps.size() == 0 && b.intent.hasBound) { try { bumpServiceExecutingLocked(s, false, "unbind"); if (b.client != s.app && (c.flags&Context.BIND_WAIVE_PRIORITY) == 0 && s.app.setProcState <= ActivityManager.PROCESS_STATE_HEAVY_WEIGHT) { // If this service's process is not already in the cached list, // then update it in the LRU list here because this may be causing // it to go down there and we want it to start out near the top. mAm.updateLruProcessLocked(s.app, false, null); } mAm.updateOomAdjLocked(s.app, true); b.intent.hasBound = false; // Assume the client doesn't want to know about a rebind; // we will deal with that later if it asks for one. b.intent.doRebind = false; s.app.thread.scheduleUnbindService(s, b.intent.intent.getIntent()); } catch (Exception e) { Slog.w(TAG, "Exception when unbinding service " + s.shortName, e); serviceProcessGoneLocked(s); } } // If unbound while waiting to start, remove the pending service mPendingServices.remove(s); if ((c.flags&Context.BIND_AUTO_CREATE) != 0) { boolean hasAutoCreate = s.hasAutoCreateConnections(); if (!hasAutoCreate) { if (s.tracker != null) { s.tracker.setBound(false, mAm.mProcessStats.getMemFactorLocked(), SystemClock.uptimeMillis()); } } bringDownServiceIfNeededLocked(s, true, hasAutoCreate); } } }
Example 4
Source File: ConnectionRecord.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public String toString() { if (stringName != null) { return stringName; } StringBuilder sb = new StringBuilder(128); sb.append("ConnectionRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(" u"); sb.append(binding.client.userId); sb.append(' '); if ((flags&Context.BIND_AUTO_CREATE) != 0) { sb.append("CR "); } if ((flags&Context.BIND_DEBUG_UNBIND) != 0) { sb.append("DBG "); } if ((flags&Context.BIND_NOT_FOREGROUND) != 0) { sb.append("!FG "); } if ((flags&Context.BIND_IMPORTANT_BACKGROUND) != 0) { sb.append("IMPB "); } if ((flags&Context.BIND_ABOVE_CLIENT) != 0) { sb.append("ABCLT "); } if ((flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) { sb.append("OOM "); } if ((flags&Context.BIND_WAIVE_PRIORITY) != 0) { sb.append("WPRI "); } if ((flags&Context.BIND_IMPORTANT) != 0) { sb.append("IMP "); } if ((flags&Context.BIND_ADJUST_WITH_ACTIVITY) != 0) { sb.append("WACT "); } if ((flags&Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE) != 0) { sb.append("FGSA "); } if ((flags&Context.BIND_FOREGROUND_SERVICE) != 0) { sb.append("FGS "); } if ((flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) { sb.append("LACT "); } if ((flags&Context.BIND_VISIBLE) != 0) { sb.append("VIS "); } if ((flags&Context.BIND_SHOWING_UI) != 0) { sb.append("UI "); } if ((flags&Context.BIND_NOT_VISIBLE) != 0) { sb.append("!VIS "); } if (serviceDead) { sb.append("DEAD "); } sb.append(binding.service.shortName); sb.append(":@"); sb.append(Integer.toHexString(System.identityHashCode(conn.asBinder()))); sb.append('}'); return stringName = sb.toString(); }
Example 5
Source File: ConnectionBindRecord.java From springreplugin with Apache License 2.0 | 4 votes |
public String toString() { if (stringName != null) { return stringName; } StringBuilder sb = new StringBuilder(128); sb.append("ConnectionBindRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(" p"); sb.append(binding.client.pid); sb.append(' '); if ((flags & Context.BIND_AUTO_CREATE) != 0) { sb.append("CR "); } if ((flags & Context.BIND_DEBUG_UNBIND) != 0) { sb.append("DBG "); } if ((flags & Context.BIND_NOT_FOREGROUND) != 0) { sb.append("!FG "); } if ((flags & Context.BIND_ABOVE_CLIENT) != 0) { sb.append("ABCLT "); } if ((flags & Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) { sb.append("OOM "); } if ((flags & Context.BIND_WAIVE_PRIORITY) != 0) { sb.append("WPRI "); } if ((flags & Context.BIND_IMPORTANT) != 0) { sb.append("IMP "); } if ((flags & Context.BIND_ADJUST_WITH_ACTIVITY) != 0) { sb.append("WACT "); } if (serviceDead) { sb.append("DEAD "); } sb.append(binding.service.shortName); sb.append(":@"); sb.append(Integer.toHexString(System.identityHashCode(conn.asBinder()))); sb.append('}'); stringName = sb.toString(); return stringName; }