安装在/ system / app文件夹中的应用程序是否自动被认定为具有所有权限的系统应用程序(说实话,我不确定所有权限是什么)。
我在/ system / app中安装了一个应用程序,但它仍然会出现同样的错误:
DatagramSocket socket = new DatagramSocket(67);
生成异常的代码是:
public class myService extends Service implements SensorEventListener {
private SensorManager mSensorManager;
private Sensor mAccelerometer;
...
public int onStartCommand(Intent intent, int flags, int startId) {
//USING SENSOR MANAGER
mSensorManager = mSensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, mSensorManager.SENSOR_DELAY_FASTEST);
return START_STICKY;
}
...
public void onSensorChanged(SensorEvent event) {
...
if(event.sensor.getStringType().equals(Sensor.STRING_TYPE_ACCELEROMETER)) {
//CONVERTING VALUES
mXValuesAcc = (float)(((int)(event.values[0] * 100)) / 100.0);
mYValuesAcc = (float)(((int)(event.values[1] * 100)) / 100.0);
mZValuesAcc = (float)(((int)(event.values[2] * 100)) / 100.0);
//ADDING THREE ACCELEROMETER DATA TOGETEHR
sumXYZ = Math.abs(mXValuesAcc) + Math.abs(mYValuesAcc) + Math.abs(mZValuesAcc);
//MAKING READY TO CALL THE MAIN FRAGMENT ACTIVITY
Intent MainIntent = new Intent(this, myActivity.class);
MainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//SENDING THE sumXYZ VALUE TO THE winLooseState FUNCTION
WinLooseState winLooseState = myAlgo(sumXYZ, eventTimestamp);
//AS A RESULT STATE OF EVENT WILL BE DEFINED
switch (winLooseState) {
case WIN:
...
break;
case LOOSE:
//MAKING PowerManager READY
PowerManager TempPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock TempWakeLock = TempPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP |
PowerManager.ON_AFTER_RELEASE, "TempWakeLock");
// LCD ON
TempWakeLock.acquire();
//DATA TO SEND TO myActivity
MainIntent.putExtra(...);
//CALLING myActivity
startActivity(MainIntent);
// LCD off
TempWakeLock.release();
break;
case DRAW:
...
}
}
}
}
端口67(< 1024)显然是一个特权端口,不允许普通应用访问。
有人可以对此有所了解吗?