2 * Copyright (C) 2013 Koushik Dutta (@koush)
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.koushikdutta.superuser.db;
19 import android.content.Context;
20 import android.content.pm.PackageInfo;
21 import android.content.pm.PackageManager;
22 import android.database.Cursor;
25 public class UidCommand {
26 public String username;
28 public String packageName;
30 public String command;
31 public int desiredUid;
32 public String desiredName;
34 public String getName() {
37 if (packageName != null)
39 if (username != null && username.length() > 0)
41 return String.valueOf(uid);
45 public void getPackageInfo(Context context) {
47 PackageManager pm = context.getPackageManager();
48 PackageInfo pi = context.getPackageManager().getPackageInfo(pm.getPackagesForUid(uid)[0], 0);
49 name = pi.applicationInfo.loadLabel(pm).toString();
50 packageName = pi.packageName;
52 catch (Exception ex) {
56 public void getUidCommand(Cursor c) {
57 uid = c.getInt(c.getColumnIndex("uid"));
58 command = c.getString(c.getColumnIndex("command"));
59 name = c.getString(c.getColumnIndex("name"));
60 packageName = c.getString(c.getColumnIndex("package_name"));
61 desiredUid = c.getInt(c.getColumnIndex("desired_uid"));
62 desiredName = c.getString(c.getColumnIndex("desired_name"));
63 username = c.getString(c.getColumnIndex("username"));