android.content.Context#BIND_ABOVE_CLIENT源码实例Demo

下面列出了android.content.Context#BIND_ABOVE_CLIENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Atomic   文件: ServersActivity.java
/**
 * 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();
}
 
源代码2 项目: android_9.0.0_r45   文件: ProcessRecord.java
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;
        }
    }
}
 
源代码3 项目: android_9.0.0_r45   文件: ActiveServices.java
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);
        }
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: ConnectionRecord.java
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();
}
 
源代码5 项目: springreplugin   文件: ConnectionBindRecord.java
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;
}
 
 方法所在类
 同类方法